MA2213 Lecture 9 Nonlinear Systems
Midterm Test Results
Topics Roots of One Nonlinear Equation in One Variable Secant Method pages Roots of Nonlinear Systems (n Equations, n Variables) Newton’s Method pages Calculus Review : Intermediate Value Theorem, Newton’s Method pages Mean Value Theorems for Derivatives and Integrals Applications to Eigenvalue-Eigenvector Calculation Applications to Optimization
Mean Value Theorem for Derivatives Theorem A.4 p. 494 Let There there is at least one point such that
Newton’s Method Newton’s method is based on approximating the graph of y = f(x) with a tangent line and on then using a root of this straight line as an approximation to the root of f(x)
Error of Newton’s Method Newton’s iteration for finding a rootof Mean Value Theorem between the error satisfies and Mean Value Theorem betweenand Question Compare B with estimate in slides 33,34 Lect 1
MATLAB for Newton’s Method MATLAB implementation of formula 3.27 on page 91 Start with one estimate >> x(1)=2; f(1) = x(1)^6-x(1)-1 >> for n = 1:10 S = 6*x(n)^5 – 1; x(n+1) = x(n) – f(n) / S; f(n+1) = x(n+1)^6 – x(n) – 1; end For n = 1:nmax end >> x' ans = Example pages 91-92
Secant Method is based on approximating the graph of y = f(x) with a secant line and on then using a root of this straight line as an approximation to the root of f(x)
Error of Secant Method It can be shown, using methods from calculus that we used to derive error bounds for Newton’s method, that the sequence of estimates computed using the secant method satisfy equation 3.28 on page 92 where is betweenand is between the largest and smallest of The analysis on page 92 and Problem 8 on pages shows, using the growth of the Fibonacci sequence, that and c is a constant
MATLAB for Secant Method MATLAB implementation of formula 3.27 on page 91 Start with two estimates >> x(1)=2; f(1) = x(1)^6-x(1)-1 >> x(2)=1; f(2) = x(2)^6-x(2)-1 >> for n = 1:9 S = (f(n+1)-f(n)) / (x(n+1)-x(n)); x(n+2) = x(n+1) - (x(n+1)^6-x(n+1) - 1) / S; f(n+2) = x(n+2)^6-x(n+2)-1; end For n = 1:nmax end >> x' ans = Example pages 91-92
Applications of Secant Method The secant method is particularly useful for finding roots of a function Example 1. The frequency where of gene (that causes certain moths to be black) in the n-th generation satisfies selection coefficient, so the MATLAB algorithm below hence Newton’s method is useless. that is defined by an algorithm. In this case there may not even exist an algorithm to compute the derivative of >> b(1) = >> s =.33; >> for n = 1:50 b(n+1) = b(n)/(1-s*(1-b(n))^2); end is the defines a function that equals the frequency of genes in the 50 th generation if the frequency in the 1 st generation = and the selection coefficient = s
Applications of Secant Method
Motivation Let us consider two equations in two variables Question What are the graphs of these equations ? Ifis an initial guess (and approximate zero of both f and g) then we may approximate f and g by linear functions
Motivation We can express this in matrix form as where M is the matrix of derivatives defined by If M is invertible then a reasonable next guess is Question Why is this guess reasonable ?
Motivation Example For f, g on slide 13 and Question What should the next guess be ? Question What happed to the residual ?
The General Newton Method We change notation To obtain Newton’s method we let x = current estimate Taylor’s Theorem & Chain Rule Imply and choose the next estimate to be where makes the right side above = 0
The General Newton Method For a general system on n-equations in n-variables
Eigenvalue-Eigenvector Application For then Result If constructby is an eigenvector of a simple eigenvalue is nonsingular. Proof corresponding to a then
MATLAB for Newton Eig-Eig function [v,l] = newt(A,v0,l0,niter) % function [v,l] = newt(A,v0,l0,niter) % % Inputs: % A is a complex 4 x 4 matrix % v0 initial eigenvector estimate % l0 initial eigenvalue estimate % niter = number of iterations % Outputs: % v = eigenvector % l = eigenvalue Id = eye(4); % 4 x 4 identity matrix x = [v0;l0]; % ‘system’ vector v = x(1:4); l = x(5); for k = 1:niter B=A -l*Id; J = [B -v;v' 0]; res = [B*v;.5*v'*v-.5]; x = x - J\res; v = x(1:4); l = x(5); end v = x(1:4); l = x(5); Question In the k-loop what name is given to the derivative matrix ? Question Under what the conditions is res = 0 ?
Computation of Real Eig-Eig >> [A V diag(D)] ans = >> v0 = [ ]' >> l0 = 3 >> niter = 4; >> [v,l] = newt(A,v0,l0,niter); >> v-V(:,3) ans = 1.0e-010 * >> l-D(3,3) ans = e-012
Computation of Complex Eig-Eig >> [A diag(D)] i i >> V i i i i i i
Computation of Complex Eig-Eig >> (v0./V(:,3))/(v0(1)/V(1,3)) i i i >> l0/D(3,3) i >> [v,l] = newt(A,v0,l0,4); >> (v./V(:,3))/(v(1)/V(1,3)) i i i >> l/D(3,3) i
Taylor’s Theorem in Several Variables Taylor’s theorem applied to yields and the chain rule implies that this matrix of second derivatives of G is the Hessian of G at x
Optimization Theorem Ifis continuously differentiable and has a local minimum / local maximum at then is positive / negative definite,and the Hessian Ifis twice continuously differentiable, thenhas a local minimum / local maximum at Proof If G has a local minimum at p, then henceand similarly for a local maximum. Positive / negative definite means> / < 0 whenever hence pos / neg def and implies thereforehas a local minimum / maximum at
Homework Due Lab 5 (Week 12, 5-9 November) 1.Write a MATLAB Program to implement the secant method and use it to (a) do Problem 1 on page 96, (b) do 15 iterations to solve the problem in Example on page 91 and for that example verify that the error satisfies the approximation 3.31 on page 92 and estimate the value of the constant c numerically and compare with the formula at the bottom of page 92. You should study Problem 8 on pages to know how the error estimate is derived and its relationship to the Fibonacci sequence 2. Write a MATLAB program to compute the function f in slide 11 and use it with the program for the secant method (that you wrote for Problem 1) to compute a value of s such that f(s)= 0.7 Suggestion: Start with s(1) =.33 and s(2) = Do problems 1, 2, and 3 on page 364 of the textbook 4. Extra Credit: Write a MATLAB program to compute the position of an airplane from its approximate position and its distance from three GPS satellites. Synthesize some data and test the program.