Skip to content
CoreSource checked

Simpson's Rule

Approximates an integral by fitting parabolas over intervals.

Quick Facts

Compact metadata for implementation and discovery.

Category
Numerical Methods
Difficulty
Beginner
Family
Numerical Integration
Tier
Core
Status
Verified
Review
Source Checked
Sources
1
Formulas
1
Relationships
4
Code example
Not ready
Visualization
Ready

Overview

Simpson's Rule estimates area under a curve with weighted samples that match a quadratic curve over each pair of subintervals.

Core Concepts

numeric approximationweighted sample sumintegral approximationnumerical integrationconvergence checkerror control

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(n)

Average

O(n)

Worst

O(n)

Space

O(1)

When to Use

  • Use Simpson's Rule when you need to sample a function at evenly spaced points.
  • Use it for numerical integration with inputs like function.
  • Use it when an approximate numeric result is acceptable and the input assumptions are satisfied.
  • Use it when the Numerical Integration tradeoff is acceptable for the problem size.

When Not to Use

  • Avoid it when rounding error, ill-conditioning, or convergence failure would hide the real answer.
  • Avoid it when the required output is not approximate integral.

What It Does

  • Samples a function at evenly spaced points
  • Combines samples with Simpson weights

Use Cases

  • Numerical integration
  • Engineering calculations
  • Approximating smooth areas

Inputs

  • Function
  • Integration interval
  • Even number of subintervals

Outputs

  • Approximate integral

Key Formulas (1)

Simpson weighted sum

integral ≈ h/3 · (f(x0) + 4·f(x1) + f(x2))
integral ~= h/3 * (f(x0) + 4*f(x1) + f(x2))

Approximates area under a curve using a quadratic fit over two subintervals.

Pseudocode

  1. 1.Split the interval into an even number of pieces
  2. 2.Evaluate the function at endpoints and midpoints
  3. 3.Apply Simpson weights
  4. 4.Multiply by the step size factor
  5. 5.Return the area estimate

Canonical Example

Input
equation = x^2 - 9 = 0 or matrix system Ax = b
Output
approximate numeric solution
Explanation
Simpson's Rule: The method iteratively or algebraically approximates the requested mathematical result.

Implementation Notes

  • Keep the input contract explicit: Function; Integration interval; Even number of subintervals.
  • Use this step as the implementation spine: Split the interval into an even number of pieces.
  • Then preserve the next state change: Evaluate the function at endpoints and midpoints.
  • Use small examples with known answers to verify the numeric update before scaling up.

Common Pitfalls

  • Simpson's Rule is accurate for smooth functions but expects an even number of subintervals.
  • Stopping based only on iteration count instead of checking residual, tolerance, or error.
  • Returning approximate integral without handling empty, invalid, or boundary inputs.

Interactive Mechanism Walkthrough

Iterative Convergence & State Trajectory

Show parabolic arcs approximating area under a curve.

Simpson's Rule mechanism walkthrough step 1 of 5x₀x₁x₂x*
Step 1 of 5: Split the interval into an even number of pieces
parabolic-area

Notes

Simpson's Rule operates in O(n) time and O(1) space within the Numerical Integration family. Key governing relation: integral ~= h/3 * (f(x0) + 4*f(x1) + f(x2)). Often compared with Bisection Method and Runge-Kutta Method.

Sources (1)

What each reference supports for this entry.

Numerical Recipes

Book

Reference text and implementation-oriented treatment for root finding, interpolation, integration, and ODE methods.

Open source

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Conceptual neighborPolynomial Interpolation

Simpson's Rule is based on local polynomial approximation.

Alternative toTrapezoidal Rule

Simpson's Rule uses quadratic interpolation rather than linear trapezoids.

Tags

Numerical MethodsQuadratureNumerical Integration