早教吧 育儿知识 作业答案 考试题库 百科 知识分享

用二分法求方程x3+4x2-10=0在[1,2]之间的根,要求精度为0.005

题目详情
用二分法求方程x3+4x2-10=0在[1,2]之间的根,要求精度为0.005
▼优质解答
答案和解析
#include"stdio.h"
//#include"conio.h"
#include"math.h"
float fun(float x)
{
return (x*x*x+4*x*x-10);
}
float xpoint(float x1,float x2)
{
return (x1+x2)/2;
}
float root(float x1,float x2)
{
float x,y,y1,y2;
y1=fun(x1);
printf("");
y2=fun(x2);
do
{x=xpoint(x1,x2);
y=fun(x);
if(y1*y