6.2 Interpolation, Numerical Integration & Numerical Solution of ODEs
Key Takeaways
- The trapezoidal rule integrates with error of order h², while Simpson's 1/3 rule reaches order h⁴ and integrates cubics exactly despite fitting parabolas.
- Simpson's 1/3 rule requires an even number of intervals; Simpson's 3/8 rule requires a multiple of three.
- Lagrange and Newton divided-difference interpolation through the same n + 1 points produce the identical unique polynomial of degree ≤ n, only in different algebraic form.
- Euler's method has global error of order h and is only conditionally stable; fourth-order Runge-Kutta reaches global error of order h⁴ using four slope evaluations per step.
- Numerical differentiation amplifies noise: the central difference [f(x+h) − f(x−h)]/2h is second-order accurate and preferred over one-sided differences.
6.2 Interpolation, Numerical Integration & Numerical Solution of ODEs
The second half of the PRC Enhanced TOS topic Numerical Methods & Analysis deals with data that arrives as a table rather than a formula, and with differential equations that have no closed-form solution. Electrical engineers meet both daily: conductor ampacity tables that need interpolation, measured load curves that need integration into energy, and transient-stability swing equations that need step-by-step solution.
1. Interpolation
Linear Interpolation
The workhorse for reading between two rows of a PEC or manufacturer's table:
Lagrange Interpolating Polynomial
For $n+1$ data points, the unique polynomial of degree $\le n$ through them is
Newton's Divided-Difference Form
with divided differences built recursively as
Examinable fact: Lagrange and Newton forms give the same polynomial through the same points — the interpolating polynomial of degree $\le n$ through $n+1$ distinct points is unique. Newton's form is preferred in practice because adding a new data point only appends one term instead of rebuilding everything.
Interpolation vs. extrapolation: estimating inside the data range is interpolation and is comparatively safe; going outside it is extrapolation, and high-degree polynomials diverge violently there (Runge's phenomenon). Spline interpolation, which fits low-degree polynomials piecewise with matched slopes and curvatures, avoids this oscillation.
2. Finite Differences & Numerical Differentiation
| Scheme | Formula | Truncation error |
|---|---|---|
| Forward difference | $f'(x) \approx \dfrac{f(x+h) - f(x)}{h}$ | $O(h)$ |
| Backward difference | $f'(x) \approx \dfrac{f(x) - f(x-h)}{h}$ | $O(h)$ |
| Central difference | $f'(x) \approx \dfrac{f(x+h) - f(x-h)}{2h}$ | $O(h^{2})$ |
| Second derivative | $f''(x) \approx \dfrac{f(x+h) - 2f(x) + f(x-h)}{h^{2}}$ | $O(h^{2})$ |
The central difference is second-order accurate at the same cost as the one-sided forms, so it is the default. Be aware that numerical differentiation amplifies measurement noise (the subtraction of nearly equal numbers is divided by a small $h$), which is why differentiating a noisy current signal is far less reliable than integrating it.
3. Numerical Integration
With $h = (b-a)/n$:
Trapezoidal Rule
Simpson's 1/3 Rule — $n$ must be even
The coefficient pattern is $1, 4, 2, 4, 2, \dots, 4, 1$. Although it fits parabolas, Simpson's 1/3 rule integrates cubics exactly — a favourite examination fact.
Simpson's 3/8 Rule — $n$ must be a multiple of three
| Rule | Fits | Interval requirement | Error order | Exact for polynomials up to degree |
|---|---|---|---|---|
| Trapezoidal | Straight lines | any $n$ | $O(h^{2})$ | 1 |
| Simpson's 1/3 | Parabolas | $n$ even | $O(h^{4})$ | 3 |
| Simpson's 3/8 | Cubics | $n$ multiple of 3 | $O(h^{4})$ | 3 |
4. Numerical Solution of Ordinary Differential Equations
For $\dfrac{dy}{dx} = f(x,y)$ with $y(x_0) = y_0$:
Euler's Method
Simple, but only first-order accurate and conditionally stable — halving $h$ only halves the error while doubling the work.
Heun's Method (Improved Euler, RK2)
Fourth-Order Runge-Kutta (RK4)
RK4 costs four function evaluations per step but delivers fourth-order accuracy, which is why it is the standard integrator for the transient-stability swing equation and for machine dynamic models.
Solved Board Exam Examples
Example 1: Simpson's 1/3 Rule on a Load Curve
A feeder demand is recorded every 2 hours over an 8-hour shift: 4.0, 5.2, 6.8, 6.0 and 4.4 MW. Estimate the energy delivered.
Solution. Here $h = 2$ h and $n = 4$ intervals — even, so Simpson's 1/3 rule applies:
The trapezoidal rule on the same data gives 44.40 MWh — close here, but with error of order $h^2$ rather than $h^4$.
Example 2: One RK4 Step on an RL Transient
For $\dfrac{di}{dt} = 10 - 2i$ with $i(0) = 0$, take one RK4 step of $h = 0.1$ s.
Solution.
The exact solution is $i(t) = 5(1 - e^{-2t})$, giving $i(0.1) = 0.906346$ A — RK4 is correct to five decimal places in a single step, while plain Euler would have returned 1.0000 A, an error of 10%.
Example 3: Lagrange Interpolation of Conductor Ampacity
Ampacity is tabulated as 115 A at 30 °C, 103 A at 40 °C and 89 A at 50 °C. Estimate the ampacity at 35 °C using a second-degree Lagrange polynomial.
Solution. With $x_0 = 30, x_1 = 40, x_2 = 50$ and $x = 35$:
Simple linear interpolation between the first two rows would give 109.0 A; the quadratic form captures the slight curvature of the derating curve. Note that the coefficients sum to exactly 1.000, a useful arithmetic check.
A set of measurements is to be integrated using Simpson's 1/3 rule. What restriction applies to the number of intervals?
Although Simpson's 1/3 rule fits parabolic arcs through the data, up to what polynomial degree does it integrate exactly?
Compared with Euler's method at the same step size, what does the fourth-order Runge-Kutta method require and deliver?