用scilab编的程序,二分法求值的functionB=f(a,b,eps,p)A=p(a); B=A;while (abs(b-a)> eps|abs(B)>eps)x=(a+b)/2B=p(x);if(B==0),break;else if(A=B>0) a=x;else b=x;endendenddisp((a+b)/2,'root=');0=epsendfuctionfunction z=fl(x)z=x^3-x-1endfunction
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/17 11:33:21
![用scilab编的程序,二分法求值的functionB=f(a,b,eps,p)A=p(a); B=A;while (abs(b-a)> eps|abs(B)>eps)x=(a+b)/2B=p(x);if(B==0),break;else if(A=B>0) a=x;else b=x;endendenddisp((a+b)/2,'root=');0=epsendfuctionfunction z=fl(x)z=x^3-x-1endfunction](/uploads/image/z/13320528-24-8.jpg?t=%E7%94%A8scilab%E7%BC%96%E7%9A%84%E7%A8%8B%E5%BA%8F%2C%E4%BA%8C%E5%88%86%E6%B3%95%E6%B1%82%E5%80%BC%E7%9A%84functionB%3Df%28a%2Cb%2Ceps%2Cp%29A%3Dp%28a%29%3B+B%3DA%3Bwhile+%28abs%28b-a%29%3E+eps%7Cabs%28B%29%3Eeps%29x%3D%28a%2Bb%29%2F2B%3Dp%28x%29%3Bif%28B%3D%3D0%29%2Cbreak%3Belse+if%28A%3DB%3E0%29+a%3Dx%3Belse+b%3Dx%3Bendendenddisp%28%28a%2Bb%29%2F2%2C%27root%3D%27%29%3B0%3Depsendfuctionfunction+z%3Dfl%28x%29z%3Dx%5E3-x-1endfunction)
用scilab编的程序,二分法求值的functionB=f(a,b,eps,p)A=p(a); B=A;while (abs(b-a)> eps|abs(B)>eps)x=(a+b)/2B=p(x);if(B==0),break;else if(A=B>0) a=x;else b=x;endendenddisp((a+b)/2,'root=');0=epsendfuctionfunction z=fl(x)z=x^3-x-1endfunction
用scilab编的程序,二分法求值的
functionB=f(a,b,eps,p)
A=p(a); B=A;
while (abs(b-a)> eps|abs(B)>eps)
x=(a+b)/2
B=p(x);
if(B==0),break;
else if(A=B>0) a=x;
else b=x;
end
end
end
disp((a+b)/2,'root=');
0=eps
endfuction
function z=fl(x)
z=x^3-x-1
endfunction
用scilab编的程序,二分法求值的functionB=f(a,b,eps,p)A=p(a); B=A;while (abs(b-a)> eps|abs(B)>eps)x=(a+b)/2B=p(x);if(B==0),break;else if(A=B>0) a=x;else b=x;endendenddisp((a+b)/2,'root=');0=epsendfuctionfunction z=fl(x)z=x^3-x-1endfunction
放在scilab里面?第一行多余,scilab不认.输出也不能这么写.去掉c(1,num)=y; end后再输出而且你这个输出是少一次的.要是想每一步都输出一次y,就