CS227-Scientific Computing. Lecture 6: Nonlinear Equations

Similar documents
Solution of Equations

Interpolation. 1 What is interpolation? 2 Why are we interested in this?

This method uses not only values of a function f(x), but also values of its derivative f'(x). If you don't know the derivative, you can't use it.

Introduction to Numerical Methods (Algorithm)

Finding Roots by "Closed" Methods

CS 3331 Numerical Methods Lecture 2: Functions of One Variable. Cherung Lee

February 2 Math 2335 sec 51 Spring 2016

lecture 31: The Secant Method: Prototypical Quasi-Newton Method

4.2 Rolle's Theorem and Mean Value Theorem

The method of false position is also an Enclosure or bracketing method. For this method we will be able to remedy some of the minuses of bisection.

EGR 102 Introduction to Engineering Modeling. Lab 09B Recap Regression Analysis & Structured Programming

Numerical Analysis Math 370 Spring 2009 MWF 11:30am - 12:25pm Fowler 110 c 2009 Ron Buckmire

Chapter 7 One-Dimensional Search Methods

Feb. 4 Math 2335 sec 001 Spring 2014

In a moment, we will look at a simple example involving the function f(x) = 100 x

Topic #1: Evaluating and Simplifying Algebraic Expressions

Solutions of Equations in One Variable. Secant & Regula Falsi Methods

Math 1526 Summer 2000 Session 1

BARUCH COLLEGE MATH 2003 SPRING 2006 MANUAL FOR THE UNIFORM FINAL EXAMINATION

Makinde, V. 1,. Akinboro, F.G 1., Okeyode, I.C. 1, Mustapha, A.O. 1., Coker, J.O. 2., and Adesina, O.S. 1.

69

Unit 3: Writing Equations Chapter Review

Chapter 6: Quadratic Functions & Their Algebra

Chapter 2 Rocket Launch: AREA BETWEEN CURVES

Lab 14: Accumulation and Integration

Lecture Quantitative Finance Spring Term 2015

2) Endpoints of a diameter (-1, 6), (9, -2) A) (x - 2)2 + (y - 4)2 = 41 B) (x - 4)2 + (y - 2)2 = 41 C) (x - 4)2 + y2 = 16 D) x2 + (y - 2)2 = 25

The Zero Product Law. Standards:

Worksheet A ALGEBRA PMT

Chapter 4 Factoring and Quadratic Equations

Symmetric Game. In animal behaviour a typical realization involves two parents balancing their individual investment in the common

The Intermediate Value Theorem states that if a function g is continuous, then for any number M satisfying. g(x 1 ) M g(x 2 )

Mathematics 102 Fall Exponential functions

What can we do with numerical optimization?

25 Increasing and Decreasing Functions

5.1 Exponents and Scientific Notation

Developmental Math An Open Program Unit 12 Factoring First Edition

THE TRAVELING SALESMAN PROBLEM FOR MOVING POINTS ON A LINE

Figure (1) The approximation can be substituted into equation (1) to yield the following iterative equation:

CCAC ELEMENTARY ALGEBRA

Lecture 4: Divide and Conquer

Hints on Some of the Exercises

Before How can lines on a graph show the effect of interest rates on savings accounts?

1. Average Value of a Continuous Function. MATH 1003 Calculus and Linear Algebra (Lecture 30) Average Value of a Continuous Function

Factoring is the process of changing a polynomial expression that is essentially a sum into an expression that is essentially a product.

Math 229 FINAL EXAM Review: Fall Final Exam Monday December 11 ALL Projects Due By Monday December 11

EC316a: Advanced Scientific Computation, Fall Discrete time, continuous state dynamic models: solution methods

Some derivative free quadratic and cubic convergence iterative formulas for solving nonlinear equations

Lecture 6: Option Pricing Using a One-step Binomial Tree. Thursday, September 12, 13

Optimization 101. Dan dibartolomeo Webinar (from Boston) October 22, 2013

