Engineering Mathematics III

Chapter 12
Numerical Methods for Engineering Computation

Bachelor Program in Mechatronics Engineering
Engineering Mathematics III   •   Bachelor

Numerical Methods for Engineering Computation

Introduction

Engineering models frequently produce equations that cannot be solved conveniently by closed-form algebra. A nonlinear sensor model, a matrix equation from a robot mechanism, a sampled displacement signal, or a transient thermal model may require numerical computation. Numerical methods replace an exact mathematical operation by a finite sequence of arithmetic operations that produces an approximation.

The quality of a numerical answer depends on more than the number of digits displayed. A reliable computation requires attention to conditioning, convergence, stability, truncation error, round-off error, stopping criteria, and the validity of the mathematical model. These issues are particularly important in mechatronics, where computations are implemented in embedded controllers and must often be completed rapidly with finite precision.

Learning objectives

By the end of this chapter, a student should be able to:

  • formulate and solve nonlinear equations using bracketing and open methods;
  • construct and evaluate interpolation formulas;
  • approximate derivatives and integrals from discrete data;
  • solve linear systems and assess their numerical reliability;
  • explain eigenvalue methods and their engineering significance;
  • solve initial-value differential equations numerically;
  • distinguish truncation, round-off, conditioning, convergence, and stability;
  • select a method according to accuracy, robustness, computational cost, and application requirements.

1. Numerical error and reliability

If x is the exact value and x̃ is its computed approximation, the absolute error is

Ea = |x - x̃|

The relative error, provided x ≠ 0, is

Er = |x - x̃| / |x|

The percentage relative error is 100E_r percent. For a measured or reference value x_ref, an often-used practical estimate is |x_ref − x̃|/|x_ref|, although x_ref itself may not be exact.

Round-off error results from representing real numbers with a finite number of digits. Truncation error results from replacing an infinite process or exact expression by a finite one; for example, replacing a derivative by a finite difference. Propagation error is the transmission of input errors through a computation.

A problem is well-conditioned if small input changes produce small output changes. A problem is ill-conditioned if small input changes can produce large output changes. Conditioning belongs primarily to the mathematical problem, whereas stability describes how an algorithm behaves in finite-precision arithmetic. A stable algorithm can still produce poor results for an intrinsically ill-conditioned problem.

For a scalar function y = f(x), a local condition measure is approximately

κ(x) = |x f′(x) / f(x)|

when x and f(x) are nonzero. This measures relative output sensitivity to relative input perturbations. It is not applicable at zero and should not be interpreted as a universal condition number.

A numerical method is convergent if its approximation approaches the exact solution as the step size or iteration error tends to zero. If the error behaves as E ≈ Ch^p, the method has order p, where h is a discretization parameter and C is independent of sufficiently small h. Higher order usually means faster asymptotic reduction of truncation error, but not necessarily better performance for every problem because round-off and stability also matter.

2. Nonlinear equations

A nonlinear equation is written as

f(x) = 0

where f is nonlinear in x. Examples include actuator equilibrium, diode equations, friction models, and geometric closure equations.

2.1 Bisection method

Suppose f is continuous on [a,b] and f(a)f(b) < 0. The intermediate value theorem guarantees at least one root in the interval. The midpoint is

c = (a + b) / 2

If f(a)f(c) < 0, replace b by c; otherwise replace a by c. The interval width after n iterations is (b − a)/2ⁿ, and the midpoint error is at most

|x* - cn| ≤ (b - a) / 2^(n+1)

where x* is a root and c_n is the nth midpoint. Bisection is slow but guaranteed under the stated continuity and sign-change conditions. It cannot detect an even-multiplicity root by sign change alone.

2.2 Newton–Raphson method

Starting from x₀, Newton’s iteration is

xk+1 = xk - f(xk) / f′(xk)

