Skip to main content
Engineering LibreTexts

15.5: Summary

  • Page ID
    122667
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\dsum}{\displaystyle\sum\limits} \)

    \( \newcommand{\dint}{\displaystyle\int\limits} \)

    \( \newcommand{\dlim}{\displaystyle\lim\limits} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \(\newcommand{\longvect}{\overrightarrow}\)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)

    Numerical Methods: Integration, Differentiation, and Ordinary Differential Equations

    Numerical methods are essential tools in scientific computing for approximating solutions to mathematical problems that are difficult or impossible to solve analytically. This summary covers numerical integration, numerical differentiation, and solving initial value ordinary differential equations using Python's NumPy and SciPy libraries.

    Numerical Integration

    Numerical integration, also known as quadrature, is the process of approximating the definite integral of a function. It's used when an antiderivative cannot be found analytically or when the function is only known at discrete points (e.g., experimental data).

    Concepts: The definite integral of a function f(x) from a to b is represented as \(\int_a^b f(x)dx\). Numerical methods approximate this area by dividing it into smaller shapes (rectangles, trapezoids, parabolas) and summing their areas.

    Python Implementations:

    • NumPy: While NumPy itself doesn't offer dedicated integration routines, it provides the building blocks for simple methods like the Riemann sum or trapezoidal rule if you have discrete data points.
      • np.trapz(y, x): Computes the integral using the composite trapezoidal rule.
      • np.sum(): Can be used for basic Riemann sums.
    • SciPy (scipy.integrate): This module provides a comprehensive set of functions for numerical integration.
      • scipy.integrate.quad(func, a, b): For integrating a function over a given interval. It's generally the most robust and accurate for single integrals of functions.
      • scipy.integrate.trapz(y, x): Same as NumPy's trapz, useful for integrating data points.
      • scipy.integrate.simps(y, x): Computes the integral using Simpson's rule, often more accurate than the trapezoidal rule for smooth functions.

    Numerical Differentiation

    Numerical differentiation is the process of approximating the derivative of a function using its values at a set of discrete points. It's used when an analytical derivative is unknown, too complex, or when dealing with experimental data.

    Concepts: The derivative of a function f(x) at a point x is defined as \(f'(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}\). Numerical methods approximate this limit using finite differences.

    • Forward Difference:\(\frac{f(x+h) -f(x)}{h}\)
    • Backward Difference:\(\frac{f(x) -f(x-h)}{h}\)
    • Central Difference: \(\frac{f(x+h) -f(x-h)}{2h}\) (generally more accurate)

    Python Implementations:

    • NumPy: You can implement finite difference formulas directly using NumPy arrays.
      • np.diff(arr): Computes the N-th discrete difference along the given axis. Useful for approximating derivatives of discrete data.
    • SciPy (scipy.misc or manual):
      • scipy.misc.derivative(func, x0, dx, n=1): Approximates the n-th derivative of a function func at point x0 with step size dx. This function is convenient but might not be the most robust for all cases.
      • A more controlled method utilizes a derivative digital filter that differentiates low frequency components in the signal and attenuates the higher frequency noise components.

    Solving Initial Value Ordinary Differential Equations (ODEs)

    An Ordinary Differential Equation (ODE) is an equation that relates a function with its derivatives. An Initial Value Problem (IVP) for an ODE specifies the value of the unknown function (and possibly its derivatives) at a given point, called the initial condition.

    Concepts:

    • First-Order ODE: An ODE involving only the first derivative, e.g., \(\frac{dy}{dt} = f(t,y)\).
    • Higher-Order ODE: An ODE involving derivatives higher than the first can be converted into a system of first-order ODEs.

    Converting Higher-Order ODEs to First-Order Systems: A common technique to solve higher-order ODEs numerically is to transform them into a system of first-order ODEs. For example, a second-order ODE \(\frac{d^2y}{dt^2} = f(t,y,\frac{dy}{dt})\) can be converted by introducing new variables: Let \(y_1 = y\) Let \(y_2 = \frac{dy}{dt}\) Then, we have a system of first-order ODEs: \(\frac{dy_1}{dt} = y_2\) and \(\frac{dy_2}{dt} = f(t,y_1,y_2)\)

    Python Implementations:

    • NumPy: NumPy is used to define the arrays for the state variables and the right-hand side of the ODE system.
    • SciPy (scipy.integrate.solve_ivp): This is the primary function in SciPy for solving initial value problems for systems of ODEs.
      • scipy.integrate.solve_ivp(fun, t_span, y0, method='RK45', ...)
        • fun: A function describing the right-hand side of the ODE system. It takes (t, y) as arguments and returns dy/dt.
        • t_span: A tuple (t_start, t_end) defining the interval of integration.
        • y0: Initial conditions (a NumPy array).
        • method: The integration method (e.g., 'RK45' for Runge-Kutta 4(5), 'LSODA' for stiff problems).

    These numerical methods are fundamental for solving a wide range of problems in physics, engineering, finance, and data science where analytical solutions are not feasible.


    This page titled 15.5: Summary was last modified on Wed, 30 Jul 2025 04:12:08 GMT and is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by Carl Greco.