00001 maximum number of iterations maxit 50 False position method has converged

00001 maximum number of iterations maxit 50 false

This preview shows page 43 - 52 out of 52 pages.

allowable tolerance es = 0.00001 maximum number of iterations maxit = 50 False position method has converged step xl xu xr f(xr) 1.0000 0 10.0000 4.9661 271.4771 2.0000 4.9661 10.0000 6.0295 27.5652 3.0000 6.0295 10.0000 6.1346 2.4677 4.0000 6.1346 10.0000 6.1440 0.2184 5.0000 6.1440 10.0000 6.1449 0.0193 6.0000 6.1449 10.0000 6.1449 0.0017 7.0000 6.1449 10.0000 6.1449 0.0002 Much faster convergence than the bisection method May be slower than bisection method for some cases
Image of page 43
Why don ' t we always use false position method? There are times it may converge very, very slowly. Example: What other methods can we use? 0 4 x 3 x ) x ( f 4 = - + = Convergence Rate Convergence Rate
Image of page 44
Convergence slower than bisection method midpoint root [ ] [ ] 3 0 x x 0 4 x 3 x x f u l 4 , , ) ( = = - + = 1 2 3 1 2
Image of page 45
0 4 x 3 x ) x ( f 4 = - + = Bisection Method False-Position Method Bisection Method False-Position Method » xl = 0; xu = 3; es = 0.00001; maxit = 100; » [xr,fr]=bisect2(inline( ‘x^4+3*x-4’ )) Bisection method has converged step xl xu xr f(x) 1.0000 0 3.0000 1.5000 5.5625 2.0000 0 1.5000 0.7500 -1.4336 3.0000 0.7500 1.5000 1.1250 0.9768 4.0000 0.7500 1.1250 0.9375 -0.4150 5.0000 0.9375 1.1250 1.0312 0.2247 6.0000 0.9375 1.0312 0.9844 -0.1079 7.0000 0.9844 1.0312 1.0078 0.0551 8.0000 0.9844 1.0078 0.9961 -0.0273 9.0000 0.9961 1.0078 1.0020 0.0137 10.0000 0.9961 1.0020 0.9990 -0.0068 11.0000 0.9990 1.0020 1.0005 0.0034 12.0000 0.9990 1.0005 0.9998 -0.0017 13.0000 0.9998 1.0005 1.0001 0.0009 14.0000 0.9998 1.0001 0.9999 -0.0004 15.0000 0.9999 1.0001 1.0000 0.0002 16.0000 0.9999 1.0000 1.0000 -0.0001 17.0000 1.0000 1.0000 1.0000 0.0001 18.0000 1.0000 1.0000 1.0000 0.0000 19.0000 1.0000 1.0000 1.0000 0.0000 » xl = 0; xu = 3; es = 0.00001; maxit = 100; » [xr,fr]=false_position(inline( ‘x^4+3*x-4’ )) False position method has converged step xl xu xr f(xr) 1.0000 0 3.0000 0.1333 -3.5997 2.0000 0.1333 3.0000 0.2485 -3.2507 3.0000 0.2485 3.0000 0.3487 -2.9391 4.0000 0.3487 3.0000 0.4363 -2.6548 5.0000 0.4363 3.0000 0.5131 -2.3914 6.0000 0.5131 3.0000 0.5804 -2.1454 7.0000 0.5804 3.0000 0.6393 -1.9152 8.0000 0.6393 3.0000 0.6907 -1.7003 9.0000 0.6907 3.0000 0.7355 -1.5010 10.0000 0.7355 3.0000 0.7743 -1.3176 11.0000 0.7743 3.0000 0.8079 -1.1503 12.0000 0.8079 3.0000 0.8368 -0.9991 13.0000 0.8368 3.0000 0.8617 -0.8637 14.0000 0.8617 3.0000 0.8829 -0.7434 15.0000 0.8829 3.0000 0.9011 -0.6375 16.0000 0.9011 3.0000 0.9165 -0.5448 17.0000 0.9165 3.0000 0.9296 -0.4642 18.0000 0.9296 3.0000 0.9408 -0.3945 19.0000 0.9408 3.0000 0.9502 -0.3345 20.0000 0.9502 3.0000 0.9581 -0.2831 …. 40.0000 0.9985 3.0000 0.9988 -0.0086 …. 58.0000 0.9999 3.0000 0.9999 -0.0004
Image of page 46
» x = -2:0.1:2; y = x.^3-3*x+1; z = x*0; » H = plot(x,y, 'r', x,z, 'b' ); grid on; set(H, 'LineWidth' ,3.0); » xlabel( 'x' ); ylabel( 'y' ); title( 'f(x) = x^3 - 3x + 1 = 0' ); Example: Rate of Convergence Example: Rate of Convergence
Image of page 47
>> bisect2(inline( 'x^3-3*x+1' )) enter lower bound xl = 0 enter upper bound xu = 1 allowable tolerance es = 1.e-20 maximum number of iterations maxit = 100 exact zero found step xl xu xr f(xr) 1.0000 0 1.0000 0.5000 -0.3750 2.0000 0 0.5000 0.2500 0.2656 3.0000 0.2500 0.5000 0.3750 -0.0723 4.0000 0.2500 0.3750 0.3125 0.0930 5.0000 0.3125 0.3750 0.3438 0.0094 6.0000 0.3438 0.3750 0.3594 -0.0317 7.0000 0.3438 0.3594 0.3516 -0.0112 8.0000 0.3438 0.3516 0.3477 -0.0009 9.0000 0.3438 0.3477 0.3457 0.0042 10.0000 0.3457 0.3477 0.3467 0.0016 11.0000 0.3467 0.3477 0.3472 0.0003 12.0000 0.3472 0.3477 0.3474 -0.0003 13.0000 0.3472 0.3474 0.3473 0.0000 14.0000 0.3473 0.3474 0.3474 -0.0001 .. . .. . 50.0000 0.3473 0.3473 0.3473 -0.0000 51.0000 0.3473 0.3473 0.3473 0.0000 52.0000 0.3473 0.3473 0.3473 -0.0000 53.0000 0.3473 0.3473 0.3473 -0.0000 54.0000 0.3473 0.3473 0.3473 0 Comparison of rate of convergence for bisection and false-position method Continued on next page
Image of page 48
>> false_position(inline( 'x^3-3*x+1' )) enter lower bound xl = 0 enter upper bound xu = 1 allowable tolerance es = 1.e-20 maximum number of iterations maxit = 100 exact zero found step xl xu xr f(xr) 1.0000 0 1.0000 0.5000 -0.3750 2.0000 0 0.5000 0.3636 -0.0428 3.0000 0 0.3636 0.3487 -0.0037 4.0000 0 0.3487 0.3474 -0.0003 5.0000 0 0.3474 0.3473 -0.0000 6.0000 0 0.3473 0.3473 -0.0000 7.0000 0 0.3473 0.3473 -0.0000 8.0000 0 0.3473 0.3473 -0.0000 9.0000 0 0.3473 0.3473 -0.0000 10.0000 0 0.3473 0.3473 -0.0000 11.0000 0 0.3473 0.3473 -0.0000 12.0000 0 0.3473 0.3473 -0.0000 13.0000 0 0.3473 0.3473 -0.0000 14.0000 0 0.3473 0.3473 -0.0000 15.0000 0 0.3473 0.3473 -0.0000 16.0000 0 0.3473 0.3473 -0.0000 17.0000 0 0.3473 0.3473 0 iter1=length(x1); iter2=length(x2); k1=1:iter1; k2=1:iter2; >> root1=x1(iter1); root2=x2(iter2); >> error1=abs((x1-root1)/root1); error2=abs((x2-root2)/root2); >> H=semilogy(k1,error1, 'ro-' ,k2,error2, 'bs-' ); set(H, 'LineWidth' ,2.0); >> xlabel( 'Number of Iterations' ); ylabel( 'Relative Error' ); Compute relative errors f ( x ) = x 3 – 3x +1 = 0
Image of page 49
Rate of Convergence Rate of Convergence f(x)= x 3 - 3x + 1 Bisection Method False position
Image of page 50
Rate of Convergence Rate of Convergence A few words about convergence We have been looking at ε a as our measure of convergence A more technical means of differentiating the speed of convergence looks at the asymptotic convergence
Image of page 51
Definition: λ is the asymptotic error constant we say that the method converges to x* with order p > 0 . Higher p is faster convergence. p = 1 is linear p = 2 is quadratic 0 some for x x x x p old r new r k = - - λ λ * * lim Rate of Convergence Rate of Convergence Bisection method : p = 1 False-Position : p = 1.4 - 1.6
Image of page 52

You've reached the end of your free preview.

Want to read all 52 pages?

  • Fall '10
  • Elkamal
  • Numerical Analysis, Xu, XR, Root-finding algorithm, Bisection Method

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture