Math 551 Homework Assignment 3 Page 1 of 6

Similar documents
Numerical Methods Lecture 3

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

CHEE 222: PROCESS DYNAMICS AND NUMERICAL METHODS

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

MA 8019: Numerical Analysis I Solution of Nonlinear Equations

MATH 4211/6211 Optimization Basics of Optimization Problems

Numerical Methods in Informatics

CS 323: Numerical Analysis and Computing

MAE 107 Homework 8 Solutions

CS 323: Numerical Analysis and Computing

Chapter 5 Roots of Equations: Bracketing Models. Gab-Byung Chae

SYSTEMS OF NONLINEAR EQUATIONS

Nonlinearity Root-finding Bisection Fixed Point Iteration Newton s Method Secant Method Conclusion. Nonlinear Systems

Solving Nonlinear Equations

Numerical Methods I Solving Nonlinear Equations

Midterm Review. Igor Yanovsky (Math 151A TA)

FALL 2018 MATH 4211/6211 Optimization Homework 4

Math Introduction to Numerical Methods - Winter 2011 Homework 2 Assigned: Friday, January 14, Due: Thursday, January 27,

MATH 350: Introduction to Computational Mathematics

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

Variable. Peter W. White Fall 2018 / Numerical Analysis. Department of Mathematics Tarleton State University

1.1: The bisection method. September 2017

NON-LINEAR ALGEBRAIC EQUATIONS Lec. 5.1: Nonlinear Equation in Single Variable

MATH 350: Introduction to Computational Mathematics

Numerical solutions of nonlinear systems of equations

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

Math 409/509 (Spring 2011)

Goals for This Lecture:

R x n. 2 R We simplify this algebraically, obtaining 2x n x n 1 x n x n

COURSE Iterative methods for solving linear systems

University of Delaware Department of Mathematical Sciences Math 353 Engineering Mathematics III 06S C. Bacuta

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

MATH 3795 Lecture 12. Numerical Solution of Nonlinear Equations.

Math Numerical Analysis

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

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

Finding the Roots of f(x) = 0

Shiqian Ma, MAT-258A: Numerical Optimization 1. Chapter 3. Gradient Method

Math 471. Numerical methods Root-finding algorithms for nonlinear equations

Numerical Methods. Root Finding

Optimization and Calculus

NEW DERIVATIVE FREE ITERATIVE METHOD FOR SOLVING NON-LINEAR EQUATIONS

ECE 680 Modern Automatic Control. Gradient and Newton s Methods A Review

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

Homework 2 - Solutions MA/CS 375, Fall 2005

2.4 - Convergence of the Newton Method and Modified Newton Method

Numerical Analysis Fall. Roots: Open Methods

Songklanakarin Journal of Science and Technology SJST R1 KANYAMEE. Numerical methods for finding multiplicative inverses of a modulo N

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

Applied Computational Economics Workshop. Part 3: Nonlinear Equations

Chapter 9 Implicit Methods for Linear and Nonlinear Systems of ODEs

CLASS NOTES Computational Methods for Engineering Applications I Spring 2015

Solving nonlinear equations

Numerical Solution of f(x) = 0

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.

Nonlinearity Root-finding Bisection Fixed Point Iteration Newton s Method Secant Method Conclusion. Nonlinear Systems

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

Numerical Methods 5633

ME451 Kinematics and Dynamics of Machine Systems

1 Newton s Method. Suppose we want to solve: x R. At x = x, f (x) can be approximated by:

Chapter 3: Root Finding. September 26, 2005

CHAPTER 10 Zeros of Functions

Halley s Method: A Cubically Converging. Method of Root Approximation

Line Search Methods. Shefali Kulkarni-Thaker

Analysis Methods in Atmospheric and Oceanic Science

Instructor: Marios M. Fyrillas HOMEWORK ASSIGNMENT ON NUMERICAL SOLUTION OF NONLINEAR EQUATIONS

Some MATLAB Programs and Functions. Bisection Method

Extended Introduction to Computer Science CS1001.py. Lecture 8 part A: Finding Zeroes of Real Functions: Newton Raphson Iteration

Analysis Methods in Atmospheric and Oceanic Science

Module 5 : Linear and Quadratic Approximations, Error Estimates, Taylor's Theorem, Newton and Picard Methods

NUMERICAL AND STATISTICAL COMPUTING (MCA-202-CR)

Finding Roots of Equations

Numerical Methods. King Saud University

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

Numerical Methods 5633

Unconstrained minimization of smooth functions

Grégory Antoni. 1. Introduction. 2. A New Numerical Technique (NNT) Combined with Classical Newton s Method (CNM)

17 Solution of Nonlinear Systems

FIXED POINT ITERATIONS

Project 1: ADMI 6807

Numerical Methods in Physics and Astrophysics

Therefore, the root is in the second interval and the lower guess is redefined as x l = The second iteration is

Numerical Methods School of Mechanical Engineering Chung-Ang University