Math1090 Midterm 2 Review Sections , Solve the system of linear equations using Gauss-Jordan elimination.

Direct Methods for linear systems Ax = b basic point: easy to solve triangular systems

Mathematics Department A BLOCK EXAMINATION CORE MATHEMATICS PAPER 1 SEPTEMBER Time: 3 hours Marks: 150

Characterization of the Optimum

Since his score is positive, he s above average. Since his score is not close to zero, his score is unusual.

Study Guide and Review - Chapter 2

Mathematics (Project Maths Phase 2)

Analysing and computing cash flow streams

Factoring is the process of changing a polynomial expression that is essentially a sum into an expression that is essentially a product.

Extra Practice Chapter 6

Maximum Likelihood Estimation Richard Williams, University of Notre Dame, Last revised January 13, 2018

Properties of IRR Equation with Regard to Ambiguity of Calculating of Rate of Return and a Maximum Number of Solutions

V(0.1) V( 0.5) 0.6 V(0.5) V( 0.5)

MLC at Boise State Polynomials Activity 3 Week #5

Notes on a Basic Business Problem MATH 104 and MATH 184 Mark Mac Lean (with assistance from Patrick Chan) 2011W

List the quadrant(s) in which the given point is located. 1) (-10, 0) A) On an axis B) II C) IV D) III

Math Lab 5 Assignment

EXAMPLE: Find the Limit: lim

UNIT 5 QUADRATIC FUNCTIONS Lesson 2: Creating and Solving Quadratic Equations in One Variable Instruction

MATH20330: Optimization for Economics Homework 1: Solutions

GovernmentAdda.com. Data Interpretation

Lab 10: Optimizing Revenue and Profits (Including Elasticity of Demand)

PRELIMINARY EXAMINATION 2018 MATHEMATICS GRADE 12 PAPER 1. Time: 3 hours Total: 150 PLEASE READ THE FOLLOWING INSTRUCTIONS CAREFULLY

Calculus Chapter 3 Smartboard Review with Navigator.notebook. November 04, What is the slope of the line segment?

Slope-Intercept Form Practice True False Questions Indicate True or False for the following Statements.

Adjusting the Black-Scholes Framework in the Presence of a Volatility Skew

9.2 Secant Method, False Position Method, and Ridders Method

Comments on Foreign Effects of Higher U.S. Interest Rates. James D. Hamilton. University of California at San Diego.

Chapter 6 Analyzing Accumulated Change: Integrals in Action

The following content is provided under a Creative Commons license. Your support

Finding Zeros of Single- Variable, Real Func7ons. Gautam Wilkins University of California, San Diego

Chapter 5 Finite Difference Methods. Math6911 W07, HM Zhu

Frequency Distributions

1. f(x) = x2 + x 12 x 2 4 Let s run through the steps.

Falling Cat 2. Falling Cat 3. Falling Cats 5. Falling Cat 4. Acceleration due to Gravity Consider a cat falling from a branch

Factors of 10 = = 2 5 Possible pairs of factors:

Calculus Review with Matlab

Contents Critique 26. portfolio optimization 32

MATH ASSIGNMENT 1 SOLUTIONS

When Is Factoring Used?

Chapter 4 Partial Fractions

Section 5.6 Factoring Strategies

Analysing the IS-MP-PC Model

Entrance Exam Wiskunde A

Recitation 1. Solving Recurrences. 1.1 Announcements. Welcome to 15210!

The Theory of Interest

Penalty Functions. The Premise Quadratic Loss Problems and Solutions

Part 3: Trust-region methods for unconstrained optimization. Nick Gould (RAL)

(Refer Slide Time: 01:17)

Sandringham School Sixth Form. AS Maths. Bridging the gap

Transcription:

CS227-Scientific Computing Lecture 6: Nonlinear Equations

