You have 3 free guides left 😟
Unlock your guides
You have 3 free guides left 😟
Unlock your guides

13.1 Numerical Integration and Differentiation

3 min readjuly 22, 2024

Numerical integration and differentiation are powerful tools for solving complex mathematical problems. These techniques approximate integrals and derivatives when analytical solutions are impractical or impossible, using methods like the and finite differences.

By implementing these algorithms in programming languages like Python and MATLAB, we can efficiently compute solutions to real-world problems. Understanding the accuracy, stability, and appropriate application of these methods is crucial for effectively solving mathematical and physical challenges.

Numerical Integration

Concepts of numerical integration

Top images from around the web for Concepts of numerical integration
Top images from around the web for Concepts of numerical integration
  • Numerical integration approximates definite integrals using discrete points when analytical integration is difficult or impossible (complex functions, tabular data)
  • Trapezoidal rule approximates the area under a curve using trapezoids, dividing the interval into subintervals and summing the areas of the trapezoids
    • Formula: abf(x)dxh2[f(a)+2f(x1)+2f(x2)++2f(xn1)+f(b)]\int_a^b f(x) dx \approx \frac{h}{2}[f(a) + 2f(x_1) + 2f(x_2) + \cdots + 2f(x_{n-1}) + f(b)], where h=banh = \frac{b-a}{n} and nn is the number of subintervals
  • approximates the area under a curve using quadratic polynomials, providing higher accuracy than the trapezoidal rule
    • Formula: abf(x)dxh3[f(a)+4f(x1)+2f(x2)+4f(x3)++2f(xn2)+4f(xn1)+f(b)]\int_a^b f(x) dx \approx \frac{h}{3}[f(a) + 4f(x_1) + 2f(x_2) + 4f(x_3) + \cdots + 2f(x_{n-2}) + 4f(x_{n-1}) + f(b)], where h=banh = \frac{b-a}{n} and nn is the number of subintervals (must be even)
  • approximates integrals using optimally chosen points and weights, providing high accuracy for smooth functions (sine, exponential)
    • Common types include Gauss-Legendre, Gauss-Hermite, and Gauss-Laguerre quadrature
    • Formula: abf(x)dxi=1nwif(xi)\int_a^b f(x) dx \approx \sum_{i=1}^n w_i f(x_i), where wiw_i are the weights and xix_i are the quadrature points

Implementation of numerical algorithms

  • Python implementation utilizes NumPy and SciPy libraries for efficient computations
    • Example: Trapezoidal rule
      import numpy as np
      
      def trapezoidal(f, a, b, n):
          h = (b - a) / n
          x = np.linspace(a, b, n+1)
          y = f(x)
          integral = (h/2) * (y[0] + 2*np.sum(y[1:-1]) + y[-1])
          return integral
      
  • MATLAB implementation leverages built-in functions for numerical integration and differentiation
    • Example: Simpson's rule
      f = @(x) sin(x);
      a = 0;
      b = pi;
      n = 100;
      
      h = (b - a) / n;
      x = linspace(a, b, n+1);
      y = f(x);
      
      integral = (h/3) * (y(1) + 4*sum(y(2:2:end-1)) + 2*sum(y(3:2:end-2)) + y(end));
      

Numerical Differentiation

Methods of numerical differentiation

  • Finite differences approximate derivatives using the difference quotient
    • Forward difference: f(x)f(x+h)f(x)hf'(x) \approx \frac{f(x+h) - f(x)}{h}
    • Backward difference: f(x)f(x)f(xh)hf'(x) \approx \frac{f(x) - f(x-h)}{h}
    • Central difference: f(x)f(x+h)f(xh)2hf'(x) \approx \frac{f(x+h) - f(x-h)}{2h}, which is more accurate than forward and backward differences
  • improves the accuracy of numerical derivatives by combining approximations with different step sizes
    • Formula: f(x)4D(h/2)D(h)3f'(x) \approx \frac{4D(h/2) - D(h)}{3}, where D(h)D(h) is the finite difference approximation with step size hh

Analysis of numerical techniques

  • Accuracy depends on the step size and the order of the method, with higher-order methods generally providing better accuracy (Gaussian quadrature vs trapezoidal rule)
    • can automatically adjust the step size to maintain a desired accuracy (adaptive Simpson's rule)
  • Stability refers to the ability of numerical methods to control the growth of errors over time
    • Stable methods have bounded errors that do not grow significantly (implicit Euler method)
    • Implicit methods are often more stable than explicit methods (implicit vs explicit Runge-Kutta methods)
  • Selecting appropriate techniques depends on the characteristics of the function and the problem at hand
    • Smooth functions: Higher-order methods (Simpson's rule, Gaussian quadrature)
    • Non-smooth or discontinuous functions: Lower-order methods (trapezoidal rule)
    • Oscillatory functions: Specialized methods (Filon's method, Levin's method)
    • High-dimensional integrals: Monte Carlo methods or sparse grid techniques
© 2024 Fiveable Inc. All rights reserved.
AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.
AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.

© 2024 Fiveable Inc. All rights reserved.
AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.
Glossary
Glossary