1 / 53

MA/CS 375

MA/CS 375. Fall 2002 Lecture 31. Root Finding. Given a real valued function f of one variable (say x), the idea is to find an x such that: f(x) = 0. Newton’s Method cont. Repeat the formula to create an algorithm:

Download Presentation

MA/CS 375

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MA/CS 375 Fall 2002 Lecture 31 MA/CS 375 Fall 2002

  2. Root Finding • Given a real valued function f of one variable (say x), the idea is to find an x such that: f(x) = 0 MA/CS 375 Fall 2002

  3. Newton’s Method cont. • Repeat the formula to create an algorithm: • If at each step the linear model is a good approximation to f then xn should get closer to a root of f as n increases. MA/CS 375 Fall 2002

  4. Newton in Matlab MA/CS 375 Fall 2002

  5. Newton’s Method Without Knowing the Derivative • Recall: we can approximate the derivative to a function with: MA/CS 375 Fall 2002

  6. Modification MA/CS 375 Fall 2002

  7. Team Exercise • 10 minutes • Modify your script to use the approximate derivative (note you will require an extra parameter delta) • Test it with some function you do not know the derivative of. MA/CS 375 Fall 2002

  8. Convergence Rate For Newton’s Method • Theorem 8 (van Loan p 285) • Suppose f(x) and f’(x) are defined on an interval where and positive constants rho and delta exist such that • If xc is in I, then is in I and • That is x+ is at least half the distance to x* that xc was.Also, the rate of convergence is quadratic. MA/CS 375 Fall 2002

  9. Convergence Rate of Newton’s Method cont • The proof of this theorem works by using the fundamental theorem of calculus. • All of the restrictions are important – and can be fairly easily broken by a general function • The restrictions amount to: • f’ does not change sign in a neighbourhood of the root x* • f is not too non-linear (Lipschitz condition) • the Newton’s iteration starts close enough to the root x* then convergence is guaranteed and the convergence rate is quadratic. MA/CS 375 Fall 2002

  10. Finding A Root Of A Two-dimensional Function of Two Variables • Suppose: • Specifically: MA/CS 375 Fall 2002

  11. Finding A Root Of A Two-dimensional Function of Two Variables • Suppose: • Specifically: • We can construct a Taylor series: MA/CS 375 Fall 2002

  12. Constructing A Newton Scheme Create a sequence by using this linear approximation to update from (xn,yn) to (xn+1,yn+1) MA/CS 375 Fall 2002

  13. Constructing A Newton Scheme We figure that if the linear approximationis good then the f(xn+1,yn+1) and g(xn+1,yn+1)should be small MA/CS 375 Fall 2002

  14. Two-dimensional Newton Method MA/CS 375 Fall 2002

  15. Jacobian Matrix MA/CS 375 Fall 2002

  16. Jacobian Matrix MA/CS 375 Fall 2002

  17. Team Exercise (Part 1) • Code up the two-dimensional Newton solver. • Use the approximation for small delta: • Use it to find x,y such that: MA/CS 375 Fall 2002

  18. Team Exercise (Part 2) • Generalize your Newton Solver to solve: • Construct a 3-vector function and find its roots. • Plot the position of (xn,yn,zn) using sphere MA/CS 375 Fall 2002

  19. Problems with Multi-D Newton • The method relies on inverting the Jacobian matrix. • Recall that matrix inversion is strongly dependent on the condition number of the matrix. • Clearly, if the root is near a region where the gradient is small then we will run into slow convergence when the search nears the root. MA/CS 375 Fall 2002

  20. Team Exercise:Dodgy Convergence • Try to find the (0,0) root of • Compare the rate of convergence for the (0,0) root of: • For each iteration plot the condition number of the Jacobian matrix. Try several different starting positions. MA/CS 375 Fall 2002

  21. Roots of a Polynomial • Suppose we wish to find all the roots of a polynomial of order P • Then there are going to be at most P roots!. • We can use a variant of Newton’s method. MA/CS 375 Fall 2002

  22. Roots of a Polynomial cont. • Suppose we have an initial guess for one of the roots of the polynomial function f • Then we can use Newton’s method, starting at this guess to solve for f(x)=0 • Once we have found the first root x1 we apply polynomial deflation to remove this root and then repeat the process to find the next root. MA/CS 375 Fall 2002

  23. Algorithm 1) We are seeking the roots x1,x2,..xP of a polynomial f 2) We find x1 using Newton’s method. 3) We then use Newton’s method to find the next root of f(x)/(x-x1) 4) Then we find x3 as a root of f(x)/((x-x1)(x-x2)) 5) Repeat until all roots found MA/CS 375 Fall 2002

  24. Details of Newton’s Algorithm • At the k’th step, we need to find a root of For Newton’s we need: MA/CS 375 Fall 2002

  25. Product rule for differentiation MA/CS 375 Fall 2002

  26. MA/CS 375 Fall 2002

  27. Newton Scheme For Multiple Root Finding MA/CS 375 Fall 2002

  28. Multiple Root Finder(applied to find roots of Legendre polynomials) MA/CS 375 Fall 2002

  29. Recall: recurrence relation of Legendre polynomials MA/CS 375 Fall 2002

  30. Recall: Recurrence Relation for Gradient of Legendre Polynomials MA/CS 375 Fall 2002

  31. Roots of the 10th Order Legendre Polynomial Notice how they cluster at the end points MA/CS 375 Fall 2002

  32. Numerical Quadrature • A numerical quadrature is a set of two vectors. • The first vector is a list of x-coordinates for nodes where a function is to be evaluated. • The second vector is a set of integration weights, used to calculate the integral of a function which is given at the nodes MA/CS 375 Fall 2002

  33. Example of Quadrature • Say we wish to calculate an approximation to the integral of f over [-1,1] : • Suppose we know the value of f at a set of N points then we would like to find a set of weights w1,w2,..,wN so that: MA/CS 375 Fall 2002

  34. Newton-Cotes Formula • The first approach we are going to use is the well known Newton-Cotes quadrature. • Suppose we are given a set of points x1,x2,..,xN. Then we require that the constant is exactly integrated: MA/CS 375 Fall 2002

  35. Now we require that 1,x,x2,..,xN-1are integrated exactly MA/CS 375 Fall 2002

  36. In Matrix Notation: Notice anything familiar? MA/CS 375 Fall 2002

  37. It’s the transpose of the Vandermonde matrix  MA/CS 375 Fall 2002

  38. Integration by Interpolation • In essence this approach uses the unique (N-1)’th order interpolating polynomial If and integrates the area under the If instead of the area under f • Clearly, we can estimate the approximation error using the estimates for the error in the interpolation we used before. MA/CS 375 Fall 2002

  39. Newton-Cotes Weights MA/CS 375 Fall 2002

  40. Using Newton-Cotes Weights MA/CS 375 Fall 2002

  41. Using Newton-Cotes Weights(Interpretation) i.e. we calculate the coefficients of the interpolating polynomial expansion using the Vandermonde, then since we know the integral of each term we can sum up the integral of each term to get the total. MA/CS 375 Fall 2002

  42. Matlab Function for Calculating Newton-Cotes Weights MA/CS 375 Fall 2002

  43. Demo: Matlab Function for Calculating Newton-Cotes Weights • set N=5 points • build equispaced nodes • calculate NC weights • evaluate F=X^3 at nodes • evaluate integral • F is anti-symmetric on [-1,1] so its integral is 0 • Answer correct  MA/CS 375 Fall 2002

  44. Team Exercise • Get the directory Lecture19m from the cd-rom • make sure your matlab path points to the copy of this directory • using a script figure out what order polynomial the weights can exactly integrate for a given set of N points (say N=6). MA/CS 375 Fall 2002

  45. Gauss Quadrature • The construction of the Newton-Cotes weights does not utilize the ability to choose the distribution of nodes for greater accuracy. • We can in fact choose the set of nodes to increase the order of polynomial that can be integrated exactly using just N points. MA/CS 375 Fall 2002

  46. Suppose: MA/CS 375 Fall 2002

  47. Remainder term, whichmust have p roots locatedat the interpolating nodes Suppose: MA/CS 375 Fall 2002

  48. At this point we can choose the nodes {xi}. If we choose them so that they are the p+1 roots of the (p+1)’th order Legendre function then s(x) is in fact the N=(p+1)’th order Legendre function itself!. MA/CS 375 Fall 2002

  49. But we also know that if r is a lower order polynomial than (p+1)’th order, it can be expressedas a linear combination of Legendre polynomialsand is in fact orthogonal to Lp+1 MA/CS 375 Fall 2002

  50. Hence: i.e. the quadrature is exact for all polynomials of order up to p=(2N-1) MA/CS 375 Fall 2002

More Related