240 likes | 321 Views
Numerical Methods. What computers can’t do. Solve (by reasoning) general mathematical problems t hey can only repetitively apply arithmetic primitives to input. Solve problems exactly . Represent all numbers. Only a finite subset of the numbers between 0 and 1 can be represented.
E N D
What computers can’t do • Solve (by reasoning) general mathematical problems they can only repetitively apply arithmetic primitives to input. • Solve problems exactly. • Represent all numbers. Only a finite subset of the numbers between 0 and 1 can be represented.
Numerical Integration • In NA, take visual view of integration as area under the curve • Many integrals that occur in science or engineering practice do not have a closed form solution – must be solved using numerical integration
Trapezoidal Rule • The area under the curve from [a, fa] to [b, fb] is initially approximated by a trapezoid: I1 = ( b – a ) * ( fa + fb ) / 2
Simple trapezoid over large interval is prone to error. Divide interval into halves…
fc I2 = ( b – a )/2 * ( fa + 2*fc + fb ) / 2 (Note that interior sides count twice, since they belong to 2 traps.)
Trapezoidal rule This gives us a better approximation than either left or right rectangles.
Example Single Application of the Trapezoidal Rulef(x) = 0.2 +25x – 200x2 + 675x3 – 900x4 + 400x5Integrate f(x) from a=0 to b=0.8 Solution:f(a)=f(0) = 0.2 and f(b)=f(0.8) = 0.232
Simpson’s rule • .. Another approach • Rather than use straight line of best fit, • Use parabola of best fit (curves) • Converges more quickly
Simpson’s Rules • More accurate estimate of an integral is obtained if a high-order polynomial is used to connect the points. These formulas are called Simpson’s rules. Simpson’s 1/3 Rule: resultswhen a 2nd order Lagrange interpolating polynomial is used for f(x) a=x0x1 b=x2
The Multiple-Application Simpson’s 1/3 Rule • Just as the trapezoidal rule, Simpson’s rule can be improved by dividing the integration interval into a number of segments of equal width. • However, it is limited to cases where values are equispaced, there are an even number of segments and odd number of points.
Simpson’s rule Simpson’s rule can also be interpreted as fitting parabolas to sections of the curve. Simpson’s rule will usually give a very good approximation with relatively few subintervals.
Simpson’s 3/8 Rule Fit a 3rd order Lagrange interpolating polynomial to four points and integrate Simpson’s 1/3 and 3/8 rules can be applied in tandem to handle multiple applications with odd number of intervals
Equation 2 Rn APPROXIMATION • If we choose xi* to be the right endpoint, xi* = xi and we have: • The approximation Rniscalled right endpoint approximation.
Mn APPROXIMATION • The figure shows the midpoint approximation Mn.
THE MIDPOINT RULE • where and
APPROXIMATE INTEGRATION • Approximate the integral with n = 5, using: a. Trapezoidal Rule • b. Midpoint Rule Example 1
Example 1 a APPROXIMATE INTEGRATION • With n = 5, a = 1 and b = 2, we have: ∆x = (2 – 1)/5 = 0.2 • So, the Trapezoidal Rule gives:
APPROXIMATE INTEGRATION Example 1 b • The midpoints of the five subintervals are: 1.1, 1.3, 1.5, 1.7, 1.9
Example 1 b APPROXIMATE INTEGRATION • So, the Midpoint Rule gives:
Example 3 ERROR ESTIMATES • Use the Midpoint Rule with n = 10 to approximate the integral • Give an upper bound for the error involved in this approximation.
Example 3 a ERROR ESTIMATES • As a = 0, b = 1, and n = 10, the Midpoint Rule gives: