
用MATLAB程序编程:分析方程f(x)=sinx-x/2=0正根的分布情况,并用二分法求正根近似值,使误差不超过0.01.
2015-11-28
展开全部
clc;clear
a=0;b=1;
fa=1-a-sin(a);
fb=1-b-sin(b);
c=(a+b)/2;
fc=1-c-sin(c);
if fa*fb>0,break,end
while abs(fc)>0.5*10^(-4)
c=(a+b)/2;
fc=1-c-sin(c);
if fb*fc>0
b=c;
fb=fc;
else
a=c;
fa=fc;
end
end
format long
fx=fc,x=c
结果:
fx =
-2.414986223420179e-005
x =
0.510986328125000
精确
>> x=solve('1-x-sin(x)')
x =
a=0;b=1;
fa=1-a-sin(a);
fb=1-b-sin(b);
c=(a+b)/2;
fc=1-c-sin(c);
if fa*fb>0,break,end
while abs(fc)>0.5*10^(-4)
c=(a+b)/2;
fc=1-c-sin(c);
if fb*fc>0
b=c;
fb=fc;
else
a=c;
fa=fc;
end
end
format long
fx=fc,x=c
结果:
fx =
-2.414986223420179e-005
x =
0.510986328125000
精确
>> x=solve('1-x-sin(x)')
x =
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询