MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   bisection methods? (https://www.labfans.com/bbs/showthread.php?t=4692)

meteora1005 2008-10-03 23:45

回复: bisection methods?
 
你的y算出来都是2啊,肯定哪错了,我不太懂bisection的原理,还是自己好好检查一下

木心 2008-10-04 01:27

回复: bisection methods?
 
好像图做出来了...但结果好像有点乱...我再查一遍...
谢谢:)

y=zeros(1,200);
i=1;
for x=0:0.01:2
a=-2;b=2; % try 200 x, get 200 y
while (b-a)/2>10^(-12)
c=(a+b)/2;

if (x^3+x*a+a^3)*(x^3+x*c+c^3)== 0 , %c is a solution, done
break;
end
if (x^3+x*a+a^3)*(x^3+x*c+c^3)<0 %a and c make the new interval
b=c;
else %c and b make the new interval
a=c;
end
end

y(i)=(a+b)/2; %new midpoint is best estimate
i=i+1;
disp('x=');
disp (x);

disp('y=');
disp (y) ;
end
x=0:0.01:2
plot(x,y)

meteora1005 2008-10-04 13:01

回复: bisection methods?
 
我看图已经画对了啊,基本成功了:biggrin:


所有时间均为北京时间。现在的时间是 13:48

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.