Numerical Methods I Solving Nonlinear Equations

Similar documents
Scientific Computing: Optimization

Lecture Notes to Accompany. Scientific Computing An Introductory Survey. by Michael T. Heath. Chapter 5. Nonlinear Equations

Scientific Computing: An Introductory Survey

Numerical Methods I Non-Square and Sparse Linear Systems

Outline. Scientific Computing: An Introductory Survey. Nonlinear Equations. Nonlinear Equations. Examples: Nonlinear Equations

CS 450 Numerical Analysis. Chapter 5: Nonlinear Equations

Numerical Methods I Eigenvalue Problems

Numerical Methods in Informatics

1. Method 1: bisection. The bisection methods starts from two points a 0 and b 0 such that

THE SECANT METHOD. q(x) = a 0 + a 1 x. with

MATH 3795 Lecture 13. Numerical Solution of Nonlinear Equations in R N.

Numerical solutions of nonlinear systems of equations

Numerical Solution of f(x) = 0

CLASS NOTES Models, Algorithms and Data: Introduction to computing 2018

Queens College, CUNY, Department of Computer Science Numerical Methods CSCI 361 / 761 Spring 2018 Instructor: Dr. Sateesh Mane.

Scientific Computing: Numerical Integration

MATH 350: Introduction to Computational Mathematics

University of Houston, Department of Mathematics Numerical Analysis, Fall 2005

Simple Iteration, cont d

MATH 350: Introduction to Computational Mathematics

Motivation: We have already seen an example of a system of nonlinear equations when we studied Gaussian integration (p.8 of integration notes)

Finding the Roots of f(x) = 0. Gerald W. Recktenwald Department of Mechanical Engineering Portland State University

Finding the Roots of f(x) = 0

