Skip to content

MANE 3351

Lecture 13

Classroom Management

Agenda

  • Homework 3 Assignment
  • Numerical Integration
  • Lab 5 if not completed on Monday

Calendar

Week Monday Lecture Wednesday Lecture
7 10/13: Secant Method 10/15: Trapezoid Rule
8 10/20: Simpson's Rule 10/22: Romberg Integration
9 10/27: Gaussian Quadrature 10/29: Numerical Differentiation (not on Test 2)
10 11/3: Linear Algebra 11/5: Test 2 (Root Finding and Numerical Integration)

Resources

Handouts


Lecture 13 Content

  • Today's topic is numerical integration.
  • This is a major new topic after root finding.
  • Trapezoid Rule

Introduction to Numerical Integration

  • In layman's terms, an integral calculates the area under a curve
  • Frequently used in engineering analysis

Examples of integration


Another Integration Example


Definitions

Cheney and Kincaid (2004)1 provide the following definitions

  • Indefinite integral : \(\int x^2\;dx=\frac{1}{3}x^3+C\)
  • **Definite integral: ** \(\int x^2\; dx = \frac{8}{3}\)

Numerical Integration

Kiusalaas (2013)2 suggest three major approaches to numerical integration that we will investigate:

  1. Newton-Cotes

a. Trapezoid rule (n=1)

b. Simpson's rule (n=2)

c. 3/8 Simpson's rule (n=3)

  1. Romberg Integration

  2. Gaussian Quadrature

Note: there are many different techniques for numerical integration than the ones listed above


Newton-Cotes Formulas

Kiusalass (2013)2 provide the following illustration to explain Newton-Cotes techniques

Newton Cotes Approach


Trapezoid Rule

Chapra and Canale (2015)3 provide the figure shown below illustrating the trapezoid rule

Trapezoid Rule


Trapezoid Rule, continued

Chapra and Canale (2015)3 provided the following formulae

  • \(I=(b-a)\frac{f(a)+f(b)}{2}\)
  • \(E=-\frac{1}{12}f^{\prime\prime}\left(\xi\right)\left(b-a\right)^3\)

Multiple Applications of the Trapezoid Rule

Typically, the region form \(a\) to \(b\) is sub-divided into multiple regions and then the Trapezoid Rule for each region is applied. Chapra and Canale (2015)3 illustrate this concept.

Multiple Trapezoid Rules


Uniform Spacing

Cheney and Kincaid (2004)1 the following formula for composite (multiple) applications of the Trapezoid Rule

\[ \int_a^b=f(x)dx\approx T(f;P)=h\left\{\sum_{i=1}^{n-1}f\left(x_i\right)+\frac{1}{2}\left[f\left(x_0\right)+f\left(x_n\right)\right]\right\} \]

Pseudo-code

Cheney and Kincaid (2004)1 provided the following pseudo-code for the composite trapezoid rule

Trapezoid Rule Pseudo-code


Python Code for Multiple Trapezoid Rule Applications

import math
def f(z):
    return (math.exp(-0.5*z**2)/((2.0*math.pi)**0.5)) 

n=4
a=-5.0
b=0.0
h=(b-a)/n
sum=0.5*(f(a)+f(b))
for i in range(1,n):
    x=a+i*h
    sum=sum+f(x)
sum=sum*h
print("The area is {} for {} sub-intervals".format(sum,n))


  1. Cheny, W., and Kincaid, D., (2004), Numerical Mathematics and Computer, 5th edition 

  2. Kiusalaas, J. (2013), Numerical Methods in Engineering with Python 3 

  3. Chapra, S., and Canale, R., (2015), Numerical Methods for Engineers, 7th edition