Download presentation

Presentation is loading. Please wait.

Published byMaddison Tansill Modified about 1 year ago

1
Numerical Computation Lecture 4: Root Finding Methods - II United International College

2
Review During our Last Class we covered: – Algorithm Convergence – Root Finding: Bisection Method, Newton’s Method

3
Today We will cover: – Root Finding: More on Newton’s Method, Secant Method – Section 4.3 in Pav – Sections 4.4 and 4.6 in Moler

4
Uses of Newton’s Method Newton's Method can be used to program more complex functions using only simple functions. Problem: A computer only has addition, subtraction, multiplication, division, and we need to compute some complex function g(x). Solution: Use Newton's Method to solve some equation equivalent to g(z) - x = 0, where z is the input to the subroutine. Then, x is the numerical value for g(z).

5
Uses of Newton’s Method Example: Find Solution: Use Newton's Method for f(x) = z - x 2. – Iterations : – Simplify : Practice: Write a Matlab M-function program to find the sqrt(z) to a specified accuracy eps.

6
Secant Method Newton’s Method is fast (quadratic convergence). However, Newton’s Method requires knowledge of the derivative of f(x). This is hard to do programmatically. Needed: An algorithm that is (hopefully) as fast as Newton’s Method, but does not require f’(x). Solution: Secant Method

7
Secant Method Recall: Newton’s method Problem is f’(x k ). We know that the derivative is a limit of the difference quotient We can approximate this by using x=x k-1, as we assume that the iterates {x k } are close to one another.

8
Secant Method In other words, instead of following the tangent line to get the next iterate (Newton’s Method), we follow the secant line.

9
Secant Method The secant line has equation: We want to find where it crosses the x-axis, i.e. where y = 0. So,

10
Secant Method Secant Iterates: Note: We will have to supply two initial guesses: x 0 and x 1.

11
Secant Method Matlab Implementation: function v = secant( f, x1, x0, eps) %Secant method % Assumes f is differentiable k = 0; xprev = x0; xnext = x1; while abs(xnext - xprev) > eps*abs(xnext) xtmp = xnext; xnext = xnext - ((xnext-xprev)/(f(xnext)-f(xprev)))*f(xnext); xprev = xtmp; k = k + 1; v = [xnext k]; end

12
Secant Method Practice: Run this program to find the sqrt(2) to an accuracy of How does the speed of the Secant Method compare to Newton’s Method?

13
Secant Method Convergence: Pav (Section 4.3) shows that the error in the Secant method has the following order of growth: where This called super-linear convergence. It is slower than quadratic, but faster than linear. So, somewhere between the speed of bisection and Newton.

14
Inverse Quadratic Interpolation Method (IQI) Secant Method uses a line to approximate f(x) and then finds where that line crosses the x- axis. Idea: Use a parabola (quadratic) to approximate f(x) and find where parabola crosses x-axis. Problem: Parabola might have complex roots! It might not cross the x-axis.

15
Inverse Quadratic Interpolation Method (IQI) Solution: Inverse approximation (interpolation) – we think of x k as a function of y k =f(x k ) We get a quadratic p(y) and the next approximation x k+1 is just p(0).

16
Inverse Quadratic Interpolation Method (IQI) f(x)

17
Inverse Quadratic Interpolation Method (IQI) Convergence: It can be shown (Michael T Heath’s book Scientific Computing) that where α ≈ So this method is almost as fast as Newton’s method, and does not require derivatives.

18
Matlab Root-finding fzero algorithm: Matlab has a function called fzero that will find the root of a function, starting from an initial guess. It uses a combination of the bisection, secant, and inverse quadratic methods. Idea: We use bisection and secant to get a good approximation, then use IQI to rapidly close in on the root. Algorithm is listed as zeroin in section 4.6 of Moler text.

19
Practice (If time) Try Exercise 4.9. in Moler Find the first ten positive values of x for which x = tan x. How can we do this in one Matlab M-function file?

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google