Automatic Integration

Slides:



Advertisements
Similar presentations
Numerical Integration
Advertisements

1 Chapter 5 Numerical Integration. 2 A Review of the Definite Integral.
Mathematics1 Mathematics 1 Applied Informatics Štefan BEREŽNÝ.
Asymptotic error expansion Example 1: Numerical differentiation –Truncation error via Taylor expansion.
Numerical Integration of Functions
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Today’s class Romberg integration Gauss quadrature Numerical Methods
Numerical Integration
Newton-Cotes Integration Formula
Lecture 3: Integration. Integration of discrete functions
Numerical Integration
8 TECHNIQUES OF INTEGRATION. There are two situations in which it is impossible to find the exact value of a definite integral. TECHNIQUES OF INTEGRATION.
1 Example 2 Estimate by the six Rectangle Rules using the regular partition P of the interval [0,  ] into 6 subintervals. Solution Observe that the function.
NUMERICAL DIFFERENTIATION The derivative of f (x) at x 0 is: An approximation to this is: for small values of h. Forward Difference Formula.
CISE301_Topic7KFUPM1 SE301: Numerical Methods Topic 7 Numerical Integration Lecture KFUPM Read Chapter 21, Section 1 Read Chapter 22, Sections 2-3.
CISE301_Topic71 SE301: Numerical Methods Topic 7 Numerical Integration Lecture KFUPM (Term 101) Section 04 Read Chapter 21, Section 1 Read Chapter.
Index FAQ Numerical Approximations of Definite Integrals Riemann Sums Numerical Approximation of Definite Integrals Formulae for Approximations Properties.
19.5 Numeric Integration and Differentiation
Integration. Problem: An experiment has measured the number of particles entering a counter per unit time dN(t)/dt, as a function of time. The problem.
The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Numerical Analysis ECIV 3306 Chapter 21 Newton-Cotes Integration Formula.
Numerical Integration In general, a numerical integration is the approximation of a definite integration by a “weighted” sum of function values at discretized.
Lecture 28: Comparison of different numerical integrators 1.Adaptive Simpson’s and Trapezoid Rules 2. Romberg Integration 3. Adaptive Gaussian Quadrature.
Integrals 5.
Chapter 4 Numerical Differentiation and Integration 1/16 Given x 0, approximate f ’(x 0 ). h xfhxf xf h )()( lim)('    x0x0 x1x1 h x1x1 x0x0.
1 Chapter 5 Numerical Integration. 2 A Review of the Definite Integral.
SE-280 Dr. Mark L. Hornick Numerical Integration.
3. Numerical integration (Numerical quadrature) .
Integration Integration: is the total value, or summation, of f(x) dx over the range from a to b:
Numerical Computation
MAT 1235 Calculus II Section 7.7 Approximate (Numerical) Integration
1 Numerical Analysis Lecture 12 Numerical Integration Dr. Nader Okasha.
1 Simpson’s 1/3 rd Rule of Integration. 2 What is Integration? Integration The process of measuring the area under a curve. Where: f(x) is the integrand.
Lecture 19 – Numerical Integration 1 Area under curve led to Riemann sum which led to FTC. But not every function has a closed-form antiderivative.
4.6 Numerical Integration Trapezoid and Simpson’s Rules.
Homework questions thus far??? Section 4.10? 5.1? 5.2?
EE3561_Unit 7Al-Dhaifallah EE 3561 : Computational Methods Unit 7 Numerical Integration Dr. Mujahed AlDhaifallah ( Term 342)
1 §12.4 The Definite Integral The student will learn about the area under a curve defining the definite integral.
5.1.  When we use the midpoint rule or trapezoid rule we can actually calculate the maximum error in the calculation to get an idea how much we are off.
Numerical Approximations of Definite Integrals Mika Seppälä.
Integration For a function f, The “integral of f from a to b” is the area under the graph of the function. If f is continuous, then the area is well defined,
Section 5.9 Approximate Integration Practice HW from Stewart Textbook (not to hand in) p. 421 # 3 – 15 odd.
Chap. 11 Numerical Differentiation and Integration
Techniques for Numerical Integration
1 Example 1 Estimate by the six Rectangle Rules using the regular partition P of the interval [0,1] into 4 subintervals. Solution This definite integral.
The purpose of Chapter 5 is to develop the basic principles of numerical integration Usefule Words integrate, integral 积分(的), integration 积分(法), quadrature.
To find the area under the curve Warm-Up: Graph. Area under a curve for [0, 3]  The area between the x-axis and the function Warm-up What is the area.
Chapter 6 Integration Section 4 The Definite Integral.
SE301_Topic 6Al-Amer20051 SE301:Numerical Methods Topic 6 Numerical Integration Dr. Samir Al-Amer Term 053.
Definite Integral df. f continuous function on [a,b]. Divide [a,b] into n equal subintervals of width Let be a sample point. Then the definite integral.
Approximating Antiderivatives. Can we integrate all continuous functions? Most of the functions that we have been dealing with are what are called elementary.
Quadrature – Concepts (numerical integration) Don Allen.
NUMERICAL DIFFERENTIATION Forward Difference Formula
Lecture 19 – Numerical Integration
Midpoint and Trapezoidal Rules
NUMERICAL INTEGRATION
MTH1170 Numeric Integration
5. 7a Numerical Integration. Trapezoidal sums
Approximating Definite Integrals. Left Hand Riemann Sums.
Approximating Definite Integrals. Left Hand Riemann Sums.
Integration & Area Under a Curve
Numerical Integration:
5. 7a Numerical Integration. Trapezoidal sums
MATH 174: NUMERICAL ANALYSIS I
Numerical Integration of Functions
Arc Length … x y a b xi ... Pi P0 P1 Pn
Comp 208 Computers in Engineering Yi Lin Winter, 2007
Numerical Integration
Presentation transcript:

Automatic Integration

Quadrature Fancy name for integration by calculating areas Remember the Riemann Integral definition? You take the limit of rectangles that “cover” the area under a curve With numeric integration (quadrature), we calculate these areas by summing the areas of subsets (rectangles, trapezoids, etc.) of the entire area When the computations “converge”, we quit

The Midpoint Rule Divides [a, b] into n (evenly-spaced) segments Calculates the area of the rectangle where: Width is the segment length, h = (b-a)/n Height is f((xi + xi+1)/2) (f(segment midpoint)) Essentially, we’re passing a zero-degree interpolating polynomial through ((xi + xi+1)/2, f((xi + xi+1)/2)) See riemann.cpp

The Trapezoidal Rule Uses the 1-degree polynomial passing through the points (xi, f(xi)), (xi+1, f(xi+1)) This is a trapezoid Area = h((f(xi) + f(xi+1))/2) Composite formula: See trapezoid.cpp

Error of Trapezoidal Rule We talk about local and total (“global”) truncation error when doing quadrature Local truncation error is the error of approximating the integral on [xi,xi+1] by the trapezoid there It’s O(h3) for the Trapezoidal Rule Total truncation error is the error after all the trapezoids are summed It’s O(h2)

Truncation vs. Roundoff Error As we increase the number of trapezoids, h decreases, therefore the truncation error decreases (remember, h < 1) Theoretically, we could get arbitrary accuracy by increasing n (= decreasing h) Alas, roundoff takes over We have to find other ways of increasing accuracy FYI: We will skip Romberg extrapolation

Simpson’s Rule Instead of a straight line (curve of degree 1), we use a parabola (curve of degree 2) passing through 3 points (endpoints and midpoint of each interval) Has some interesting error properties It is much better than expected A property of odd-point rules

Simpson Formula Midpoint Formula was c*f(xm) c = h Trapezoid Formula was c*f(xi) + d*f(xi+1) c = d = h/2 For Simpson’s: Use 3 points in c*f(xi) + d*f(xm) + e*f(xi+1) How to find c, d, and e? Two approaches Interpolating polynomial Use special f’s to more easily solve for c, d, and e

Simpson Formula Local formula: Composite formula: n must be even! See simpson.cpp

Error of Simpson’s Rule Local truncation error is O(h5) Total (global) truncation error is O(h4) We can really get some mileage out of this See next slide

An Improved Simpson Formula Based on the fact that truncation error is O(h4) Let S1 be a Simpson estimate with n panels Call the panel width h Let S2 be an estimate using 2n panels The panel width is therefore h/2 Since the error is O(h4): The error of S2 is 1/16-th the error of S1 See next slide

An Improved Simpson Formula

An Improved Simpson Formula We can iterate until the absolute error reaches ε But we’ll return the improved estimate: S2 + (S2 – S1) / 15 Note: As before, ε may need to be bigger than machine epsilon Roundoff may make ultimate precision unlikely Use a user-supplied tolerance instead

Automatic Integration AKA “Adaptive Integration” Continually refines mesh until accuracy is achieved Avoids needless computation (and therefore, roundoff) Refines mesh selectively Refines only when it needs to! Determines at runtime when/where it needs to refine Certain intervals will need more refinement than others The steep or wiggly ones

Program 4 We will use an adaptive Simpson’s Rule We will refine automatically according to our error estimate If |S2 - S1 | < 15 * tol, that interval is “finished” It is a recursive algorithm Which we’ll have to do very carefully! The tolerance will be spread out over the intervals

Pseudocode for Program 4 (See spec. and p. 241 for more details) area(f, a, b,tol) { compute S1 and S2 if |S2 – S1|/15 <= tol return S2 + (S2 – S1)/15 else return area(f, a, (a+b)/2, tol/2) + area(f,(a+b)/2,b,tol/2) }