It is derived by replacing f locally by its tangent line. Near a simple root x with f′(x) ≠ 0, and with a sufficiently good initial estimate, convergence is usually quadratic: the number of correct digits approximately doubles during the asymptotic phase. Failure can occur when f′(x_k) is zero or small, when the initial value is poor, or when iterates leave the physically meaningful region.

2.3 Secant method

The secant method avoids evaluating f′:

xk+1 = xk - f(xk)(xk - xk-1) / [f(xk) - f(xk-1)]

It generally converges faster than bisection but has no guaranteed bracketing. A robust engineering implementation often combines bisection with Newton or secant steps: retain a bracket, accept a fast step only when it remains safe, and otherwise bisect.

Worked example: solving a nonlinear actuator equation

Consider the illustrative equilibrium equation

f(x) = x³ - x - 2 = 0

The root is known to lie in [1,2], because f(1) = −2 and f(2) = 4. Bisection gives c₁ = 1.5, with f(1.5) = −0.125, so the new bracket is [1.5,2]. The next midpoint is c₂ = 1.75 and f(1.75) = 1.609375, giving [1.5,1.75]. Next, c₃ = 1.625 and f(1.625) ≈ 0.6660, giving [1.5,1.625]. Continuing produces convergence to approximately

x* ≈ 1.52138

The result should be checked by substitution: f(1.52138) is close to zero. The number of iterations should be selected from the required tolerance rather than from an arbitrary number of decimal places.

A practical stopping rule may require both a residual and an step-size condition:

|f(xk)| ≤ εf and |xk - xk-1| ≤ εx(1 + |xk|)

Here ε_f and ε_x are user-selected tolerances. A small step does not always imply a small residual, especially near a flat or poorly scaled function.

3. Interpolation and approximation of data

Interpolation estimates a function between known data points. Given distinct points (x_i,y_i), an interpolating polynomial p(x) satisfies p(x_i) = y_i. Interpolation is appropriate inside the data range; extrapolation outside it can be highly unreliable.

3.1 Lagrange interpolation

For n + 1 data points, the polynomial of degree at most n is

pn(x) = ∑i=0n yi Li(x)

where

Li(x) = ∏j=0, j≠in (x - xj)/(xi - xj)

Distinct x_i values are required. The interpolation error, if f has n + 1 continuous derivatives, is

f(x) - pn(x) = f^(n+1)(ξ)/(n+1)! × ∏i=0n(x - xi)

for some ξ in the interval containing the nodes and x. The error formula explains why node placement matters.

3.2 Newton divided differences

Newton’s form is convenient when data points are added:

pn(x) = f[x0] + f[x0,x1](x-x0) + … + f[x0,…,xn]∏j=0n-1(x-xj)

The divided differences are defined recursively by

f[xi,…,xi+k] = [f[xi+1,…,xi+k] - f[xi,…,xi+k-1]]/(xi+k-xi)

For equally spaced points, finite-difference forms are efficient. High-degree global polynomials may oscillate strongly, particularly near interval endpoints (Runge’s phenomenon). Piecewise cubic splines generally provide smoother and more stable approximations for engineering data.

Worked example: linear interpolation

A temperature sensor gives T = 20 °C at t = 2 s and T = 32 °C at t = 5 s. A linear estimate at t = 3 s is

T(3) = 20 + (32 - 20)(3 - 2)/(5 - 2) = 24 °C

The result assumes approximately linear variation over the interval. It does not establish the temperature outside 2–5 s and does not reveal rapid fluctuations between samples.

4. Numerical differentiation and integration

4.1 Finite differences

For equally spaced data with step h, the forward, backward, and central approximations are respectively

f′(x) ≈ [f(x+h)-f(x)]/h
f′(x) ≈ [f(x)-f(x-h)]/h
f′(x) ≈ [f(x+h)-f(x-h)]/(2h)

