相关代码 |
|
function erfen %二分法解方程 syms x y ; y = input('请输入迭代函数f(x):'); v = input('请输入迭代条件[a,b,e]:'); a = v(1); b = v(2); e = v(3); while abs(b-a)>e c = 0.5 * (a + b); x = c; fc = eval(y); x = a; fa = eval(y); if fc==0 c elseif fa==0 a elseif fa*fc>0 a = c; else b = c; end end a b 0.5 * (a + b)
相关资源 |
|