Anda di halaman 1dari 20

Secant Method Suppose we have two estimates (guesses) x0 and x1 of the root then equation of line passing through

h these point is
y y y (x ) y = x1 x 0 x x 1 1 1 0

f (x ) f (x ) 1 0 x x y (x ) f (x ) = x x 1 1 1 0

This line is called the Secant line (why ?)

Secant Method The root of this line y(x) provides the next better estimate x2 for , so
f (x )(x x ) x = x 1 1 0 2 1 f (x ) f (x ) 1 0

The two initial guesses can be on the same side of g the exact root

Algorithm
f (x n ) x n x n 1 x = xn n +1 f (x ) f (x ) n n 1 1

n 1

| | | n1 Stopping criterion: | xn| |xn+1 xn| pp g Note: formula is similar to Newtons method except we are calculating f '(xn) numerically. g ( y Example (p. 91): Find the largest root of f (x ) = x 6 x 1 = 0 accurate to within =1x10-5. Take initial guess x0 = 2.0, x1 = 1.0

n 0 1 2 3 4 5 6 7 8

xn 2.0 1.0 10 1.01612903 1.19057777 1.11765583 1 11765583

f(xn) 61.0 -1.0 10 - 9.15367726E - 1 6.57465714E - 1 -1 68491177E - 1 1.68491177E

xn-xn-1 -1.0 10 1.612903E - 2 1.7444874E - 1 -7 292194E - 2 7.292194E

1.13472414

-1.13E - 9 root

4.92E - 7

Table 3.3, p. 92

Loss-of-significance error in this formulation g

Secant Method Advantages Converges rapidly than bisection method Root need not be bracketed No derivative of function is required Less computational effort as compared to Newton s Newtons method Disadvantages Convergence depends strongly on the initial guesses x0, x1, hence may not converge Will have problem if f '()=0 convergence is slow as compared to Newtons method co ve ge ce s s ow co pa ed o New o s e od Check the Matlab code for the Secant method p.93

Interpolation and approximation


Interpolation Given a set of data points find and evaluate the function whose graph passes through these data points points. function approximation passing a smooth curve through a set of data p p g g points: x , y | i = 1,........N i i