Taylor expansion shows that forward and backward differences have truncation error O(h), while the central difference has error O(h²), assuming sufficient smoothness. Central differences are usually more accurate but require data on both sides of x. Near a boundary, one-sided formulas are necessary.

Reducing h does not indefinitely improve the result. Subtraction of nearly equal measured or rounded values magnifies noise and round-off. In control applications, numerical differentiation may therefore require filtering, model-based observers, or carefully designed discrete-time differentiators.

4.2 Numerical integration

The composite trapezoidal rule with n equal subintervals, h = (b−a)/n, is

∫ab f(x) dx ≈ h[ f(x0)/2 + ∑i=1n-1f(xi) + f(xn)/2 ]

Its global truncation error is O(h²) for a function with a continuous second derivative. The composite Simpson’s 1/3 rule requires an even n:

∫ab f(x) dx ≈ h/3 [f(x0) + f(xn) + 4∑i oddf(xi) + 2∑i even, 2≤i≤n-2f(xi)]

Its global error is O(h⁴) when f has sufficiently continuous fourth derivative. Simpson’s rule is not automatically superior for discontinuous, noisy, or sharply varying data.

For sampled sensor data, integration can accumulate bias: a small constant offset in acceleration produces a linearly growing velocity error and a quadratically growing position error. Detrending, calibration, filtering, and periodic reference corrections are therefore essential.

5. Linear systems

Many engineering models lead to

A x = b

where A is an n × n coefficient matrix, x is the unknown vector, and b is the known right-hand-side vector. Units must be consistent: rows may represent equations with different physical dimensions only after appropriate scaling or formulation.

5.1 Gaussian elimination

Gaussian elimination transforms A into an upper triangular matrix U. Back substitution then obtains x, beginning with the last equation. Partial pivoting exchanges rows so that the largest available absolute pivot in the current column is used. This reduces the risk of division by a small pivot and generally improves numerical stability.

For a nonsingular dense matrix, direct elimination requires approximately O(n³) arithmetic operations and O(n²) storage. LU factorization writes

P A = L U

where P is a permutation matrix, L is lower triangular, and U is upper triangular. Once the factorization is available, multiple right-hand sides can be solved efficiently.

5.2 Iterative methods

Jacobi and Gauss–Seidel methods are useful for large sparse systems. Splitting A = D + L + U, the Jacobi iteration is

x^(k+1) = D^(-1)[b - (L+U)x^(k)]

Gauss–Seidel uses newly computed components immediately:

x^(k+1) = (D+L)^(-1)[b - Ux^(k)]

Convergence is guaranteed for strictly diagonally dominant matrices under standard conditions; symmetric positive-definite matrices also provide important convergence results for related methods. Iterative methods require a stopping rule based on the residual r = b − Ax, not solely on changes in x.

The residual norm ||r|| measures equation satisfaction, whereas the solution error ||x−x*|| depends also on conditioning. A small residual can coexist with a relatively large solution error when A is ill-conditioned.

Worked example: a two-variable system

Consider

3x + y = 7
x + 2y = 5

From the first equation, y = 7 − 3x. Substitution into the second gives x + 2(7−3x) = 5, so −5x = −9 and x = 1.8. Therefore y = 1.6. Substitution verifies both equations: 3(1.8)+1.6 = 7 and 1.8+2(1.6)=5. In software, elimination with pivoting is preferred over manually forming an inverse A⁻¹; explicitly computing an inverse is usually more expensive and less stable than solving the system directly.

6. Eigenvalue problems

For a square matrix A, an eigenpair satisfies

A v = λ v

where λ is an eigenvalue and nonzero v is its eigenvector. Equivalently, eigenvalues are roots of det(A − λI) = 0, although directly forming the determinant polynomial is generally not the preferred numerical method for large matrices.

In mechatronics, eigenvalues describe natural modes, vibration frequencies, stability, and principal directions. For a continuous-time linear system ẋ = Ax, asymptotic stability requires every eigenvalue of A to have negative real part. For a discrete-time system x_{k+1} = Ax_k, asymptotic stability requires every eigenvalue to satisfy |λ| < 1.

