ISC 210 Computational Methods Zeroes and Roots Spring

  • Slides: 11
Download presentation
ISC 210 Computational Methods Zeroes and Roots Spring 2009 -2010 Dr. Jehad Al Dallal

ISC 210 Computational Methods Zeroes and Roots Spring 2009 -2010 Dr. Jehad Al Dallal

Bisection Method n n Given a continuous function f(x) on a given interval [a,

Bisection Method n n Given a continuous function f(x) on a given interval [a, b] such that f(a)f(b)<0 Algorithm 1. 2. 3. 4. Define c=(a+b)/2 If b-c , then accept root=c and exit If f(b)f(c) 0, then a=c, otherwise b=c Return to step 1

Example 1 n Find the square root of 2 , =0. 05 n n

Example 1 n Find the square root of 2 , =0. 05 n n n Between 1 and 2 Try 1. 5 -> 1. 52=2. 25 ->[1, 1. 5] Try 1. 25 -> 1. 252=1. 5625 ->[1. 25, 1. 5] Try 1. 375 -> 1. 3752=1. 8906 ->[1. 375, 1. 5] Try 1. 4375 -> 1. 343752=2. 0664 ->[1. 375, 1. 4375] Try 1. 4063 1. 4375 -1. 4063<0. 05 -> ans=1. 4063

Example 2 n Find the root of f(x)=x 6 -x-1 , =0. 05 n

Example 2 n Find the root of f(x)=x 6 -x-1 , =0. 05 n n n Between 1 and 2 Try 1. 5 -> f(x)=8. 8906 Try 1. 25 -> f(x)=1. 5647 Try 1. 125 -> f(x)= =-. 0977 Try 1. 1875 -> f(x)= =. 6167 Try 1. 1563 -1. 125<0. 05 ->[1, 1. 5] ->[1, 1. 25] ->[1. 125, 1. 1875] -> ans=1. 1563

Newton’s Method n n Given a continuous function f(x) and an initial value x

Newton’s Method n n Given a continuous function f(x) and an initial value x 0 Algorithm 1. 2. 3. xn+1 = xn – f(xn)/f’(xn) If | xn+1 - xn| , then accept root= xn+1 and exit Else 1. 2. xn = xn+1 go to step 1

Example (1) n Find the root of f(x)=x 6 -x-1 , =0. 05, x

Example (1) n Find the root of f(x)=x 6 -x-1 , =0. 05, x 0=2 n n n f’(x)=6 x 5 -1 X=1. 681 X=1. 431 X=1. 255 X=1. 162 X=1. 136 <- answer

Example 2 n How to find the square root of 2, starting at x=1

Example 2 n How to find the square root of 2, starting at x=1 ? ?

Secant Method n n n Two initial points are required xn+1 = xn –

Secant Method n n n Two initial points are required xn+1 = xn – f(xn)(xn-xn-1)/[f(xn)- f(xn-1)] The steps are similar to Newton’s method steps.

Example n Find the root of f(x)=x 6 -x-1 , =0. 05 n n

Example n Find the root of f(x)=x 6 -x-1 , =0. 05 n n n f(1)=-1, f(2)=61 X 2=1. 016 X 3=1. 031 <- answer

Inverse Quadratic Interpolation (IQI) Method n n n Use three points (a, f(a)), (b,

Inverse Quadratic Interpolation (IQI) Method n n n Use three points (a, f(a)), (b, f(b)), (c, f(c)) Find the new point by interpolating the previous three points In the interpolation, interpolate for y. In the resulting formula, make y=0 and find x. Find f(x) Ignore the first point and shift the points such that a=b, b=c, and c=x. Repeat the steps till |c- b| *|c|

Example n n n Same example (1, -1), (1. 5, 8. 89), (2, 61)

Example n n n Same example (1, -1), (1. 5, 8. 89), (2, 61) x=1. 0564 f(x)=-0. 667 Ignore (1, -1). The new points are: (1. 5, 8. 89), (2, 61), (1. 0564, -0. 667) |1. 0564 -2|>0. 05*1. 0564 (you have to continue)