Views
5 months ago

numerical3j

{18} • Numerical

{18} • Numerical Methods The Algorithm We can now describe Newton’s method algebraically. Starting from x 1 , the above calculation shows that if we construct the tangent line to the graph y = f (x) at x = x 1 , this tangent line has x-intercept given by x 2 = x 1 − f (x 1) f ′ (x 1 ) . Then, starting from x 2 we perform the same calculation, and obtain the next approximation x 3 as x 3 = x 2 − f (x 2) f ′ (x 2 ) . The same calculation applies at each stage: so from the n’th approximation x n , the next approximation is given by x n+1 = x n − f (x n) f ′ (x n ) . Formally, Newton’s algorithm is as follows. [Newton’s method] Let f : R → R be a differentiable function. We seek a solution of f (x) = 0, starting from an initial estimate x = x 1 . At the n’th step, given x n , compute the next approximation x n+1 by x n+1 = x n − f (x n) f ′ (x n ) and repeat. Some comments about this algorithm: 1 Often, Newton’s method works extremely well, and the x n converge rapidly to a solution. However, it’s important to note that Newton’s method does not always work. Several things can go wrong, as we will see shortly. 2 Note that if f (x n ) = 0, so that x n is an exact solution of f (x) = 0, then the algorithm gives x n+1 = x n , and in fact all of x n , x n+1 , x n+2 , x n+3 ,... will be equal. If you have an exact solution, Newton’s method will stay on that solution! 3 While the bisection method only requires f to be continuous, Newton’s method requires the function f to be differentiable. This is necessary for f to have a tangent line. Using Newton’s method As we did with the bisection method, let’s approximate some well-known constants.

A guide for teachers – Years 11 and 12 • {19} Example Use Newton’s method to find an approximate solution to x 2 − 2 = 0, starting from an initial estimate x 1 = 2. After 4 iterations, how close is the approximation to 2? Solution Let f (x) = x 2 −2, so f ′ (x) = 2x. At step 1, we have x 1 = 2 and we calculate f (x 1 ) = 2 2 −2 = 2 and f ′ (x 1 ) = 4, so x 2 = x 1 − f (x 1) f ′ (x 1 ) = 2 − 2 4 = 3 2 = 1.5. At step 2, from x 2 = 3 2 we calculate f (x 2) = 1 4 and f ′ (x 2 ) = 3, so x 3 = x 2 − f (x 2) f ′ (x 2 ) = 3 1 2 − 4 3 = 17 ∼ 1.41666667 (to 8 decimal places). 12 At step 3, from x 3 = 17 12 we have f (x 3) = 1 144 and f ′ (x 3 ) = 17 6 , so x 4 = x 3 − f (x 3) f ′ (x 3 ) = 17 12 − 1 144 17 6 = 577 ∼ 1.41421569 (to 8 decimal places). 408 At step 4, from x 4 = 577 408 we calculate f (x 4) = 1 166,464 and f ′ (x 4 ) = 577 204 , so x 5 = x 4 − f (x 4) f ′ (x 4 ) = 665,857 ∼ 1.414213562375 (to 12 decimal places). 470,832 In fact, to 12 decimal places 2 ∼ 1.414213562373. So after 4 iterations, the approximate solution x 5 agrees with 2 to 11 decimal places. The difference between x 5 and 2 is 665,857 470,832 − 2 ∼ 1.59 × 10 −12 to 3 significant figures. Newton’s method in the above example is much faster than the bisection algorithm! In only 4 iterations we have 11 decimal places of accuracy! The following table illustrates how many decimal places of accuracy we have in each x n . n 1 2 3 4 5 6 7 # decimal places accuracy in x n 0 0 2 5 11 23 47 The number of decimal places of accuracy approximately doubles with each iteration!