The power method computes the dominant eigenvalue in magnitude. Starting with a vector v₀, repeatedly calculate w_k = Av_k and normalize: v_{k+1} = w_k/||w_k||. If a unique dominant eigenvalue exists and the starting vector has a component in its eigenvector direction, the method converges, often slowly. The Rayleigh quotient

ρ(v) = (vᵀ A v)/(vᵀ v)

is an eigenvalue estimate for real v and symmetric A; for nonsymmetric matrices, the transpose expression still defines a quotient but its interpretation and accuracy require care. QR-based methods are standard general-purpose techniques for computing many eigenvalues.

7. Numerical solution of differential equations

An initial-value problem has the form

y′ = f(t,y), y(t0) = y0

where t is the independent variable and y may be a scalar or vector. For a vector state, f maps time and state to a derivative vector.

7.1 Euler method

With step h, explicit Euler is

yn+1 = yn + h f(tn,yn)

Taylor expansion gives local truncation error O(h²) and global error O(h). Euler is simple but can be inaccurate or unstable for stiff systems.

The implicit Euler method is

yn+1 = yn + h f(tn+1,yn+1)

It requires solving an equation at each step but has better stability for many dissipative problems.

7.2 Runge–Kutta method

The classical fourth-order Runge–Kutta method is

k1 = f(tn,yn)
k2 = f(tn+h/2, yn+hk1/2)
k3 = f(tn+h/2, yn+hk2/2)
k4 = f(tn+h, yn+hk3)
yn+1=yn+h(k1+2k2+2k3+k4)/6

For sufficiently smooth nonstiff problems, its global error is O(h⁴). Adaptive Runge–Kutta methods estimate local error using embedded formulas and adjust h. A solver should limit h when rapid dynamics, discontinuities, or actuator saturation are present.

7.3 Stability

For the test equation y′ = λy, explicit Euler gives y_{n+1} = (1+hλ)y_n. Absolute stability requires

|1 + hλ| < 1

For real negative λ, this becomes −2 < hλ < 0. Thus a physically decaying mode can grow numerically if h is too large. This distinction between physical behavior and numerical behavior is central to simulation reliability.

8. Integrated application: temperature control of a motor

The following is an illustrative case. A motor controller must estimate winding temperature from a first-order thermal model and determine when a protection threshold will be reached. The model is

Cth dT/dt = Ploss - (T-Ta)/Rth

where T is winding temperature in °C, T_a is ambient temperature in °C, P_loss is heat generation in W, R_th is thermal resistance in °C/W, and C_th is thermal capacitance in J/°C. Dimensional consistency follows because C_th dT/dt has units J/°C × °C/s = W, and (T−T_a)/R_th has units W.

Let T_a = 25 °C, R_th = 0.8 °C/W, C_th = 120 J/°C, P_loss = 100 W, and T(0)=30 °C. With h = 1 s, explicit Euler gives

Tn+1=Tn + h[100 - (Tn-25)/0.8]/120

At the first step, the heat-flow term is 100 − 6.25 = 93.75 W, so T₁ = 30 + 93.75/120 = 30.78125 °C. Repeating the calculation estimates the temperature trajectory. The steady-state value is obtained by setting dT/dt = 0:

Tss = Ta + Ploss Rth = 25 + 100(0.8) = 105 °C

If the protection limit is 90 °C, a numerical root finder can solve T(t) − 90 = 0 after the time response has been computed. A smaller step or an adaptive Runge–Kutta method should be used to verify that the predicted crossing time is not a discretization artifact. Sensor bias must also be included in the safety margin; a controller must not treat a computed threshold as exact.

This case illustrates a complete workflow: formulate a dimensionally consistent model, select a time-integration method, assess step-size stability, locate an event by interpolation or root finding, and validate predictions against measured temperature.