15 Nonlinear Equations and Zero-Finders

CHAPTER 4 ROOTS OF EQUATIONS

Math 471. Numerical methods Introduction

Homework No. 2 Solutions TA: Theo Drivas

Root Finding Convergence Analysis

Model-building and parameter estimation

Numerical Methods in Physics and Astrophysics

An Implicit Multi-Step Diagonal Secant-Type Method for Solving Large-Scale Systems of Nonlinear Equations


2007 Summer College on Plasma Physics

MATLAB Examples 2 (covering Statistics Lectures 3 and 4)

Notes for Numerical Analysis Math 5465 by S. Adjerid Virginia Polytechnic Institute and State University. (A Rough Draft)

MATHEMATICS FOR COMPUTER VISION WEEK 8 OPTIMISATION PART 2. Dr Fabio Cuzzolin MSc in Computer Vision Oxford Brookes University Year

An Efficient Solver for Systems of Nonlinear. Equations with Singular Jacobian. via Diagonal Updating

x 2 x n r n J(x + t(x x ))(x x )dt. For warming-up we start with methods for solving a single equation of one variable.

Bindel, Spring 2016 Numerical Analysis (CS 4220) Notes for

Zeros of Functions. Chapter 10

Transcription:

Math 551 Homework Assignment 3 Page 1 of 6 Name and section: ID number: E-mail: 1. Consider Newton s method for finding + α with α > 0 by finding the positive root of f(x) = x 2 α = 0. Assuming that x 0 > 0, show the following: (a) x k+1 = 1 2 (x k + αxk ). (b) ( ) x x 2 2 2 k+1 α = k α, for k 0 and therefore x k > α for k 1. Solution: (a) Let us apply Newton s method to f(x). In particular, we have that x k+1 = x k f(x k) f (x k ) = x k x2 k α = x2 k + α x k+1 = 1 ) (x k + αxk. 2x x 2 (b) Starting from the left-hand-side (lhs) of part (b) and utilizing the result from part (a), we obtain x 2 k+1 α = 1 4 ( ) x 2 2 = k α. ( x k + α ) 2 α = 1 (x 2k + α2 x k 4 x 2 k ) 2α = 1 4 ( x 2 k α Therefore, if x 2 k α, then ( x 2 k α ) 2 > 0 which implies x 2 k+1 > α, or x k+1 > α for k 0. It then follows that xk > α for k 1. x k ) 2 2. Implement Newton s method in MATLAB. In particular, create a function, which utilizes the method, and store it as an m-file. Then, use your function to estimate 7 by finding the positive root of f(x) = x 2 7. Try two different initial guesses: (i)

Math 551 Homework Assignment 3 Page 2 of 6 x 0 = 2 and (ii) x 0 = 500 and consider x k+1 x k < 10 10 as a convergence criterion. Attach your codes and provide MATLAB output for both cases. Solution: An implementation of Newton s method is given in the following script named as newton.m : function [ x, k, fout ] = newton( func, dfunc, x0, atol, nmax ) On input: a) func: is the nonlinear function f(x). b) dfunc: the derivative of f(x). c) x0 : initial guess. d) atol : absolute tolerance. e) nmax : maximum number of iterations allowed. On output: a) x : is the root of f(x). b) k : number of iterations required to achieve atol. c) fout: Residuals store at each k. xk = rand; Just to start the while loop. res = xk - x0; Compute the absolute error. k = 0; Iteration index. iflag = 0; For stopping purposes. while abs(res)>atol Do-while loop. fxk = feval(func,x0); Compute the residual. fout(k+1) = fxk; Store the residual. dfxk = feval(dfunc,x0); Evaluate the derivative of f(x). xk = x0 - fxk / dfxk; Newton step. res = xk - x0; Compute the "new" absolute error. x0 = xk; Store it. k = k + 1; Increase iteration index. if(k == nmax) Check whether we reached the maximum iflag = -1; number of iterations! break; If yes, then we stop Newton. if(iflag==0) On successful exit, return the root! k = k + 1; fout(k) = feval(func,xk); xout(k) = xk; x = xk; else disp( maximum number of iterations reached! ); x = []; k = [];

Math 551 Homework Assignment 3 Page 3 of 6 Then, the main driver consists of the following code which calls newton.m : func = @(x) x^2-7; dfunc = @(x) 2 * x; x0 = 2; atol = 1e-10; nmax = 100; [ xstar, k, fout ] = newton( func, dfunc, x0, atol, nmax ); and the corresponding MATLAB output for x 0 = 2 is given below: f() 2.000000000000000-3.000000000000000e+00 2.750000000000000 0.562500000000000e+00 2.647727272727273 0.010459710743802e+00 2.645752048380804 3.901511218984410e-06 2.645751311064693 5.435651928564766e-13 2.645751311064591 8.881784197001252e-16 Similarly, for x 0 = 500: f() 5.000000000000000e+02 2.499930000000000e+05 2.500070000000000e+02 6.249650004900000e+04 1.250174996080110e+02 1.562237520823903e+04 6.253674588464200e+01 3.903844585840287e+03 3.132434003735431e+01 9.742142787757983e+02 1.577390421629556e+01 2.418160542248670e+02 8.108837568589735e+00 5.875324671377228e+01 4.486046618789610e+00 1.312461426595369e+01 3.023220284018386e+00 2.139860885700212e+00 2.669316055303705e+00 1.252482031021342e-01 2.645855325943224e+00 5.504058221266206e-04 2.645751313109127e+00 1.081866862762126e-08 2.645751311064591e+00 8.881784197001252e-16 3. For x > 0, consider the equation x + ln x = 0. Implement the secant method and find the root of the above equation. Use x 0 = 0.5, x 1 = 0.6 and x k+1 x k < 10 10 as a convergence criterion. In addition, use your