STOP, a i+ 1 is the desired root. )f(a i) > 0. Else If f(a i+ 1. Set a i+1 = a i+ 1 and b i+1 = b Else Set a i+1 = a i and b i+1 = a i+ 1

Numerical Methods I Solving Square Linear Systems: GEM and LU factorization

Numerical Methods in Physics and Astrophysics

Lecture 7 Unconstrained nonlinear programming

Nonlinear Programming

E5295/5B5749 Convex optimization with engineering applications. Lecture 8. Smooth convex unconstrained and equality-constrained minimization

Scientific Computing: An Introductory Survey

Scientific Computing: An Introductory Survey

Non-polynomial Least-squares fitting

MATH 3795 Lecture 12. Numerical Solution of Nonlinear Equations.

EAD 115. Numerical Solution of Engineering and Scientific Problems. David M. Rocke Department of Applied Science

Lecture 5. September 4, 2018 Math/CS 471: Introduction to Scientific Computing University of New Mexico

Chapter 3: Root Finding. September 26, 2005

Math 411 Preliminaries

Numerical Methods in Physics and Astrophysics

Midterm Review. Igor Yanovsky (Math 151A TA)

Outline. Math Numerical Analysis. Intermediate Value Theorem. Lecture Notes Zeros and Roots. Joseph M. Mahaffy,

Math Numerical Analysis

Scientific Computing: Solving Linear Systems

Applied Mathematics 205. Unit I: Data Fitting. Lecturer: Dr. David Knezevic

Optimization. Escuela de Ingeniería Informática de Oviedo. (Dpto. de Matemáticas-UniOvi) Numerical Computation Optimization 1 / 30

ROOT FINDING REVIEW MICHELLE FENG

Outline. Scientific Computing: An Introductory Survey. Optimization. Optimization Problems. Examples: Optimization Problems

Nonlinear Equations and Continuous Optimization

CS 323: Numerical Analysis and Computing

Applied Computational Economics Workshop. Part 3: Nonlinear Equations

, b = 0. (2) 1 2 The eigenvectors of A corresponding to the eigenvalues λ 1 = 1, λ 2 = 3 are

Lecture 8. Root finding II

Numerical Analysis Fall. Roots: Open Methods

17 Solution of Nonlinear Systems

CLASS NOTES Computational Methods for Engineering Applications I Spring 2015

Numerical Methods I Singular Value Decomposition

MA 8019: Numerical Analysis I Solution of Nonlinear Equations

1. Nonlinear Equations. This lecture note excerpted parts from Michael Heath and Max Gunzburger. f(x) = 0

5 Handling Constraints

PART I Lecture Notes on Numerical Solution of Root Finding Problems MATH 435

Chapter 1. Root Finding Methods. 1.1 Bisection method

CS 323: Numerical Analysis and Computing

Finite Elements for Nonlinear Problems

Goals for This Lecture:

Zero-Order Methods for the Optimization of Noisy Functions. Jorge Nocedal

EAD 115. Numerical Solution of Engineering and Scientific Problems. David M. Rocke Department of Applied Science

Lecture 8 Optimization

Scientific Computing: Dense Linear Systems

Bindel, Fall 2011 Intro to Scientific Computing (CS 3220) Week 6: Monday, Mar 7. e k+1 = 1 f (ξ k ) 2 f (x k ) e2 k.

PHYS 410/555 Computational Physics Solution of Non Linear Equations (a.k.a. Root Finding) (Reference Numerical Recipes, 9.0, 9.1, 9.

Notes for CS542G (Iterative Solvers for Linear Systems)

Chapter 4. Solution of Non-linear Equation. Module No. 1. Newton s Method to Solve Transcendental Equation

Review for Exam 2 Ben Wang and Mark Styczynski

CS 542G: Robustifying Newton, Constraints, Nonlinear Least Squares

Math 409/509 (Spring 2011)

Lecture 7: Minimization or maximization of functions (Recipes Chapter 10)

Chapter 3 Numerical Methods

INTRODUCTION, FOUNDATIONS

SOLVING EQUATIONS OF ONE VARIABLE

Lecture 5: Random numbers and Monte Carlo (Numerical Recipes, Chapter 7) Motivations for generating random numbers

Matrix Derivatives and Descent Optimization Methods

Solution of Algebric & Transcendental Equations

Introduction to Nonlinear Optimization Paul J. Atzberger

CHAPTER 10 Zeros of Functions

INTRODUCTION TO NUMERICAL ANALYSIS

Chapter 6: Derivative-Based. optimization 1

Math and Numerical Methods Review

Line Search Methods. Shefali Kulkarni-Thaker

The Plan. Initial value problems (ivps) for ordinary differential equations (odes) Review of basic methods You are here: Hamiltonian systems

FALL 2018 MATH 4211/6211 Optimization Homework 4

Solving nonlinear equations (See online notes and lecture notes for full details) 1.3: Newton s Method

An Introduction to Algebraic Multigrid (AMG) Algorithms Derrick Cerwinsky and Craig C. Douglas 1/84

Iterative Methods for Solving A x = b

Optimization 2. CS5240 Theoretical Foundations in Multimedia. Leow Wee Kheng

Optimization and Root Finding. Kurt Hornik

1 Lecture 8: Interpolating polynomials.

Lecture 8: Optimization

The Steepest Descent Algorithm for Unconstrained Optimization

Iterative solvers for linear equations

MATH 4211/6211 Optimization Basics of Optimization Problems

Linear Solvers. Andrew Hazel

Transcription:

Numerical Methods I Solving Nonlinear Equations Aleksandar Donev Courant Institute, NYU 1 donev@courant.nyu.edu 1 MATH-GA 2011.003 / CSCI-GA 2945.003, Fall 2014 October 16th, 2014 A. Donev (Courant Institute) Lecture VI 10/2014 1 / 24

Outline 1 Basics of Nonlinear Solvers 2 One Dimensional Root Finding 3 Systems of Non-Linear Equations A. Donev (Courant Institute) Lecture VI 10/2014 2 / 24

Fundamentals Basics of Nonlinear Solvers Simplest problem: Root finding in one dimension: f (x) = 0 with x [a, b] Or more generally, solving a square system of nonlinear equations f(x) = 0 f i (x 1, x 2,..., x n ) = 0 for i = 1,..., n. There can be no closed-form answer, so just as for eigenvalues, we need iterative methods. Most generally, starting from m 1 initial guesses x 0, x 1,..., x m, iterate: x k+1 = φ(x k, x k 1,..., x k m ). A. Donev (Courant Institute) Lecture VI 10/2014 3 / 24

Basics of Nonlinear Solvers Order of convergence Consider one dimensional root finding and let the actual root be α, f (α) = 0. A sequence of iterates x k that converges to α has order of convergence p > 1 if as k x k+1 α e k+1 x k α p = e k p C = const, where the constant 0 < C < 1 is the convergence factor. A method should at least converge linearly, that is, the error should at least be reduced by a constant factor every iteration, for example, the number of accurate digits increases by 1 every iteration. A good method for root finding coverges quadratically, that is, the number of accurate digits doubles every iteration! A. Donev (Courant Institute) Lecture VI 10/2014 4 / 24

Basics of Nonlinear Solvers Local vs. global convergence A good initial guess is extremely important in nonlinear solvers! Assume we are looking for a unique root a α b starting with an initial guess a x 0 b. A method has local convergence if it converges to a given root α for any initial guess that is sufficiently close to α (in the neighborhood of a root). A method has global convergence if it converges to the root for any initial guess. General rule: Global convergence requires a slower (careful) method but is safer. It is best to combine a global method to first find a good initial guess close to α and then use a faster local method. A. Donev (Courant Institute) Lecture VI 10/2014 5 / 24

Basics of Nonlinear Solvers Conditioning of root finding f (α + δα) f (α) + f (α)δα = δf δα δf f (α) κ abs = f (α) 1. The problem of finding a simple root is well-conditioned when f (α) is far from zero. Finding roots with multiplicity m > 1 is ill-conditioned: f (α) = = f (m 1) (α) = 0 δα [ δf ] 1/m f m (α) Note that finding roots of algebraic equations (polynomials) is a separate subject of its own that we skip. A. Donev (Courant Institute) Lecture VI 10/2014 6 / 24

One Dimensional Root Finding The bisection and Newton algorithms A. Donev (Courant Institute) Lecture VI 10/2014 7 / 24

Bisection One Dimensional Root Finding First step is to locate a root by searching for a sign change, i.e., finding a 0 and b 0 such that f (a 0 )f (b 0 ) < 0. The simply bisect the interval, for k = 0, 1,... x k = ak + b k 2 and choose the half in which the function changes sign, i.e., either a k+1 = x k, b k+1 = b k or b k+1 = x k, a k+1 = a k so that f (a k+1 )f (b k+1 ) < 0. Observe that each step we need one function evaluation, f (x k ), but only the sign matters. The convergence is essentially linear because x k α bk 2 k+1 x k+1 α x k α 2. A. Donev (Courant Institute) Lecture VI 10/2014 8 / 24

One Dimensional Root Finding Newton s Method Bisection is a slow but sure method. It uses no information about the value of the function or its derivatives. Better convergence, of order p = (1 + 5)/2 1.63 (the golden ratio), can be achieved by using the value of the function at two points, as in the secant method. Achieving second-order convergence requires also evaluating the function derivative. Linearize the function around the current guess using Taylor series: f (x k+1 ) f (x k ) + (x k+1 x k )f (x k ) = 0 x k+1 = x k f (xk ) f (x k ) A. Donev (Courant Institute) Lecture VI 10/2014 9 / 24

One Dimensional Root Finding Convergence of Newton s method Taylor series with remainder: f (α) = 0 = f (x k )+(α x k )f (x k )+ 1 2 (α xk ) 2 f (ξ) = 0, for some ξ [x n, α] After dividing by f (x k ) 0 we get [ x k f ] (xk ) f (x k α = 1 ) 2 (α xk ) 2 f (ξ) f (x k ) x k+1 α = e k+1 = 1 2 ( e k ) 2 f (ξ) f (x k ) which shows second-order convergence x k+1 α x k α 2 = e k+1 e k 2 = f (ξ) 2f (x k ) f (α) 2f (α) A. Donev (Courant Institute) Lecture VI 10/2014 10 / 24

One Dimensional Root Finding Proof of Local Convergence x k+1 α x k α 2 = f (ξ) 2f (x k ) M f (α) 2f (α) e k+1 = x k+1 α M x k α 2 = ( M e k ) e k which will converge, e k+1 < e k, if M e k < 1. This will be true for all k > 0 if e 0 < M 1, leading us to conclude that Newton s method thus always converges quadratically if we start sufficiently close to a simple root, more precisely, if x 0 α = e 0 < M 1 2f (α) f (α). A. Donev (Courant Institute) Lecture VI 10/2014 11 / 24

One Dimensional Root Finding Fixed-Point Iteration Another way to devise iterative root finding is to rewrite f (x) in an equivalent form x = φ(x) Then we can use fixed-point iteration x k+1 = φ(x k ) whose fixed point (limit), if it converges, is x α. For example, recall from first lecture solving x 2 = c via the Babylonian method for square roots x n+1 = φ(x n ) = 1 2 ( c x + x ), which converges (quadratically) for any non-zero initial guess. A. Donev (Courant Institute) Lecture VI 10/2014 12 / 24

One Dimensional Root Finding Convergence theory It can be proven that the fixed-point iteration x k+1 = φ(x k ) converges if φ(x) is a contraction mapping: φ (x) K < 1 x [a, b] x k+1 α = φ(x k ) φ(α) = φ (ξ) ( x k α ) by the mean value theorem x k+1 α < K x k α If φ (α) 0 near the root we have linear convergence x k+1 α x k φ (α). α If φ (α) = 0 we have second-order convergence if φ (α) 0, etc. A. Donev (Courant Institute) Lecture VI 10/2014 13 / 24

One Dimensional Root Finding Applications of general convergence theory Think of Newton s method x k+1 = x k f (xk ) f (x k ) as a fixed-point iteration method x k+1 = φ(x k ) with iteration function: φ(x) = x f (x) f (x). We can directly show quadratic convergence because (also see homework) φ (x) = f (x)f (x) [f (x)] 2 φ (α) = 0 φ (α) = f (α) f (α) 0 A. Donev (Courant Institute) Lecture VI 10/2014 14 / 24

One Dimensional Root Finding Stopping Criteria A good library function for root finding has to implement careful termination criteria. An obvious option is to terminate when the residual becomes small f (x k ) < ε, which is only good for very well-conditioned problems, f (α) 1. Another option is to terminate when the increment becomes small x k+1 x k < ε. For fixed-point iteration x k+1 x k = e k+1 e k [ 1 φ (α) ] e k e k so we see that the increment test works for rapidly converging iterations (φ (α) 1). ε [1 φ (α)], A. Donev (Courant Institute) Lecture VI 10/2014 15 / 24

In practice One Dimensional Root Finding A robust but fast algorithm for root finding would combine bisection with Newton s method. Specifically, a method like Newton s that can easily take huge steps in the wrong direction and lead far from the current point must be safeguarded by a method that ensures one does not leave the search interval and that the zero is not missed. Once x k is close to α, the safeguard will not be used and quadratic or faster convergence will be achieved. Newton s method requires first-order derivatives so often other methods are preferred that require function evaluation only. Matlab s function fzero combines bisection, secant and inverse quadratic interpolation and is fail-safe. A. Donev (Courant Institute) Lecture VI 10/2014 16 / 24

One Dimensional Root Finding Find zeros of a sin(x) + b exp( x 2 /2) in MATLAB % f=@ m f i l e u s e s a f u n c t i o n i n an m f i l e % P a r a m e t e r i z e d f u n c t i o n s a r e c r e a t e d with : a = 1 ; b = 2 ; f = @( x ) a s i n ( x ) + b exp( x ˆ2/2) ; % Handle f i g u r e ( 1 ) e z p l o t ( f, [ 5, 5 ] ) ; g r i d x1=f z e r o ( f, [ 2,0]) [ x2, f 2 ]= f zero ( f, 2. 0 ) x1 = 1. 227430849357917 x2 = 3.155366415494801 f 2 = 2. 116362640691705 e 16 A. Donev (Courant Institute) Lecture VI 10/2014 17 / 24

One Dimensional Root Finding Figure of f (x) 2.5 a sin(x)+b exp( x 2 /2) 2 1.5 1 0.5 0 0.5 1 5 4 3 2 1 0 1 2 3 4 5 x A. Donev (Courant Institute) Lecture VI 10/2014 18 / 24

Systems of Non-Linear Equations Multi-Variable Taylor Expansion We are after solving a square system of nonlinear equations for some variables x: f(x) = 0 f i (x 1, x 2,..., x n ) = 0 for i = 1,..., n. It is convenient to focus on one of the equations, i.e., consider a scalar function f (x). The usual Taylor series is replaced by f (x + x) = f (x) + g T ( x) + 1 2 ( x)t H ( x) where the gradient vector is [ f g = x f =, f,, f ] T x 1 x 2 x n and the Hessian matrix is { H = 2 2 } f xf = x i x j A. Donev (Courant Institute) Lecture VI 10/2014 19 / 24 ij

Systems of Non-Linear Equations Newton s Method for Systems of Equations It is much harder if not impossible to do globally convergent methods like bisection in higher dimensions! A good initial guess is therefore a must when solving systems, and Newton s method can be used to refine the guess. The first-order Taylor series is f ( x k + x ) f ( x k) + [ J ( x k)] x = 0 where the Jacobian J has the gradients of f i (x) as rows: [J (x)] ij = f i x j So taking a Newton step requires solving a linear system: [ J ( x k )] x = f ( x k) but denote J J ( x k) x k+1 = x k + x = x k J 1 f ( x k). A. Donev (Courant Institute) Lecture VI 10/2014 20 / 24

Systems of Non-Linear Equations Convergence of Newton s method Newton s method converges quadratically if started sufficiently close to a root x at which the Jacobian is not singular. x k+1 x = e k+1 = x k J 1 f ( x k) x = e k J 1 f ( x k) but using second-order Taylor series J 1 { f ( x k)} { J 1 f (x ) + Je k + 1 ( e k ) T ( H e k )} 2 e k+1 = = e k + J 1 2 J 1 2 ( e k ) T H ( e k ) ( e k ) T H ( e k ) J 1 H e k 2 2 A. Donev (Courant Institute) Lecture VI 10/2014 21 / 24

Systems of Non-Linear Equations Problems with Newton s method Newton s method requires solving many linear systems, which can become complicated when there are many variables. It also requires computing a whole matrix of derivatives, which can be expensive or hard to do (differentiation by hand?) Newton s method converges fast if the Jacobian J (x ) is well-conditioned, otherwise it can blow up. For large systems one can use so called quasi-newton methods: Approximate the Jacobian with another matrix J and solve J x = f(x k ). Damp the step by a step length α k 1, x k+1 = x k + α k x. Update J by a simple update, e.g., a rank-1 update (recall homework 2). A. Donev (Courant Institute) Lecture VI 10/2014 22 / 24

In practice Systems of Non-Linear Equations It is much harder to construct general robust solvers in higher dimensions and some problem-specific knowledge is required. There is no built-in function for solving nonlinear systems in MATLAB, but the Optimization Toolbox has fsolve. In many practical situations there is some continuity of the problem so that a previous solution can be used as an initial guess. For example, implicit methods for differential equations have a time-dependent Jacobian J(t) and in many cases the solution x(t) evolves smootly in time. For large problems specialized sparse-matrix solvers need to be used. In many cases derivatives are not provided but there are some techniques for automatic differentiation. A. Donev (Courant Institute) Lecture VI 10/2014 23 / 24

Systems of Non-Linear Equations Conclusions/Summary Root finding is well-conditioned for simple roots (unit multiplicity), ill-conditioned otherwise. Methods for solving nonlinear equations are always iterative and the order of convergence matters: second order is usually good enough. A good method uses a higher-order unsafe method such as Newton method near the root, but safeguards it with something like the bisection method. Newton s method is second-order but requires derivative/jacobian evaluation. In higher dimensions having a good initial guess for Newton s method becomes very important. Quasi-Newton methods can aleviate the complexity of solving the Jacobian linear system. A. Donev (Courant Institute) Lecture VI 10/2014 24 / 24