A Financial Problem You invest $100 a month in an interest-bearing account. You make 60 deposits, and one month after the last deposit (5 years after the first deposit) you withdraw the money in the account. You would like to have $ 8000. What must the rate of interest on the account be in order to achieve this?

A Financial Problem Let s solve the problem in general with r : monthly rate of interest d : monthly deposit n : number of periods M : goal

A Financial Problem Account balance after 0 months: d. Account balance after 1 month (before second deposit): (1 + r)d. Account balance after 2 months (before third deposit): (1 + r) 2 d + (1 + r)d. Account balance after n months: d((1 + r) n + (1 + r) n 1 + + (1 + r)) = (geometric series) n 1 d(1 + r) (1 + r) j = j=0 [ (1 + r) n ] 1 d(1 + r). r

A Financial Problem So we have a nonlinear equation; [ (1 + r) n ] 1 d(1 + r) = M. r With our original values for d, n, m, we have to solve the nonlinear equation [ (1 + r) 60 ] 1 (1 + r) 80 = 0. r

Truncation error and rate of convergence of iterative methods The solutions to linear equations and linear systems can be expressed exactly as sums, products and quotients of their coefficients. All the error present in calculating solutions this way is due to roundoff error. In contrast, nonlinear equations usually cannot have their solutions expressed this way. Instead, solution methods typically generate a sequence of approximations that converge to the root. So in addition to the roundoff error, there is also truncation error: If you cut the iterative process off after s steps, how close are you to the correct answer? How fast does the process converge to the root?

A simple idea: Bisection Theorem Intermediate Value Theorem. If f is a continuous function throughout the interval a x b, and f (a) f (b) < 0, then there is some c, with a < c < b, such that f (c) = 0.

Bisection Method So if we start with an interval [a, b] that brackets a root of f, we can split it in two by computing the midpoint c = a+b 2. One of the two subintervals [a, c] or [c, b] will bracket a root, and we can continue subdividing until the width of the bracketing interval is as small as we desire. In the figure below, we go from [a, b] to [a, b ] to [a, b ] to [a, b ] to[a, b ].

Rate of Convergence of Bisection After k steps, we have the root trapped between two numbers that are (b a) 2 k apart, so we get roughly one additional bit of precision for each evaluation of the function f. As long as we start with a pair of numbers that brackets a root, and as long as f is continuous, this is foolproof. Note that we have not discussed how to find brackets (sometimes a plot, or careful thinking about the function itself, can help). There is a risk that the initial interval has more than one root of f. And the rate of convergence is rather slow.

Implementation of Bisection The bisection function posted on the course website shows a robust implementation in MATLAB. Note, first of all, the use of function handles as arguments, as well as the flexibility that allows us to apply this to a function of several variables fixing the values of all but the first variable and solving for the first variable. Since evaluating the function f is likely to be the most time-consuming step, the code is written to make sure that f is evaluated only once in each pass through the while loop. Note also that the function returns a lot of information: The final values of the endpoints of the bracketing interval as well as the values of f at these endpoints. You can of course just call it with a single output argument and get an approximation to the root.

Implementation of Bisection Here is the function bisection applied to our interest rate problem. The depositor is putting in a total of $ 6000. If he earned 33 % interest in the last month, he would get the desired $ 8000 in one period, so we can use 0.33 as an upper bound. We might like to use 0 as a lower bound, but our function is written in a form that is not defined at r = 0, so we need to use a very small positive value let s say 0.001 (one tenth of one percent interest per month, which is surely too small). >> F=@(r,d,n,M)d*(1+r)*((1+r)^n-1)/r-M; >> [x,y,r,s]=bisection(f,0.001,0.33,100,60,8000) x = 0.009072994445666 y = 0.009072994445666 r = -1.809894456528127e-10 s =0.910827217623591e-11 So the answer is about 0.91 % monthly interest, which is close to 11% annual interest.

Newton s Method The pretty idea here is to guess a value that is close to the root, then follow the tangent line at that point until it crosses the x-axis. This should be a closer approximation to the root, and we can iterate the procedure.

