Skip to content

MANE 3351

Lecture 14

Classroom Management

Agenda

  • Return Test 1
  • Simpson's Rule
  • Lab 7
  • Homework 3 due today
  • Homework 4

Calendar

Date Lecture Lab
10/14 Simpson's Rule, Homework 4 Lab 7
10/16 Romberg Integration Lab 7, continued
10/21 No Class, Dr. Timmer on ABET Visit No Class, Dr. Timmer on ABET Visit
10/23 Gaussian Quadrature, Homework 5 Lab 8
10/28 Numerical Differentiation (not on Test 2) Lab 8, continued
11/4 Numerical Integration (not on Test 2) Lab 9
11/6 Linear Algebra, part 1 (not on Test 2) Lab 9, continued
11/11 Test 2 (Root Finding and Numerical Integration) No Lab

Resources

Handouts


Lecture 14

Today's topic is Simpson's Rule.

  • Simpson's (1/3) rule is Newton-Cotes with \(n=2\)
  • Chapra and Canale (2015)3 illustrate Simpson's rule in the figure shown below Simpson's Rule

Definition of Simpson's Rule

  • Chapra and Canale(2015)3 provide the following definition of Simpson's rule
\[ I=\frac{h}{3}\left[f(x_0)+4f(x_1)+f(x_2)\right] \]

where \(h=(b-a)/2\)

  • Note that Simpson's rule is of the form
\[ \begin{aligned} I&\approx \left(b-a\right)\frac{f(x_0)+4f(x_1)+f(x_2)}{6}\\ I&\approx\mbox{ width}\times\mbox{ average height} \end{aligned} \]

Simpson's Rule Error Analysis

  • Chapra and Canale (2015)3 provides the following definition:
\[ \begin{aligned} I&=\frac{h}{3}\left[f(x_0)+4f(x_1)+f(x_2)\right]-\frac{1}{90}f^{(4)}(\xi)h^5\\ I&=\mbox{Simpson's 1/3 approximation}-\mbox{ Truncation error} \end{aligned} \]

Multiple Applications of Simpson's Rule

  • The number of segments must be even
  • The formula is
\[ I\approx\left(b-a\right)\frac{f(x_0)+4\sum_{i=1,3,5}^{n-1}f(x_i)+2\sum_{j=2,4,6}^{n-2}f(x_j)+f(x_n)}{3n} \]

where \(h=\frac{b-a}{n}\)


Pseudo-code: Simpson's 1/3 Rule

  • CodeSansar4 provides the following pseudo-code Simpson's 1/3 pseudo-code

Python Code for Multiple Simpson's 1/3 Rule

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

n=10
a=-5.0
b=0.0
h=(b-a)/n
sum=f(a)+f(b)
for i in range(1,n):
   # print(i)
    k=a+i*h
    if i%2==0:
        #print("even number")
        sum=sum+2.0*f(k)
    else:
        #print("odd number")
        sum=sum+4.0*f(k)
sum=sum*h/3.0
print("The area is {} after {} iterations".format(sum,n))

Simpson's 3/8 Rule

  • Simpson's 3/8 rule is Newton-Cotes with \(n=3\)
  • Chapra and Canale (2015)3 illustrate Simpson's rule in the figure shown below Simpson's3/8 Rule

Definition of Simpson's 3/8 Rule

  • Chapra and Canale(2015)3 provide the following definition of Simpson's rule
\[ I=\frac{3h}{8}\left[f(x_0)+3f(x_1)+3f(x_2)+f(x_3)\right] \]

where \(h=(b-a)/3\)

  • Note that Simpson's 3/8 rule is of the form
\[ \begin{aligned} I&\approx \left(b-a\right)\frac{f(x_0)+3f(x_1)+3f(x_2)+f(x_3)}{8}\\ I&\approx\mbox{ width}\times\mbox{ average height} \end{aligned} \]

Truncation Error of Simpson's 3/8 Rule

\[ \begin{aligned} E_t&=-\frac{3}{80}h^5f^{(4)}(\xi)\\ &=-\frac{\left(b-a\right)^5}{6480}f^{(4)}(\xi) \end{aligned} \]

Classroom Coding: One Interval of Simpson's 3/8 Rule


รท


  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 

  4. https://www.codesansar.com/numerical-methods/integration-simpson-1-3-method-algorithm.htm 

  5. https://www.codesansar.com/numerical-methods/integration-simpson-3-8-method-pseudocode.htm