Math 551 Homework Assignment 3 Page 4 of 6 function from Question 2 employing Newton s method and repeat the calculation with same initial guess x 0 and convergence criterion as before. Finally, attach your code for the secant method and provide MATLAB outputs for both cases. Which method converges faster? Briefly explain. Solution: An implementation of secant s method is given in the following script named as secant.m : function [ x, k, fout ] = secant( func, x0, x1, atol, nmax ) On input: a) func: is the nonlinear function f(x). b) x0 : initial guess. c) x1 : >>. d) atol : absolute tolerance. e) nmax : maximum number of iterations allowed. On output: a) x : is the root of f(x). b) k : number of iterations required to achieve atol. c) fout : residuals stored at each k. k = 0; Iteration index. iflag = 0; For stopping purposes. xk = rand; Just to start the while loop. res = xk - x0; Compute the absolute error. fx0 = feval(func,x0); Evaluate the function at x_{0}. fx1 = feval(func,x1); Evaluate the function at x_{1}. while abs(res)>atol Do-while loop. fout(k+1) = fx0; Store the residual in each step. xk = x1 - fx1 * ( x1 - x0 ) / ( fx1 - fx0 ); Secant method. res = xk - x0; Compute the "new" absolute error. x0 = x1; Substitutions. x1 = xk; >>. fx0 = feval(func,x0); Evaluate the function at x_{0}. fx1 = feval(func,x1); Evaluate the function at x_{1}. k = k + 1; Increase iteration index. if(k == nmax) Check whether we reached the maximum iflag = -1; number of iterations! break; If yes, then we stop secant. if(iflag==0) On successful exit, return the root! fout(k) = feval(func,xk); xout(k) = xk; x = xk;

Math 551 Homework Assignment 3 Page 5 of 6 else disp( maximum number of iterations reached! ); x = []; k = []; Then, the main driver consists of the following code which calls secant.m : func = @(x) x+log(x); x0 = 0.5; x1 = 0.6; atol = 1.e-10; nmax = 100; [ xstar, k, fout ] = secant( func, x0, x1, atol, nmax ); and the corresponding MATLAB output follows: f() 0.500000000000000-0.193147180559945e+00 0.600000000000000 0.089174376234009e+00 0.568413897526397 0.003508464725863e+00 0.567120282313471-6.357732002681971e-05 0.567143306843229 4.540927101004399e-08 0.567143290409997 5.876410469340954e-13 0.567143290409784-1.110223024625157e-16 On the other hand, the MATLAB output using Newton s method follows: f() 0.500000000000000-0.193147180559945e+00 0.564382393519982-0.007640861009083e+00 0.567138987715060-1.188933308848839e-05 0.567143290399369-2.877842408821607e-11 0.567143290409784-1.110223024625157e-16 From the above results it can be discerned that Newton s method converges faster. Note that 7 iterations required for secant method while 5 for Newton s one. 4. Assume that a function f is twice differentiable, that is, f C 2 [a, b] and there is a root x [a, b] such that f(x ) = 0 and f (x ) 0. We saw in class that Newton s method converges quadratically. Prove this is indeed the case. Hint: Let e k = x k x denotes the error in the kth iterate. Do a Taylor expansion about of f(x) about x k and then evaluate it at x k+1. Use this expansion in Newton s algeorithm to compare e k and e k+1. l

Math 551 Homework Assignment 3 Page 6 of 6 Solution: At first, we note that x k = e k + x and, similarly, x k+1 = e k+1 + x. Then, from Newton s method we have that x + e k+1 = x + e k f(x + e k ) f (x + e k ). Next, by Taylor expanding f(x) about x + e k up to second order we arrive at x + e k+1 = x + e k f(x ) + e k f (x ) + 1 2 e2 k f (x ). (1) f (x ) + e k f (x ) However, based on our assumption f (x ) 0 we note that and since f(x ) = 0, Eq. (1) yields to 1 1 + e k f (x )/f (x ) 1 e f (x ) k f (x ), e k+1 = f (x ) 2f (x ) e2 k e k+1 = 1 f (x ) 2 f (x ) e2 k, (2) that is, Newton s method converges quadratically.