Newton s Method Call the initial guess x 0, and the subsequent approximations x 1, x 2, etc. The equation of the tangent line to the graph of f at (x i, f (x i )) is y = f (x i )(x x i ) + f (x i ), so we have or 0 = f (x i )(x i+1 x i ) + f (x i ), x i+1 = x i f (x i) f (x i ).

Example For instance, let us try to find a solution to the 5th degree polynomial equation x 5 + 2x 2 = 0. We begin with a plot, which suggests a starting guess of x 0 = 1.

Example-continued The Newton s method iteration is x i+1 = x i x i 5 + 2x i 2 5xi 4. + 2 Let s try this out: >> G=@(x)x-((x^5+2*x-2)/(5*x^4+2)); >> x=1; >> x=g(x) x = 0.857142857142857 >> x=g(x) x = 0.819484893762504 >> x=g(x) x = 0.817476251723243 >> x=g(x) x = 0.817471019036304 >> x=g(x) x = 0.817471019000967 >> x=g(x) x = 0.817471019000967

Example-continued In successive iterations we get 1, 2, 5, 9 correct decimal digits, and the answer stabilizes after the 5th iterate. So the convergence is very fast.

Rate of convergence of Newton s Method How closely does the tangent line to the graph of f at a approximate f (x) for x close to a? Taylor s Theorem (for degree 2): f (x) = f (a) + f (a)(x a) + f (x a)2 (c) 2 for some c between a and x. So if we take x to be a root of f and a = x i, we get so 0 = f (x i ) + f (x i )(x x i ) + f (c) (x x i ) 2, 2 x i+1 x = f (c) 2f (x i ) x i x 2.

Rate of convergence of Newton s Method Roughly speaking, this means that if ɛ i represents the absolute error at the i th iteration, then ɛ i+1 f (x ) f (x ) ɛ2 i. So, if you start out close enough to x, then number of correct digits roughly doubles at each iteration. (Quadratic convergence.) This is very fast. But there are lots of caveats: If you don t start out close enough to a root, then the iterates may fail to converge altogether. If f (x ) is zero, or close to zero, the convergence may be very slow. Furthermore, the method requires you to know the derivative of f. If the values of f are only tabulated, this may be unavailable. Even if it is available, you have to evaluate both f and f at each iteration, which means that there is extra work to do.

Rapidly convergent methods that do not require the derivative. Secant method: Start out with two guesses x 0 and x 1 that bracket the root. At each subsequent step, set x i+1 to be the point where the line segment joining the points crosses the x-axis. (x i 1, f (x i 1 )), (x i, f (x i ))

Rapidly convergent methods that do not require the derivative When things are working right, the rate of convergence of the secant method is much faster than linear, but not as fast as quadratic. There are some of the same issues as with Newton s method: Poor choices of initial values can get your farther and farther from the root.

Rapidly convergent methods that do not require the derivative The industrial-strength method used in MATLAB combines several strategies. For most rapid convergence it keeps track of the three previous points x i 2, x i 1, x i. It then uses quadratic interpolation to find a parabola through the three points (x i 2, f (x i 2 ), (x i 1, f (x i 1 )), (x i, f (x i ). The catch is, it does this backwards, interchanging the roles of the x- and y-coordinates. So the resulting parabola is oriented with its axis parallel to the x-axis, and thus intersects the x-axis at one point, which is x i+1. This is called inverse quadratic interpolation. In cases where inverse quadratic interpolation won t work (e.g., two of the y-coordinates the same), or the method appears to be wandering further from a root, the algorithm will take a step of the secant method or bisection instead.

fzero The basic syntax is x = fzero(function handle,guess) x = fzero(function handle,left bracket, right bracket)) but as usual, there are many options. For instance, type x=fzero(function handle,guess,optimset( Display, iter )) to get an idea of what fzero is doing.