clc
clear all
a=1,b=2,n=20,t=0.005,i=1,x=a;
fa=x^3+4*x^2-10;
while i<=n
p=(a+b)/2;
x=p;
fp=x^3+4*x^2-10;
fpt=fp;
fpt=(fpt^2)^0.5;
fpt
if fpt<=0.005
fpt
x
i
break;
end
i=i+1;
if fa*fp>0
fa=fp;
a=p;
else
b=p;
end
end
clear all
a=1,b=2,n=20,t=0.005,i=1,x=a;
fa=x^3+4*x^2-10;
while i<=n
p=(a+b)/2;
x=p;
fp=x^3+4*x^2-10;
fpt=fp;
fpt=(fpt^2)^0.5;
fpt
if fpt<=0.005
fpt
x
i
break;
end
i=i+1;
if fa*fp>0
fa=fp;
a=p;
else
b=p;
end
end
No comments:
Post a Comment