1 SOLVING EQUATIONS OF ONE VARIABLE ELM1222 Numerical Analysis Some of the contents are adopted from Laurene V. Fausett, Applied Numerical Analysis using MATLAB. Prentice Hall Inc., 1999
2 Today s lecture Bisection Method Regula Falsi and Secant Method Newton s Method Fied-Point Iteration Matlab Functions
3 Equations of one variable Finding the zeros of nonlinear functions has a long story Although the solution of quadratic equations of one variable is possible analytically numerical estimation of the zeros or the roots may be desired. If it is impossible or difficult to find an eact solution we should employ numerical techniques for finding roots or zeros of nonlinear equations.
4 Bisection Method y = 2 3 Bisection is a systematic search technique to find a zero of a cont. function. It is dividing the interval into 2 sub-intervals and determining which has the zero in it Here the mid-point is m = a+b 2 The zero can be in the range of either [a, m] or [m, b]
5 Bisection Method Eample 1: Approimate the/a zero of y = f( = 2 3 using Bisection method. Sol.: Since f 1 = 2 and f 2 = 1 we can search for a zero in [1,2]. 3 a = 1 1 3 4 5 2 b = 2 After k iterations the error can be at most b a 2 5
6 Bisection Method Eample 2. Approimate a/the zero of y = f method. = 3 3 2 + 1 using Bisection Sol.: Since f 0 = 1 and f 1 = 1 we can search for a zero in [0,1].
7 Bisection Method Stopping Criteria: Stop the iterations when The function (y i is close enough to zero The change in the succesive iterations is ( i or y i less than a tol value The ma number of iterations ma _iter has reached
Regula Falsi and Secant Methods 8 ELM1222 Numerical Analysis Dr Muharrem Mercimek The Regula Falsi and Secant methods start with two points, (a, f(a and (b, f(b, satisfying the condition that f a. f b < 0 The line through the initial two points a, f a, b, f b can be epressed as: The net approimation to the zero is the value of where the straight line through the initial points crosses the -ais (when y is zero ( ( ( ( b a b a f b f b f y ( ( ( b f a f b f a b b
9 Regula Falsi Method If there is a zero in the interval [a, ], we leave the value of a unchanged and set b =. On the other hand, if there is no zero in [a, ], the zero must be in the interval [, b]; so we set a = and leave b unchanged.
10 Regula Falsi Method Eample 3: Approimate a/the zero of y = f method. = 3 2 using Regula-Falsi Sol.: Since f 1 = 1 and f 2 = 6 we can search for a zero in [1,2]. Our first approimation to the zero is b b f ( b a f ( a 2 6 / 7 8/ 7 1.1429 2 1 f ( b 2 6 6 1 We then find the value of the function: y f ( (8/ 7 3 2 0.5073 Since f(a and y are both negative, but y and f(b have opposite signs
11 Regula Falsi Method Stop the iterations when The function (y i is close enough to zero The change ( i or y i in the succesive iterations is less than a tol value The ma number of iterations ma _iter has reached
12 Secant Method The secant method, closely related to the Regula Falsi method. Instead of choosing the subinterval that must contain the zero, we form the net approimation from the two most recently generated points: At the k-th stage, the new approimation to the zero is kucg.korea.ac.kr 1 0 2 1 y1 y1 y0 k1 k y k k y k1 k1 y k Stopping Criteria: Stop the iterations when The function (y i is close enough to zero The change ( i or y i in the succesive iterations is less than a tol value The ma number of iterations ma _iter has reached
13 Secant Method Eample 4: Approimate the/a zero of y = f( = 2 3 using Secant method. Sol.: Since f 1 = 2 and f 2 = 1 we can search for a zero in [1,2]. 1 0 2 1 1 0 2 1 1 y1 2 (1 y y 1 ( 2 2 1 0 5 3 1.667
14 Newton s Method Like the Regula Falsi and Secant Methods Newton s Method uses a straight line approimation but in this case the line is tangent to the function. f ( f '( 0( 0 f ( 0 When f( 1 = 0 1 k1 0 k f ( f '( 0 0 f ( f '( k k
15 Newton s Method Eample 5: Approimate a/the zero of y = f method. = 4 2 3 using Newton s Sol.: Since f(0 = 3 and f(1 = 1 we can start with 0.5 f ( 4 2 3 f '( 8 1 f ( 0 2 0 0.5 1 f '( 4 0 f ( 1 1 2 1 1.0 7 /8 0.875 f '( 8 1 Stopping Criteria: Stop the iteration when The function (y i is close enough to zero The change ( i or y i in the succesive iterations is less than a tol value The ma number of iterations ma _iter has been reached
16 Oscillations in Newton s Method Newton s method give Oscillatory result for some funtions & initial estimates. 3 2 E f ( 3 3 kucg.korea.ac.kr
17 Fied Point Iteration Method A zero finding problem f = 0 can be converted to solving = g( Solution of equation = g( is investigated Rewrite the equation y = f = 5 3 10 + 3 as an implicit equation 5 3 10 + 3 = 0, = 0.5 3 0.3 = g( Starting with initial guess 0 Evaluate the function up to an iteration number or until the update is so small 1 = 0.5( 0 3 + 3 k = 0.5( k 1 3 + 0.3
18 Fied Point Iteration Method Convergence Theorem of fied-point iteration Not all g( functions converge to a good solution 1- For interval [a, b] of if g( maps values to a, b 2- If g is continuous in a, b 3- if there is a number N < 1 such that g N Then = g( has one solution and k = g( k 1 converges to for any starting point in [a, b] Stopping Criteria: Stop the iterations when The function (y i is close enough to zero The change ( i or y i in the succesive iterations is less than a tol value The ma number of iterations ma _iter has reached kucg.korea.ac.kr 18
19 Fied Point Iteration Method Eample 6: For problem y = f( = cos ( using a helper function g Check if g( may converge. = cos Condition checks: If is in [0,1] g( will be in [0,1] ( is given in term of radians = sin ( is continuous g ( = 0,85 1 g Then = cos ( has one solution and k = g( k 1 converges to for any starting point in [0,1] kucg.korea.ac.kr 19
20 Matlab s Methods roots(p outputs the roots of a polynomial p is a vector Eample 7: find the roots of 3 7 2 + 14 7 p=[1-7 14-7]; roots(p ans = 3.8019 2.445 0.75302 kucg.korea.ac.kr
21 Matlab s Methods fzero( function name,0 function name: string 0 : initial estimate of the root Eample 8: find the roots of 10 0.5; func=@( ^10-0.5 func = @(^10-0.5 fzero(func,0.5 ans = 0.9330 kucg.korea.ac.kr