1 / 12

Numerical Methods notes by G. Houseman for EARS1160, ENVI2240, CCFD1160

Numerical Methods notes by G. Houseman for EARS1160, ENVI2240, CCFD1160. Lecture 3: Integration. Integration of discrete functions Interpretation of an integral Taylor's series (again!) Mid-point rule Trapezoid rule Romberg's method Simpson's rule. Integration of Discrete Functions.

ghardesty
Télécharger la présentation

Numerical Methods notes by G. Houseman for EARS1160, ENVI2240, CCFD1160

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. Numerical Methodsnotes by G. Housemanfor EARS1160, ENVI2240, CCFD1160 Lecture 3: Integration. • Integration of discrete functions • Interpretation of an integral • Taylor's series (again!) • Mid-point rule • Trapezoid rule • Romberg's method • Simpson's rule

  2. Integration of Discrete Functions Given a function f(x), which could be represented by the discrete function {f(xi)} at the set of sample points {xi}, how do we evaluate the definite integral ? and the indefinite integral ? In the case of a definite integral, the answer is a number and the main question is how to estimate it accurately. For the indefinite integral we are generating a new discrete function, constructed from the function f(x), but each entry of the new function Fj = F(xj) is just a definite integral, with upper limit at point xj.

  3. f(x) Dx a b x Interpretation of an integral The definite integral is interpreted as the area between x = a and x = b, between the lines y = 0 and y = f(x). We can approximate the area by summing up the areas of the set of thin vertical strips between x = xj and x = xj+1.

  4. Taylor's series (again!) The function f(x) in the range is approximated by the Taylor's series about the midpoint xm of the range. Then the integral is computed as the sum of the separate integrals of the terms: Note that the second (and fourth, sixth, etc) term is zero!

  5. Mid-point rule Then provides an estimate of (i) the integral (the first term) and (ii) the error of the estimate (the second term). The error is proportional to (b-a)3 and to the curvature of the function at the midpoint. If we divide the interval into two segments, there will be two error components, but each is reduced in magnitude by a factor of 8 roughly, so the total error decreases by a factor of 4. If we divide the interval into N segments, the discretisation error is reduced by the factor N2. If we use too many segments however, the factor (b-a) becomes very small and round-off error may become large.

  6. Trapezoid Rule If we are using a discrete function, our function is only defined at the points {xj}, j = 1, N, so using midpoints may be inconvenient. We can simply estimate in the mid-point rule, so that only the values at the end points of the interval (or of the sub-intervals) are needed. The error associated with this approximation is obtained from the Taylor's series at x = a and x = b, from which and then

  7. Implementation of the Trapezoid rule The trapezoid rule is simply implemented as a summation of all the segment areas. If the N segment intervals of a discrete function are of equal length Dx, there are 2 end points and N-1 interior points some computational efficiency is gained: Each interior point is added twice, at the right end of one segment and at the left end of the adjacent segment, so the factor of 1/2 cancels at every summation point, except at the two end points.

  8. Romberg's Method: 1 We saw that the error associated with the trapezoid method for a single interval is: If we subdivide the interval into N segments, we see that the error per segment decreases as N -3, and therefore the total error decreases as N -2 (approximate because f"(x) is variable through the interval, and often unknown). Assume that: where K depends on the curvature. Doubling the number of mesh intervals causes the segment length to be halved, so

  9. Romberg's Method: 2 We saw that the error associated with the trapezoid method for a single interval is: From the estimate for N segments and that for 2N segments: and thus we obtain an estimate for the value of the integral that is significantly better than the 2N estimate: but still only approximate because of arbitrary variation of the second derivatives.

  10. Simpson's rule Accuracy of the trapezium method is limited by loss of information about the curvature of the function in between sample points. If we use more points, in order to define the curvature, more accuracy is possible. If we use three regularly spaced points in the discrete function, we can fit a parabola exactly to those points, and the integral of this best-fit parabola is then In principle, this method is 4th order accurate, i.e. the error on each segment integration decreases as N -5. Since there are N segments, the total error therefore decreases as N -4. Exercise: show that the above formula is obtained if you fit a parabola to the 3 points at a, b, and (a+b)/2, and then integrate that parabola.

  11. Simpson's Rule Another way of looking at this is that if we add twice the midpoint rule to the trapezoid rule we see that the leading terms in the error cancel, and we are left with Simpson's rule: Exercise: show that the magnitude of the error term is as given here.

  12. Implementing Simpson's Rule Since Simpson's rule requires 3 point estimates for each segment, we take the interval segments of a discrete function two at a time (requires an even number N of segments): Odd numbered points here contribute to the integral with a weight of 4, compared to even points which contribute with a weight of 2 (1 from each neighbouring segment). This formula can give accurate results for the definite integral if the function is well behaved, but its application in the computation of the indefinite integral is not straightforward because of the requirement that segments be taken 2 at a time.

More Related