用ezplot看图形
>> ezplot('x*log((x^2-1)^1/2+x)-(x^2-1)^1/2-0.5*x',[-10 10 -1 1])
>> grid
可以看出有4个根.初始值分别为-3 0 2 4
x=6;y=5;
while abs(y-x)>=0.0001
x=(y*log((y^2-1)^1/2+y)-(y^2-1)^1/2)/0.5;
y=x;
end
x
x=6;y=2;
while abs(y-x)>=0.0001
x=(y*log((y^2-1)^1/2+y)-(y^2-1)^1/2)/0.5;
y=x;
end
x
x=6;y=0;
while abs(y-x)>=0.0001
x=(y*log((y^2-1)^1/2+y)-(y^2-1)^1/2)/0.5;
y=x;
end
x
x=2;y=-3;
while abs(y-x)>=0.0001
x=(y*log((y^2-1)^1/2+y)-(y^2-1)^1/2)/0.5;
y=x;
end
x
结果:
x =
4.3321
x =
2.0111