Matlab Math 零点和根 Cleve morler著 陈文斌(wbchen@fudan.edu.cn) 复旦大学2002
Matlab Math Cleve Morler著 陈文斌(wbchen@fudan.edu.cn) 复旦大学2002 零点和根
Bisection 我们知道√2在1和2之间,先试x=32,因为x的平 方大于2,那么√2在[,321 3.513.27 24816”32”64 ATLAB M=2a=1b=3k=0 else while b-aeps a=X X=(a+b)/2; end ifx>m k=k+1; b=x end
Bisection 我们知道 在1和2之间,先试x=3/2,因为x的平 方大于2,那么 在[1,3/2]… 2 2 ,... 64 27 ,1 32 13 ,1 16 5 ,1 8 3 ,1 4 1 ,1 2 1 1 M=2;a=1;b=3;k=0; while b-a>eps x=(a+b) /2; if x^2 >M b=x else a = x end k=k+1; end
Interval bisection 观察一下ab变化的情况: 程序结束需要多少次? 最后ab是多少? 用 format hex表示呢? 为什么是这样的?
Interval bisection 观察一下a,b变化的情况: 程序结束需要多少次? 最后a,b是多少? 用format hex表示呢? 为什么是这样的?
Interval bisection--f(x) Find a very small interval, perhaps two successive floating point numbers on which the function change sign MATLAB else while abs(b-a >eps*abs(b)a=x X=(a+b)/2 end if sign(f(x)==sign(f(b))k=k+1 b=x en f= inline(x^2-2");a=1;b-2: 计算sqrt(2)
Interval bisection--f(x) Find a very small interval, perhaps two successive floating point numbers, on which the function change sign. k=0; while abs(b-a)>eps*abs(b) x=(a+b) /2; if sign(f(x)==sign(f(b)) b=x; else a = x; end k = k+1; end f = inline('x^2-2'); a=1; b=2; 计算sqrt(2)
Interval bisection 分法是慢的,用上面的代码,对任何 函数她都需要运行52步,但是她是完全 可靠的。这与我们后面介绍的方法不同
Interval bisection 二分法是慢的,用上面的代码,对任何 函数她都需要运行52步,但是她是完全 可靠的。这与我们后面介绍的方法不同