9. Method selection and implementation practice

A sound implementation should:

  1. scale variables so coefficients and unknowns have comparable magnitudes;
  2. preserve units and document all conversions;
  3. use pivoting for direct linear solves;
  4. retain residuals, iteration counts, and error estimates;
  5. impose maximum iterations and detect stagnation;
  6. distinguish interpolation from extrapolation;
  7. test step-size or mesh refinement;
  8. compare independent methods when the result controls safety-critical hardware;
  9. use synthetic problems with known solutions for verification;
  10. validate the mathematical model with physical measurements.

In embedded systems, floating-point precision, overflow, underflow, execution time, and sensor noise must be considered. AI-based surrogate models may accelerate repeated computation, but they do not remove the need for numerical verification, domain-of-validity checks, uncertainty bounds, and fail-safe behavior. For safety-related control, unexplained numerical output should never override a physical interlock.

Challenges and limitations

No numerical method is universally best. Bisection is robust but slow; Newton’s method is fast but sensitive to initialization. High-order interpolation can oscillate; splines require appropriate boundary conditions. Differentiation amplifies noise, while integration accumulates bias. Direct linear algebra can be expensive for large systems, and iterative methods may converge slowly or fail without suitable matrix properties. Differential-equation solvers face stiffness, discontinuities, events, and uncertain parameters. Finally, a numerically precise answer can still be physically wrong if the model, data, units, or boundary conditions are wrong.

Chapter Summary

Numerical methods provide practical approximations for nonlinear equations, data interpolation, derivatives, integrals, linear systems, eigenvalue problems, and differential equations. Bisection offers guaranteed convergence under continuity and a sign-change bracket, whereas Newton and secant methods can be faster but require stronger conditions. Lagrange and Newton interpolation estimate values inside a data range; finite differences approximate derivatives; trapezoidal and Simpson rules approximate definite integrals with different orders of accuracy. Gaussian elimination with pivoting is a standard direct solver for linear systems, while iterative methods are valuable for large sparse problems. Eigenvalues reveal modal and stability behavior. Euler and Runge–Kutta methods integrate initial-value problems, but step size must satisfy accuracy and stability requirements. Reliable engineering computation requires error analysis, conditioning assessment, residual checks, dimensional consistency, refinement studies, and validation against physical evidence.

Key Terms

Conditioning: Sensitivity of a mathematical problem’s output to perturbations in its input.

Convergence: Tendency of numerical approximations toward the exact solution as discretization or iteration error decreases.

Interpolation: Estimation of a function between known data points.

Extrapolation: Estimation outside the range of available data.

Truncation error: Error caused by replacing an exact or infinite process with a finite approximation.

Round-off error: Error caused by finite-precision number representation.

Residual: The mismatch r = b − Ax when a computed vector is substituted into a linear system.

Bisection: Bracketing root method that repeatedly halves an interval with a sign change.

Newton–Raphson method: Tangent-based iterative method for solving f(x)=0.

Secant method: Derivative-free root method based on a secant line.

Divided difference: Recursive coefficient used in Newton interpolation.

Finite difference: Approximation of a derivative using function values at separated points.

Quadrature: Numerical approximation of a definite integral.

Pivoting: Row or column interchange used to improve linear-system solution reliability.

Eigenvalue: Scalar λ satisfying Av = λv for a nonzero vector v.

Eigenvector: Nonzero vector associated with an eigenvalue.

Stability: Behavior of an algorithm under perturbations and finite-precision effects.

Stiffness: A differential-equation property requiring very small steps for stability in explicit methods.

Adaptive step size: Automatic adjustment of the integration step according to an error estimate.

Review Questions

Short Answer Questions

  1. Distinguish truncation error from round-off error.
  2. Why does bisection require a sign-changing bracket?
  3. State the order of the composite trapezoidal rule and composite Simpson’s rule.
  4. Why is partial pivoting used in Gaussian elimination?
  5. State the continuous-time eigenvalue condition for asymptotic stability.

