Presentation is loading. Please wait.

Presentation is loading. Please wait.

MA/CS 375 Fall 20021 MA/CS 375 Fall 2002 Lecture 32.

Similar presentations


Presentation on theme: "MA/CS 375 Fall 20021 MA/CS 375 Fall 2002 Lecture 32."— Presentation transcript:

1 MA/CS 375 Fall 20021 MA/CS 375 Fall 2002 Lecture 32

2 MA/CS 375 Fall 20022 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. Review

3 MA/CS 375 Fall 20023 Newton Scheme For Multiple Root Finding Review

4 MA/CS 375 Fall 20024 Multiple Root Finder (applied to find roots of Legendre polynomials) Should read abs(delta) > tol Review + Correction

5 MA/CS 375 Fall 20025 Legendre Polynomials Legendre polynomials are a special set of polynomials which are orthogonal in the L2 inner product: Review

6 MA/CS 375 Fall 20026 Legendre Polynomials Legendre polynomials can be calculate using the following recursion relation: Review

7 MA/CS 375 Fall 20027 Roots of the 10 th Order Legendre Polynomial Notice how they cluster at the end points Review

8 MA/CS 375 Fall 20028 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

9 MA/CS 375 Fall 20029 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 w 1,w 2,..,w N so that:

10 MA/CS 375 Fall 200210 Example: Simpson’s Rule Recall: The idea is to sample a function at N points. Then using a shifting stencil of 3 points construct a quadratic interpolant through those 3 points. Then integrate the area under the interpolant in the range bracketed by the three points. Sum up all the contributions from the sets of three points.

11 MA/CS 375 Fall 200211 Example: Simpson’s Rule quadrature:

12 MA/CS 375 Fall 200212 Example: Simpson’s Rule becomes: in summation notation:

13 MA/CS 375 Fall 200213 Newton-Cotes Formula The next approach we are going to use is the well known Newton-Cotes quadrature. Suppose we are given a set of points x 1,x 2,..,x N. Then we require that the constant is exactly integrated:

14 MA/CS 375 Fall 200214 Now we require that 1,x,x 2,..,x N-1 are integrated exactly

15 MA/CS 375 Fall 200215 In Matrix Notation: Notice anything familiar?

16 MA/CS 375 Fall 200216 It’s the transpose of the Vandermonde matrix

17 MA/CS 375 Fall 200217 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.

18 MA/CS 375 Fall 200218 Newton-Cotes Weights

19 MA/CS 375 Fall 200219 Using Newton-Cotes Weights

20 MA/CS 375 Fall 200220 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.

21 MA/CS 375 Fall 200221 Matlab Function for Calculating Newton-Cotes Weights

22 MA/CS 375 Fall 200222 Demo: Matlab Function for Calculating Newton-Cotes Weights 1)set N=5 points 2)build equispaced nodes 3)calculate NC weights 4)evaluate F=X^3 at nodes 5)evaluate integral 6)F is anti-symmetric on [-1,1] so its integral is 0 7)Answer correct

23 MA/CS 375 Fall 200223 Individual Exercise Download the contents of: http://www.math.unm.edu/~timwar/MA375F02/Integration make sure your matlab path points to your copy of this directory using a script figure out what order polynomial the weights produced with newtoncotes can exactly integrate for a given set of N points (say N=3,4,5,6,7,8) created with linspace

24 MA/CS 375 Fall 200224 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.

25 MA/CS 375 Fall 200225 Suppose:

26 MA/CS 375 Fall 200226 Suppose: Remainder term, which must have p roots located at the interpolating nodes

27 MA/CS 375 Fall 200227 At this point we can choose the nodes {x i }. 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!. Let’s integrate this formula for f over [-1,1]

28 MA/CS 375 Fall 200228 But we also know that if r is a lower order polynomial than (p+1)’th order, it can be expressed as a linear combination of Legendre polynomials {L 1, L 2, L 3, …, L N }. By the orthogonality of the Legendre polynomials we know that the s is in fact orthogonal to L p+1

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

30 MA/CS 375 Fall 200230 Summary of Gauss Quadrature We can use the multiple root finder to locate the roots of the N’th order Legendre polynomial. We can then use the Newton-Cotes formula with the roots of the N’th order Legendre polynomial to calculate a set of N weights. We now have a quadrature !!! which will integrate polynomials of order 2N-1 with N points

31 MA/CS 375 Fall 200231 Team Exercise Use the root finder (gaussNR) and Newton-Cotes routines (newtoncotes) to build a quadrature for N points (N arbitrary). Use it to integrate exp(x) over the interval [-1,1] Use it to integrate 1./(1+25*x.^2) over the interval [-1,1] For N=2,3,4,5,6,7,8,9 plot the integration error for both functions on the same graph.


Download ppt "MA/CS 375 Fall 20021 MA/CS 375 Fall 2002 Lecture 32."

Similar presentations


Ads by Google