Why numerical differentiation and integration matter
Engineering data often comes from measurements rather than exact formulas. Numerical methods let us estimate
derivatives and integrals from sampled points such as sensor readings, velocity data, force data, or flow-rate data.
\[
(x_0,y_0),(x_1,y_1),\ldots,(x_n,y_n)
\]
The calculator treats these as samples of a curve \(y=f(x)\).
Engineering meaning of integration
Numerical integration estimates accumulated quantity from the area under a curve.
\[
A=\int_a^b f(x)\,dx.
\]
Examples include displacement from velocity, work from force, total volume from flow rate, and total heat transfer
from a heat-rate curve.
Engineering meaning of differentiation
Numerical differentiation estimates local rate of change.
\[
f'(x)=\frac{df}{dx}.
\]
Examples include acceleration from velocity data, velocity from position data, cooling rate from temperature data,
and sensitivity from experimental response curves.
Forward difference
A forward difference uses the current point and the next point.
\[
f'(x_i)
\approx
\frac{f(x_{i+1})-f(x_i)}{x_{i+1}-x_i}.
\]
It is commonly used at the first data point, where there is no point before it.
Backward difference
A backward difference uses the current point and the previous point.
\[
f'(x_i)
\approx
\frac{f(x_i)-f(x_{i-1})}{x_i-x_{i-1}}.
\]
It is commonly used at the last data point, where there is no point after it.
Central difference
A central difference uses one point before and one point after the current point.
\[
f'(x_i)
\approx
\frac{f(x_{i+1})-f(x_{i-1})}{x_{i+1}-x_{i-1}}.
\]
For smooth data, central differences are usually more accurate than one-sided differences.
Function derivative with a small step
If a function is known, a small step \(h\) can be used around the selected point.
\[
f'(x_0)
\approx
\frac{f(x_0+h)-f(x_0-h)}{2h}.
\]
A very small \(h\) is not always better because computer roundoff error can become important.
Trapezoidal rule
The trapezoidal rule approximates the area under a curve by replacing each interval with a trapezoid.
\[
A_i
=
\frac{y_i+y_{i+1}}{2}
\left(x_{i+1}-x_i\right).
\]
\[
\int_a^b f(x)\,dx
\approx
\sum_i
\frac{y_i+y_{i+1}}{2}
\left(x_{i+1}-x_i\right).
\]
This method works for equally spaced and unequally spaced data.
Cumulative trapezoidal integration
Cumulative integration shows how the accumulated area grows interval by interval.
\[
A_k
=
\sum_{i=0}^{k-1}
\frac{y_i+y_{i+1}}{2}
\left(x_{i+1}-x_i\right).
\]
For velocity data, \(A_k\) estimates position change up to time \(x_k\).
Composite Simpson's rule
Simpson's rule uses parabolic arcs instead of straight trapezoid tops.
\[
\int_a^b f(x)\,dx
\approx
\frac{h}{3}
\left[
f_0+4f_1+2f_2+4f_3+\cdots+f_n
\right].
\]
Composite Simpson's rule needs equally spaced points and an even number of intervals.
When Simpson's rule is not available
Simpson's rule should not be used automatically for every data set. It requires:
- equal spacing between consecutive \(x\)-values,
- an even number of intervals,
- at least three data points,
- reasonably smooth behavior between points.
If these conditions are not met, the trapezoidal rule is safer.
Velocity, position, and acceleration
If \(v(t)\) is velocity, integrating velocity gives displacement.
\[
\Delta x
=
\int_{t_0}^{t_1} v(t)\,dt.
\]
Differentiating velocity gives acceleration.
\[
a(t)=\frac{dv}{dt}.
\]
Force and work
If \(F(x)\) is force as a function of displacement, the work done is the area under the force-displacement curve.
\[
W
=
\int_{x_0}^{x_1}F(x)\,dx.
\]
This is one of the most common engineering uses of numerical integration from experimental data.
Flow rate and accumulated volume
If \(Q(t)\) is a volume flow rate, then integrating flow rate gives volume.
\[
V
=
\int_{t_0}^{t_1}Q(t)\,dt.
\]
For sampled flow-meter data, the trapezoidal rule is often used because measurements may not be perfectly smooth.
Accuracy considerations
Numerical integration usually becomes more accurate when the spacing between points is smaller.
Numerical differentiation is more sensitive to noise because it subtracts nearby measurements.
\[
\text{noisy data}
\quad\Longrightarrow\quad
\text{unstable derivative estimates}.
\]
In real engineering data, smoothing or fitting may be needed before differentiating.
Common mistakes
- Using Simpson's rule when the data are not equally spaced.
- Forgetting that Simpson's rule needs an even number of intervals.
- Confusing the units of the integral with the units of the original data.
- Assuming derivative estimates are reliable when the data are noisy.
- Entering duplicate \(x\)-values.
- Forgetting to sort data by the independent variable.
- Using a step size \(h\) that is too large or too small for a function derivative.