Iteration Diagrams and Convergence © Christine Crisp There are some equations that we can’t solve. e.g. x 1 x 3 However, we can find an approximate solution to some of these equations. The approximation can be very accurate, say to 6 or more decimal places. There are several methods of finding approximate solutions and in this presentation we will study one of them. There are 2 stages to getting a solution: Stage 1. Find a 1st estimate Stage 2. Find a formula to improve the estimate. Sometimes we can just spot an approximate solution to an equation. Can you spot the approximate value of the solution to x3 2x 1 ? Ans: It’s quite close to 0 as the l.h.s. is then 0 and the r.h.s. is 1. If we can’t quickly spot an approximation, we can use a method involving finding bounds for the solution. Bounds are numbers which lie on either side of the solution. If these are integers we call them integer bounds. e.g. To find integer bounds for x 1 x 3 we can sketch y x and y 1 x 3 y 1 x3 This is the point . . . where y x y x and so the x coordinate gives the solution to y 1 x3 x 1 x3 Rearrange the equation to get zero on one side. e.g. For x 1 x 3 , get x 3 1 x 0 Call this f ( x) 0 To show how the method works I’m going to sketch y f ( x ) ( but you won’t usually have to do this ). The solution, a, is f ( x) x 3 1 x now where f ( x) 0 a At a, f ( x) 0 To the left of a, e.g. at x = 0, f ( x ) 1 0 To the right of a, e.g. at x = 1, f ( x ) 1 0 Iteration diagrams and Convergence Once we have the bounds we may try and get a formula to find the root x 1 x 3 Using the formula x n1 1 we got xn 1 3 with x0 0 5 x 0 0 5 , x1 0 66 , x 2 0 57 , . . . The solution to the equation we called a. We can illustrate the iteration process on a diagram. Iteration diagrams and Convergence x n 1 1 x n 1 3 1 3 we draw y 1 x and yx So, a is the x-coordinate of the point of intersection. For y 1 x 1 3 yx a a 0 605423 ( to 6 d.p. ) We’ll zoom in on the graph to enlarge the part near the intersection. Iteration diagrams and Convergence We start the iteration with x1 1 x 0 and we substituted x 0 0 5 to get x1 . On the diagram we draw from x 0 to the curve . . . y 1 x 1 3 1 3 yx Iteration diagrams and Convergence We started the iteration with x1 1 x 0 and we substituted x 0 0 5 to get x1 . On the diagram we draw from x 0 to the curve . . . which gives a y-value, y 0 66 y 1 x 1 3 x (0 5, 0 66) x0 1 3 yx Iteration diagrams and Convergence We started the iteration with x1 1 x 0 and we substituted x 0 0 5 to get x1 . On the diagram we draw from x 0 to the curve . . . which gives a y-value, y 0 66 y 1 x 1 3 yx 1 3 x x x0 x1 (0 5, 0 66) (0 66, 0 66) By drawing across to y = x this y-value gives the point where x 0 66 . This is x1 . Iteration diagrams and Convergence In the iteration, x1 is now substituted into x 2 1 x1 to give x 2 . On the diagram we draw from (0 66, 0 66) to the curve . . . giving the next y-value. y 1 x yx 1 3 x (0 5, 0 66) x (0 66, 0 66) x(0 66, x0 0 57) x1 The next line converts this y-value to x 2 and so on. 1 3 Iteration diagrams and Convergence In the iteration, x1 is now substituted into x 2 1 x1 to give x 2 . On the diagram we draw from (0 66, 0 66) to the curve . . . giving the next y-value. y 1 x yx 1 3 x x (0 66, 0 66) (0 5, 0 66) x(0 66, x0 1 3 x2 0 57) x1 The next line converts this y-value to x 2 and so on. x 0 0 5 , x1 0 66 , x 2 0 57 , . . . The lines are drawn to the curve and y = x alternately, starting by joining x 0 to the curve. Iteration diagrams and Convergence The diagram we’ve drawn illustrates a convergent, oscillating sequence. y 1 x yx 1 3 a x0 x2 x4 x3 x1 This is called a cobweb diagram. Iteration diagrams and Convergence Looking at the original graph, we have y 1 x 1 3 yx a x0 Iteration diagrams and Convergence SUMMARY To draw a diagram illustrating Draw x g( x ) iteration: y g( x ) and y x on the same axes. Mark x 0 on the x-axis and draw a line parallel to the y-axis from x 0 to y g ( x ) ( the curve ). Continue the cobweb line, going parallel to the x-axis to meet y x . Continue the cobweb line, going parallel to the y-axis to meet y g( x ) . Repeat Iteration diagrams and Convergence Iteration does not always give an oscillating sequence. We can also draw a diagram for sequences which iterate directly towards the solution. I am going to use an example presentation: Solve x 2x 3 Iteration diagrams and Convergence Before we zoom in, the graphs look like this. yx y 3 2x The solution has 2 roots. We will find the one nearest to the origin. Iteration diagrams and Convergence x n1 2 So, to 3 x0 1 5 xn yx This is called a staircase diagram. y 3 2x a x2 x1 x0 Iteration diagrams and Convergence Exercise Copy the following graphs and sketch the diagrams which illustrate the convergence of the iterative process, showing x 0 , x1 , x 2 and a (a) (b) y g( x ) yx yx y g( x ) x0 2 5 x0 1 5 Write on the names of the diagrams. Iteration diagrams and Convergence Solution: (a) yx y g( x ) a x0 x2 x3 A cobweb diagram. x1 Iteration diagrams and Convergence Solution: (b) yx y g( x ) a x2 x1 A staircase diagram. x0 Iteration diagrams and Convergence In the next example we’ll look at an equation which has 2 roots and the iteration produces a surprising result. The equation is e x20. x We’ll try the simplest iterative formula first : ex 2 x x n1 e xn 2 Iteration diagrams and Convergence Let’s try x n1 positive root. e x n 2 with x 0 close to the y ex 2 yx Let x0 1 5 a Iteration diagrams and Convergence Let’s try x n1 positive root. e x n 2 with x 0 close to the The staircase moves away from the root. y ex 2 yx a x0 x1 The sequence diverges rapidly. Using the iterative formula, x1 2 48 , x 2 9 96 Iteration diagrams and Convergence Suppose we try a value for x0 on the left of the root. y ex 2 yx a x0 Iteration diagrams and Convergence Suppose we try a value for x0 on the left of the root. y ex 2 yx a x1 Iteration diagrams and Convergence Suppose we try a value for x0 on the left of the root. y ex 2 yx x2 a Iteration diagrams and Convergence Suppose we try a value for x0 on the left of the root. y ex 2 yx a x3 Iteration diagrams and Convergence Suppose we try a value for x0 on the left of the root. y ex 2 yx a The sequence now converges but to the other root ! Iteration diagrams and Convergence It is possible to use our iterative method to find a in the previous example but not with the arrangement we had. The equation was e x x 2 0 . The rearrangement we used was x x formula was x n1 e n 2. With x0 1 ex 2 this gives the negative root: so the 4 d.p. ) We can also arrange the equation as follows: 1 8414 ( ex x 2 0 ex x 2 Change to log form: x ln( x 2) giving x n1 ln( x n 2) With x 0 1 ,a 1 1462 ( 4 d.p. ) Iteration diagrams and Convergence We will now look at why some iterative formulae give sequences that converge whilst others don’t and others converge or diverge depending on the starting value. Collecting the diagrams together gives us a clue. I’ve included the 4th type of diagram that we haven’t yet met: a diverging cobweb. See if you can spot the important difference once you can see the 4 diagrams Iteration diagrams and Convergence Staircase: converging Cobweb: converging yx yx y g( x ) y g(x ) a x0 The gradients of for the converging x2 x3 x1 g ( x ) a x 2 x1 sequences are shallow yx y g( x ) y g( x ) x3 x1 a x 0 x2 Cobweb: diverging yx a x 0 x1 x0 x2 Staircase: diverging Iteration diagrams and Convergence It can be shown that x n1 g( x n ) gives a convergent sequence if the gradient of g ( x ) . . . is between 1 and +1 at the root. g / ( x) We write 1 g / (a ) 1 or, g (a ) 1 / Unfortunately since we are trying to find a we don’t know its value and can’t substitute it ! In practice, to test for convergence we use a value close to the root. The closer g / (a ) is to zero, the faster will be the convergence. Iteration diagrams and Convergence e.g. By using calculus, determine which of the following arrangements of the equation ln x 4 x will give convergence to a root near x = 3 and which will not. (a) x 4 ln x Solution: (b) x e 4 x (a) g(x) 4 ln x 1 g (x) x 1 / g (3) 1 g/( 3 ) 1 3 / The sequence will converge. Iteration diagrams and Convergence e.g. By using calculus, determine which of the following arrangements of the equation ln x 4 x will give convergence to a root near x = 3 and which will not. (a) x 4 ln x Solution: (b) x e 4 x (b) g(x) e 4 x g / (x) e 4 x g / ( 3 ) e 2 7 The sequence will not converge. Iteration diagrams and Convergence We can now see why we had the strange result when we tried to solve e x x 2 0 with x n1 e xn 2 At , the gradient is less than 1 ( so the curve here is shallower than y = x ): the iteration converges. y ex 2 yx a At a , the gradient is greater than 1 ( so the curve here is steeper than y = x ): the iteration diverges. Iteration diagrams and Convergence We can now see why we had the strange result when we tried to solve e x x 2 0 with x n1 e xn 2 y ex 2 yx a Both iterations started close to a but the one that converged to started on the left of a . Iteration diagrams and Convergence SUMMARY To show that a formula of the type will give a convergent sequence, find show that x n1 g( x n ) g / ( x) g / ( x ) 1 , where x is close to the solution.