Long Answer Questions

  1. Explain bisection, Newton–Raphson, and secant methods, comparing their assumptions, convergence behavior, and engineering use.
  2. Derive the central-difference approximation from Taylor expansions and explain its truncation error.
  3. Explain how conditioning differs from algorithmic stability, using a linear-system example.
  4. Describe polynomial interpolation, divided differences, and the limitations of high-degree global polynomials.
  5. Explain explicit Euler and fourth-order Runge–Kutta methods, including accuracy and stability considerations.

Analytical / Application Questions

  1. Design a robust algorithm to find the temperature threshold crossing in the motor thermal case. Specify bracketing, interpolation, tolerances, and validation checks.
  2. A measured position signal is differentiated twice to estimate acceleration. Analyze the effects of sampling interval, sensor noise, round-off, and filtering, and recommend a method.
  3. For a large sparse model of a robot structure, justify whether a direct factorization, Jacobi/Gauss–Seidel iteration, or an eigenvalue method is appropriate for equilibrium and modal analysis. State the information needed before deciding.

Multiple Choice Questions with Answers

Question 1

Which condition is sufficient for the bisection method to guarantee that a continuous function has at least one root in [a,b]?

A. f′(x) is constant

B. f(a)f(b) < 0

C. f(a)f(b) > 0

D. f′(a)=f′(b)=0

Correct Answer: B. f(a)f(b) < 0

Question 2

The central-difference approximation [f(x+h)−f(x−h)]/(2h) has what truncation order under sufficient smoothness?

A. O(h⁴)

B. O(h³)

C. O(h²)

D. O(h)

Correct Answer: C. O(h²)

Question 3

For the system 3x + y = 7 and x + 2y = 5, what is x?

A. 1.2

B. 1.6

C. 1.8

D. 2.4

Correct Answer: C. 1.8

Question 4

What is the principal purpose of partial pivoting?

A. To increase the matrix dimension

B. To reduce division by small pivots and improve numerical reliability

C. To convert every matrix into a diagonal matrix immediately

D. To eliminate the need for back substitution

Correct Answer: B. To reduce division by small pivots and improve numerical reliability

Question 5

For a continuous-time linear system ẋ = Ax, asymptotic stability requires:

A. All eigenvalues have positive real parts

B. All eigenvalues have zero magnitude

C. All eigenvalues have negative real parts

D. At least one eigenvalue equals one

Correct Answer: C. All eigenvalues have negative real parts

Question 6

The global truncation error of explicit Euler for a sufficiently smooth nonstiff problem is generally:

A. O(h)

B. O(h²)

C. O(h³)

D. O(h⁴)

Correct Answer: A. O(h)

Question 7

The composite Simpson’s 1/3 rule normally requires:

A. An odd number of subintervals

B. An even number of subintervals

C. Exactly one subinterval

D. Unequal subintervals only

Correct Answer: B. An even number of subintervals

Question 8

For y′ = λy, explicit Euler is absolutely stable when:

A. |1+hλ| < 1

B. |hλ| > 1

C. 1+hλ > 2

D. λ = 0 only

Correct Answer: A. |1+hλ| < 1

Question 9

Which operation most directly amplifies high-frequency measurement noise?

A. Numerical integration

B. Numerical differentiation

C. Linear interpolation over a constant signal

D. Unit conversion

Correct Answer: B. Numerical differentiation

Question 10

For a discrete-time system x_{k+1}=Ax_k, asymptotic stability requires:

A. Every eigenvalue has magnitude less than 1

B. Every eigenvalue has positive real part

C. At least one eigenvalue has magnitude greater than 1

D. The trace of A equals zero

Correct Answer: A. Every eigenvalue has magnitude less than 1

Engineering Mathematics III
Chapter 12 of 15