{(
y

Linear interpolation p

x x y +x x y 0 0 1 P (x ) = 1 (x x ) 1 1 0

(x1,y1)

(x0,y0)

P1(x) interpolates the values yi at the point xi, i = 0,1 P1(xi) = yi ( i = 0,1 , P1(x0) = y0 P1(x1) = y1

Example: Approximate y = x by a straight line over the interval (1,4)

( 4 x )(1) + ( x 1) 2 P (x ) =
1 3

2 1 1 4 x

Example: Give an estimate of e0.826 using the function values e0.82 = 2.270500 and e0.83 = 2.293319 and using linear interpolation Ans: P1(0.826) = 2.2841914

True l T value xT = 2 2841638 2.2841638 How many significant digits of accuracy? 5

Quadratic interpolation

Graph of most data points is curved, so we need to use higher order polynomials, e.g., given data points (x0,y0), (x1,y1) and (x2, y2) , a quadratic polynomial which passes through them can be given as P2(x) = y0L0(x) + y1L1(x) + y2L2(x) with
L (x ) = x x x x 0 0 1 0 2 x x x x 0 1 L (x ) = x x x x 2 2 0 2 1

x x

)(

x x

( (

P2(xi) = yi i = 0,1, 2

x x x x 0 2 L (x ) = x x x x 1 1 0 1 2 Lagrange formula for quadratic interpolating polynomials L0, L1, L2 are Lagrange interpolating Basis functions Each polynomial has degree 2 Li(xj) = ij ij i called K is ll d Kronecker d l function k delta f i ij = 0, i j ij = 1, i = j

( (

Example 4.1.3: Construct P2(x) for the data p p ( ) points ( -1), (1, -1), (2, 7) (0, ) ( ) ( )

( x 1)( x 2 ) L (x ) =

2 0 L (x ) = x ( x 2 ) 1 x ( x 1) L (x ) = 2 2 ( x 1)( x 2 ) 7 x ( x 1) P (x ) = + x ( x 2) + 2 2 2

Example: Give an estimate of e0.826 using the function values e0.82 = 2.270500, e0.83 = 2.293319 and e0.84 = 2.316367 using quadratic interpolation. interpolation Ans: P2(0.826) = 2.2841639 ( )

True value xT = 2.2841638 How many significant digits of accuracy? 7

General case
Given n +1 data points (x0,y0), (x1,y1).(xn,yn) with all xi distinct, p ( y) ( y) ( y The interpolating polynomial of degree n is given as Pn( ) = y0L0 + y1L1 + y2L2 + ynLn (x) (Lagrange interpolating formula) Each Li(x) is a polynomial of degree n given by

x x ..... x x x x ...... x x 0 i 1 i +1 n L (x ) = x x ..... x x i x x ...... x x i 0 i i 1 i i +1 i n i = 0,1, 2.........n , , L (x ) = 0 j n i j ij Note: xj are called nodes P (x ) = y j = 0,1,.....n n j j

)( )(

) ( ) (

Special cases Example 1: For the data (x0, 1), (x1, 1), (x2,1) find the Lagrange interpolating polynomial Ans: P2(x) = 1

Example 2: For the data (x0, m x0), (x1, m x1), (x2,mx2) find the Lagrange interpolating polynomial Ans: P2(x) = mx

Degree of Pn(x) is n

Polynomials are the most commonly used interpolating functions Oth f ti Other functions can also be used for interpolation, instead of l b df i t l ti i t d f polynomials Example: Given the data points (0, 2) and (1, 1) find the function f(x) = a + bex, interpolating this data.

2e 1 e x Ans: f (x ) = e 1

Divided Differences Lagrange formula not very efficient to compute polynomials, e.g., P3(x) polynomials e g calculation does not help in calculating P4(x) , so alternate method is desirable. f (x ) f (x ) 1 0 First-order divided difference of f(x) f [x , x ] = x x 0 1 1 0 Mean-value theorem f [x , x ] = f (c ) c [x , x ] 0 1 0 1 x +x f [x , x ] f 0 1 for x0, x1 close 2 0 1 Example: f(x) = cos(x), x0 = 0.2, x1 = 0.3 f [x , x ] = 0 2473009 0.2473009 0 1 x +x f 0 1 = 0.2474040 2

Newton divided difference Higher-order divided differences are calculated from lower order ones. Second-order divided difference f [x , x ] f [x , x ] 1 2 0 1 f [x , x , x ] = x x 0 1 2 2 0 Third order divided difference Third-order
f [x , x , x ] f [x , x , x ] 1 2 3 0 1 2 f [x , x , x , x ] = x x 0 1 2 3 3 0

nth-order divided difference h d di id d diff

f [x ,...., x ] f [x ,...., x ] 1 n 0 n 1 f [x , , x ] = ,....., x x n 0 n 0

Newton divided difference

f [x , x ] = f (c ) 0 1 f n (c ) f [x ,...., x ] = n! 0 n

min{x ,..., x } c max{x ,..., x } 0 n 0 n

Example: Given f(x) = cos(x), x0 = 0.2, x1 = 0.3, x2 = 0.4, calculate f[x0,x1,x2] f [x , x ] = 0.2473009 f [x , x ] = 0.3427550 0 1 1 2 f (c ) f [x , x , x ] = 0.4772705 f [x , x , x ] = 2! 0 1 2 0 1 2 f (x ) 1 = 0.4776682 f [x , x , x ] 2! 0 1 2

Order of nodes f[x0,x1] = f[x1,x0] f[x0,x1,x2] = f[x0,x2,x1]= f[x2,x0,x1] (any permutation of x0,x1,x2 f[x0,..,xn] = f[xi0,xin] for any permutation (i0,i1,.,in) of (0,1,.n) Coincident nodes

Properties of Divided Differences

f (x ) f (x ) 1 0 = f (x ) f [x , x ] = lim f [x , x ] = lim x x 0 0 0 1 0 1 0 f (c ) x c x Recall f [x , x , x ] = 2! 0 1 2 0 2 x x x x c x 1 0 2 0 0 f (x ) 0 therefore f [x , x , x ] = 2! 0 0 0


x 1 x 0 x 1 x 0

General Case

f n (x ) 0 f [x , x ,....., x ] = n! 0 0 0

x cos(x)

Nodes 1 1.1 1.2 1.3 1.4 0.54030 0.45360 0.36236 0.26750 0.16997 i = 0,1,... , , k = 1, 2,... , ,
D4f(xi) 0.0125

Divided difference table

D k f (x ) = f [x ,..., x , , ] i i i +k
i 0 1 2 3 4 xi 1.0 1.1 11 1.2 1.3 13 1.4 f(xi) 0.54030 0.45360 0 45360 0.36236 0.26750 0 26750 0.16997

Df(xi) -0.8670 -0.9124 0 9124 -0.9486 -0.9753 0 9753

D2f(xi) D3f(xi) -0.2270 0.1533 -0.1810 0 1583 0 1810 0.1583 -0.1335

Reference [1]K.AtkinsonandW.Han,ElementaryNumericalAnalysis,3rd Edition,JohnWiley&Sons2004. [2]http://www.cs.uiowa.edu/~atkinson/ena_master.html

Anda mungkin juga menyukai