Presentation on theme: "NUMERICAL DIFFERENTIATION AND INTEGRATION"— Presentation transcript:
1 NUMERICAL DIFFERENTIATION AND INTEGRATION ENGR 351Numerical Methods for EngineersSouthern Illinois University CarbondaleCollege of EngineeringDr. L.R. ChevalierDr. B.A. DeVantier
2 Numerical Differentiation and Integration Calculus is the mathematics of change.Engineers must continuously deal with systems and processes that change, making calculus an essential tool of our profession.At the heart of calculus are the related mathematical concepts of differentiation and integration.
3 DifferentiationDictionary definition of differentiate - “to mark off by differences, distinguish; ..to perceive the difference in or between”Mathematical definition of derivative - rate of change of a dependent variable with respect to an independent variable
5 Integration The inverse process of differentiation Dictionary definition of integrate - “to bring together, as parts, into a whole; to unite; to indicate the total amount”Mathematically, it is the total value or summation of f(x)dx over a range of x. In fact the integration symbol is actually a stylized capital S intended to signify the connection between integration and summation.
11 Specific Study Objectives Understand the derivation of the Newton-Cotes formulasRecognize that the trapezoidal and Simpson’s 1/3 and 3/8 rules represent the areas of 1st, 2nd, and 3rd order polynomialsBe able to choose the “best” among these formulas for any particular problem
12 Specific Study Objectives Recognize the difference between open and closed integration formulasUnderstand the theoretical basis of Richardson extrapolation and how it is applied in the Romberg integration algorithm and for numerical differentiation
13 Specific Study Objectives Recognize why both Romberg integration and Gauss quadrature have utility when integrating equations (as opposed to tabular or discrete data).Understand the application of high-accuracy numerical-differentiation.Recognize data error on the processes of integration and differentiation.
14 Newton-Cotes Integration Common numerical integration schemeBased on the strategy of replacing a complicated function or tabulated data with some approximating function that is easy to integrate
15 Newton-Cotes Integration Common numerical integration schemeBased on the strategy of replacing a complicated function or tabulated data with some approximating function that is easy to integrate
16 Newton-Cotes Integration Common numerical integration schemeBased on the strategy of replacing a complicated function or tabulated data with some approximating function that is easy to integratefn(x) is an nth orderpolynomial
17 The approximation of an integral by the area under - a first order polynomial- a second order polynomialWe can also approximated the integral by using aseries of polynomials applied piece wise.
18 An approximation of an integral by the area under straight line segments.
19 Newton-Cotes Formulas Closed form - data is at the beginning and end of the limits of integrationOpen form - integration limits extend beyond the range of data.
20 Trapezoidal Rule First of the Newton-Cotes closed integration formulas Corresponds to the case where the polynomial is a first order
22 Integrate this equation. Results in the trapezoidal rule.
23 The concept is the same but the trapezoid is on its side. baseheightheightheightwidthbase
24 Error of the Trapezoidal Rule This indicates that is the function being integrated islinear, the trapezoidal rule will be exact.Otherwise, for section with second and higher orderderivatives (that is with curvature) error can occur.A reasonable estimate of x is the average value ofb and a
25 Multiple Application of the Trapezoidal Rule Improve the accuracy by dividing the integration interval into a number of smaller segmentsApply the method to each segmentResulting equations are called multiple-application or composite integration formulas
26 Multiple Application of the Trapezoidal Rule where there are n+1 equally spaced base points.
27 We can group terms to express a general form }}widthaverage height
28 }widthaverage heightThe average height represents a weighted averageof the function valuesNote that the interior points are given twice the weightof the two end points
29 EXAMPLE Evaluate the following integral using the trapezoidal rule and h = 0.1
30 Simpson’s 1/3 RuleCorresponds to the case where the function is a second order polynomial
31 Simpson’s 1/3 RuleDesignate a and b as x0 and x2, and estimate f2(x) as a second order Lagrange polynomial
32 Simpson’s 1/3 RuleAfter integration and algebraic manipulation, we get the following equations}widthaverage height
33 Error Single application of Trapezoidal Rule. Single application of Simpson’s 1/3 Rule
35 The odd points represent the middle term for each application The odd points represent the middle term for each application. Hence carry the weight 4The even points are common to adjacent applications and are counted twice.
36 Simpson’s 3/8 RuleCorresponds to the case where the function is a third order polynomial
37 Integration of Unequal Segments Experimental and field study data is often unevenly spacedIn previous equations we grouped the term (i.e. hi) which represented segment width.
38 Integration of Unequal Segments We should also consider alternately using higher order equations if we can find data in consecutively even segmentstrapezoidalrule1/3ruletrapezoidalrule3/8rule
39 EXAMPLE Integrate the following using the trapezoidal rule, Simpson’s 1/3 Rule and a multiple application ofthe trapezoidal rule with n=2. Compare results withthe analytical solution.
41 Multiple Application of the Trapezoidal Rule We are obviously not doing very well on our estimates.Lets consider a scheme where we “weight” the estimates....end of example
42 Integration of Equations Integration of analytical as opposed to tabular functionsRomberg IntegrationRichardson’s ExtrapolationRomberg Integration AlgorithmGauss QuadratureImproper Integrals
43 Richardson’s Extrapolation Use two estimates of an integral to compute a third more accurate approximationThe estimate and error associated with a multiple application trapezoidal rule can be represented generally as:I = I(h) + E(h)where I is the exact value of the integralI(h) is the approximation from an n-segment applicationE(h) is the truncation errorh is the step size (b-a)/n
44 Make two separate estimates using step sizes of h1 and h2 . I(h1) + E(h1) = I(h2) + E(h2)Recall the error of the multiple-application of the trapezoidalruleAssume that is constant regardless of the step size
46 Thus we have developed an estimate of the truncation error in terms of the integral estimates and their step sizes. This estimate can then be substituted into:I = I(h2) + E(h2)to yield an improved estimate of the integral:
47 What is the equation for the special case where the interval is halved? i.e. h2 = h1 / 2
49 EXAMPLEUse Richardson’s extrapolation to evaluate:
50 ROMBERG INTEGRATIONWe can continue to improve the estimate by successivehalving of the step size to yield a general formula:k = 2; j = 1Note:the subscriptsm and l refer tomore and lessaccurate estimates
51 Following a similar pattern to Newton divided differences, Romberg’s Table can be produced Error orders for j valuesi = i = i = i = 4j O(h2) O(h4) O(h6) O(h8)1 h I1, I1, I1, I1,42 h/ I2, I2, I2,33 h/ I3, I3,24 h/ I4,1Trapezoidal Simpson’s 1/3 Simpson’s 3/ Boole’sRule Rule Rule Rule
52 Gauss QuadratureExtend the areaunder the straightlinef(x)xf(x)x
53 Method of Undetermined Coefficients Recall the trapezoidal ruleBefore analyzingthis method,answer thisquestion.What are twofunctions thatshould be evaluatedexactlyby the trapezoidalrule?This can also be expressed aswhere the c’s are constant
54 The two cases that should be evaluated exactly by the trapezoidal rule: 1) y = constant2) a straight linef(x)y = 1f(x)y = x-(b-a)/2x(b-a)/2-(b-a)/2x(b-a)/2
55 Thus, the following equalities should hold. FOR y=1since f(a) = f(b) =1FOR y =xsince f(a) = x =-(b-a)/2andf(b) = x =(b-a)/2
56 Evaluating both integrals For y = 1For y = xNow we have two equations and two unknowns, c0 and c1.Solving simultaneously, we get :c0 = c1 = (b-a)/2Substitute this back into:
57 We get the equivalent of the trapezoidal rule. DERIVATION OF THE TWO-POINTGAUSS-LEGENDRE FORMULALets raise the level of sophistication by:- considering two points between -1 and 1- i.e. “open integration”
58 f(x)-1 x x1 1xPreviously ,we assumed that the equation fit the integrals of a constant and linear function.Extend the reasoning by assuming that it also fits the integral of a parabolic and a cubic function.
59 f(xi) is either 1, xi, xi2 or xi3 Solve these equations simultaneously
60 This results in the following The interesting result is that the simple additionof the function values at
61 However, we have set the limit of integration at -1 and 1. This was done to simplify the mathematics. A simplechange in variables can be use to translate other limits.Assume that the new variable xd is related to theoriginal variable x in a linear fashion.x = a0 + a1xdLet the lower limit x = a correspond to xd = -1 and the upperlimit x=b correspond to xd=1a = a0 + a1(-1) b = a0 + a1(1)
62 a = a0 + a1(-1) b = a0 + a1(1)SOLVE THESE EQUATIONSSIMULTANEOUSLYsubstitute
63 These equations are substituted for x and dx respectively. Let’s do an example to appreciate the theorybehind this numerical method.
64 EXAMPLEEstimate the following using two-point Gauss Legendre:
65 Higher-Point Formulas For two point, we determined that c0 =c1 = 1For three point:c0 = x0=-0.775c1= x1=0.0c2= x2=0.775
66 Higher-Point Formulas Your text goes on to provide additional weightingfactors (ci’s) and function arguments (xi’s)in Table p. 623.
67 Improper Integrals How do we deal with integrals that do not have finite limitsand boundedintegrands?Our answer will focuson improper integralswhere one limit (upper orlower) is infinity.
68 Choose -A so that is is sufficiently large to approach zero asymptotically.Once chosen, evaluate the second part using aNewton-Cotes formula.Evaluate the first part with the following identity.
69 Numerical Differentiation Forward finite divided differenceBackward finite divided differenceCenter finite divided differenceAll based on the Taylor Series
79 Richardson Extrapolation Two ways to improve derivative estimatesdecrease step sizeuse a higher order formula that employs more pointsThird approach, based on Richardson extrapolation, uses two derivatives estimates to compute a third, more accurate approximation
80 Richardson Extrapolation For a centered differenceapproximation withO(h2) the application ofthis formula will yielda new derivative estimateof O(h4)
81 EXAMPLEGiven the following function, use Richardson’s extrapolation to determine the derivative at 0.5.f(x) = -0.1x x x x +1.2Note:f(0) = 1.2f(0.25) =1.1035f(0.75) = 0.636f(1) = 0.2
82 Derivatives of Unequally Spaced Data Common in data from experiments or field studiesFit a second order Lagrange interpolating polynomial to each set of three adjacent points, since this polynomial does not require that the points be equispacedDifferentiate analytically
83 Derivative and Integral Estimates for Data with Errors In addition to unequal spacing, the other problem related to differentiating empirical data is measurement errorDifferentiation amplifies errorIntegration tends to be more forgivingPrimary approach for determining derivatives of imprecise data is to use least squares regression to fit a smooth, differentiable function to the dataIn absence of other information, a lower order polynomial regression is a good first choice