Applied Mathematics

Chapter 11
Numerical Methods and Scientific Computing

Bachelors Program in Machine Technology
Applied Mathematics   •   Bachelor

Numerical Methods and Scientific Computing

Introduction and Context

Many engineering and manufacturing problems cannot be solved conveniently, or at all, by closed-form algebra. The dimensions of a machine component may be determined by a nonlinear equation; sensor data may require interpolation; experimental results may be represented by a regression model; and the temperature of a tool or workpiece may vary according to an ordinary or partial differential equation. Numerical methods provide systematic approximations to such problems.

A numerical method replaces a continuous or exact mathematical problem by a finite sequence of arithmetic operations. Its usefulness depends not only on obtaining a number, but also on knowing whether the number is accurate, whether the algorithm converges, and whether rounding or measurement errors have been amplified. Scientific computing combines numerical analysis with algorithms, data structures, software, and visualization.

In machine technology, numerical methods support computer-aided engineering, CNC parameter selection, vibration analysis, thermal modelling, calibration, condition monitoring, and optimization.

Learning Objectives

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

  1. Formulate engineering problems for numerical solution.
  2. Apply bisection, Newton–Raphson, and secant methods to nonlinear equations.
  3. Use interpolation and least-squares regression appropriately.
  4. Approximate derivatives and definite integrals and estimate errors.
  5. Solve linear systems using direct and iterative methods.
  6. Apply basic numerical methods for ordinary and partial differential equations.
  7. Explain consistency, convergence, stability, conditioning, and round-off error.
  8. Implement and verify numerical algorithms using suitable software.

1. Numerical Representation, Error, and Conditioning

Let x be the exact value and x̃ 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%. In engineering calculations, the exact value is often unavailable, so an estimated relative error based on successive approximations is used:

Ea,est = |x(k) − x(k−1)|
Er,est = |x(k) − x(k−1)| / |x(k)|

These estimates are meaningful when the iteration is converging normally.

Errors have several sources:

  • Modelling error: simplification of the physical system.
  • Data or measurement error: uncertainty in input quantities.
  • Truncation error: replacing an infinite process by a finite one, such as replacing a derivative by a finite difference.
  • Round-off error: finite-precision representation and arithmetic.
  • Programming error: an incorrect algorithm or implementation.

A problem is well-conditioned if small changes in input produce small changes in output. An ill-conditioned problem may produce large output changes even when the algorithm is correct. The condition number expresses this sensitivity. For a scalar function y = f(x), a local relative condition measure is approximately

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

where f(x) and x are nonzero. This expression is a sensitivity indicator, not a universal definition for every problem.

A numerical algorithm is stable if it does not substantially magnify unavoidable errors. Stability concerns the algorithm; conditioning concerns the mathematical problem.

2. Root Finding for Nonlinear Equations

A root of f(x) is a value r satisfying

f(r) = 0

Root finding is used for force equilibrium, power-law calibration, geometric design, and process constraints. Before applying an algorithm, identify a physically meaningful domain and inspect the function for discontinuities.

2.1 Bisection Method

If f is continuous on [a,b] and

f(a)f(b) < 0

then the intermediate value theorem guarantees at least one root in (a,b). The bisection method repeatedly sets

c = (a + b)/2

and retains the half-interval in which a sign change remains. After n bisections, the interval width is (b − a)/2ⁿ. If the midpoint is used as the approximation, a conservative error bound is

|r − cn| ≤ (b − a)/2n+1

Bisection is guaranteed to converge under the stated continuity and sign-change conditions, but convergence is only linear.

2.2 Newton–Raphson Method

Newton's method uses the tangent at x_k:

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

It requires a differentiable function and a nonzero derivative near each iteration. If the initial estimate is sufficiently close to a simple root and f is sufficiently smooth, convergence is usually quadratic. It can fail when f′ is zero or small, when the initial estimate is poor, or when an iteration leaves the physically valid domain.

2.3 Secant Method

The secant method avoids an analytical derivative by approximating it with two previous points:

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

The denominator must not be zero. The method is generally faster than bisection but lacks its guaranteed bracketing property.

Worked Example: A Nonlinear Design Equation

Suppose a simplified actuator model requires solving

f(x) = x2 − 2 = 0

The positive root is √2. Use Newton's method with x₀ = 1.5. Since f′(x) = 2x,

x₁ = 1.5 − (1.5² − 2)/(2 × 1.5) = 1.4166667

The next iteration is

x₂ = 1.4166667 − (1.4166667² − 2)/(2 × 1.4166667) ≈ 1.4142157

A further iteration gives x₃ ≈ 1.4142136. Thus the computed root is approximately 1.4142136, with an estimated change of about 2.1 × 10⁻⁶ between x₂ and x₃. A stopping rule should combine a maximum iteration count with a tolerance such as |f(x_k)| ≤ 10⁻⁸ or a suitably scaled relative change.

3. Interpolation and Regression

Interpolation estimates a value between known data points. Regression estimates a relationship that may include measurement noise and need not pass through every observation. Confusing these purposes can produce misleading engineering conclusions.

3.1 Linear Interpolation

For data points (x₀,y₀) and (x₁,y₁), with x between x₀ and x₁,

y(x) = y₀ + [(y₁ − y₀)/(x₁ − x₀)](x − x₀)

The method assumes a nearly linear relationship over the interval. Extrapolation beyond the data range is substantially less reliable.

3.2 Polynomial Interpolation

The Lagrange polynomial through n+1 distinct points is

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

where

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

For a sufficiently smooth function, the interpolation remainder is

Rn(x) = f(n+1)(ξ)/(n+1)! × ∏i=0n(x − xi)

for some ξ within an interval containing the nodes and x. High-degree polynomial interpolation at equally spaced points can oscillate strongly near endpoints (Runge's phenomenon). Piecewise linear or cubic-spline interpolation is often safer.

3.3 Least-Squares Linear Regression

For observations (x_i,y_i), i = 1,…,n, the model y = a + bx minimizes

S(a,b) = ∑i=1n[yi − (a + bxi)]²

The coefficients are

b = [n∑xi yi − (∑xi)(∑yi)]/[n∑xi² − (∑xi)²]
a = ȳ − b x̄

where x̄ and ȳ are sample means. The coefficient of determination is

R² = 1 − [∑(yi − ŷi)²]/[∑(yi − ȳ)²]

provided the denominator is nonzero. A high R² does not prove causation, physical validity, or safe extrapolation. Residual plots, dimensional reasoning, and validation data are also necessary.

4. Numerical Differentiation and Integration

4.1 Finite Differences

For step size 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)

For a smooth function, forward and backward differences have truncation error O(h), while the central difference has error O(h²). Decreasing h indefinitely is not always beneficial because round-off error becomes more influential. A practical computation tests several h values and looks for a stable range.

4.2 Composite Trapezoidal Rule

For n equal subintervals of width h = (b−a)/n,

∫ab f(x) dx ≈ h[½f(a) + ∑i=1n−1f(a+ih) + ½f(b)]

For a function with continuous second derivative, the global truncation error is O(h²). The integral has the units of f multiplied by the units of x.

4.3 Composite Simpson's Rule

When n is even,

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

where h = (b−a)/n. For sufficiently smooth f, the global error is O(h⁴). Simpson's rule is not applicable in this standard form when n is odd.

Worked Example: Trapezoidal Integration

To approximate ∫₀² x² dx using n = 2, h = 1 and values f(0)=0, f(1)=1, f(2)=4:

IT = 1[½(0) + 1 + ½(4)] = 3

The exact integral is 8/3 ≈ 2.6667, so the absolute error is approximately 0.3333. With Simpson's rule,

IS = (1/3)[0 + 4 + 4(1)] = 8/3

which is exact here because Simpson's rule integrates quadratic polynomials exactly.

5. Linear Systems

Many discretized engineering models have the form

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. A unique solution exists when det(A) ≠ 0, although calculating a determinant is not generally the preferred numerical test.

5.1 Gaussian Elimination

Gaussian elimination transforms A into an upper-triangular matrix, followed by back substitution. Partial pivoting exchanges rows so that a suitably large pivot is used. Pivoting reduces numerical error and is standard practice unless the matrix has special structure.

For a 2 × 2 system,

2x + y = 5
x − y = 1

adding the second equation to the first after expressing x = 1 + y gives 2(1+y)+y=5, hence 3y=3 and y=1, x=2. A software implementation should verify the residual r = b − Ax rather than relying only on displayed digits.

5.2 LU Factorization

LU factorization writes A = LU, possibly with row permutation P so that PA = LU, where L is lower triangular and U is upper triangular. The system is solved by forward substitution Ly = Pb followed by backward substitution Ux = y. LU is efficient when several right-hand sides use the same A.

5.3 Iterative Methods

Jacobi and Gauss–Seidel methods rewrite each equation in terms of one variable and repeatedly update estimates. For a system with diagonal entries a_ii,

xi(k+1) = [bi − ∑j≠iaijxj(k)]/aii

is the Jacobi update. Gauss–Seidel uses newly computed values immediately. Convergence is guaranteed for important classes such as strictly diagonally dominant matrices; otherwise it must be analysed rather than assumed. Iterative methods are particularly useful for large sparse systems.

6. Numerical Ordinary Differential Equations

An initial-value problem is

y′ = f(t,y), y(t₀) = y₀

where t may represent time and y may be a scalar or vector state.

6.1 Euler's Method

With time step h,

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

Euler's method has local truncation error O(h²) and global error O(h), assuming adequate smoothness. It is simple but may be inaccurate or unstable for stiff systems.

6.2 Runge–Kutta Method

The classical fourth-order method is

k₁ = f(tn,yn)
k₂ = f(tn+h/2, yn+hk₁/2)
k₃ = f(tn+h/2, yn+hk₂/2)
k₄ = f(tn+h, yn+hk₃)
yn+1 = yn + h(k₁ + 2k₂ + 2k₃ + k₄)/6

For smooth nonstiff problems, its global error is O(h⁴). Adaptive software commonly compares solutions at different step sizes to control local error.

Stability

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

|1 + hλ| < 1

for this scalar test problem. This illustrates that a smaller step may be necessary for stability even when accuracy appears adequate. In physical simulation, an unstable numerical solution can grow although the real system decays.

7. Numerical Partial Differential Equations

A PDE describes a field depending on several independent variables. A one-dimensional heat equation is

∂u/∂t = α ∂²u/∂x²

where u(x,t) is temperature and α is thermal diffusivity with units m²/s. With spatial spacing ∆x and time spacing ∆t, the explicit forward-time central-space scheme is

uin+1 = uin + r(ui+1n − 2uin + ui−1n)

where

r = α∆t/(∆x)²

For the standard one-dimensional explicit heat equation scheme, stability requires r ≤ 1/2 under the usual assumptions of a uniform grid and constant positive α. Boundary and initial conditions must be specified. Implicit schemes, such as backward Euler or Crank–Nicolson, require solving a linear system but permit less restrictive stability conditions; accuracy and oscillation behaviour still require analysis.

Finite-difference methods approximate derivatives on a grid. Finite-element methods instead approximate the field using local basis functions and are well suited to irregular geometry and structural mechanics. Mesh refinement can improve accuracy but increases computational cost and may expose poorly conditioned systems.

8. Scientific Computing Practice

A reliable workflow is:

  1. Define the physical problem, variables, units, domain, and assumptions.
  2. Scale variables where possible to reduce extreme magnitudes.
  3. Select a method consistent with smoothness, boundary conditions, sparsity, and stiffness.
  4. Implement using vectorized, modular, documented code.
  5. Test against an exact solution, manufactured solution, limiting case, or trusted benchmark.
  6. Perform grid, step-size, tolerance, and residual studies.
  7. Report significant figures justified by input uncertainty and numerical error.
  8. Preserve code, input data, software versions, and solver settings for reproducibility.

Python with NumPy, SciPy, and Matplotlib; MATLAB; GNU Octave; and engineering packages are common choices. A solver's output should not be accepted merely because it looks smooth. Residuals, conservation laws, boundary conditions, and sensitivity to discretization must be checked.

AI-assisted coding can accelerate implementation, but generated code may contain incorrect indexing, unstable schemes, unit errors, or inappropriate stopping criteria. Engineers remain responsible for verification, validation, documentation, and safety decisions. In regulated or safety-critical work, version control, review, traceability, and approved computational procedures are essential.

Applied Case: Thermal Control of a Machining Tool

Background

Consider an illustrative case in which a cutting tool is approximated as a one-dimensional bar. Heat enters at the cutting edge, while the remaining boundary is cooled. The temperature field is represented by the heat equation with known thermal diffusivity.

Problem

The engineer must predict whether the tool exceeds a maximum allowable temperature during a short cutting cycle. The model requires initial temperature, boundary conditions, material properties, grid spacing, and time duration.

Analysis and Approach

The engineer discretizes the bar using ∆x = 0.005 m and selects ∆t so that r = α∆t/(∆x)² ≤ 0.5. The explicit finite-difference scheme is implemented. At each time step, boundary values are imposed and interior temperatures are updated. A second simulation uses half the spatial spacing and a suitably reduced time step.

Outcome

Suppose the coarse and refined meshes predict peak temperatures of 186 °C and 189 °C. The difference is approximately 3 °C, or about 1.6% relative to the refined result. If the safety limit is 200 °C, the prediction appears acceptable, but uncertainty in heat generation and convection must also be considered. If refinement produces a large change, the original grid is inadequate.

Learning Points

The case demonstrates that a numerical result is not complete without a stability check, mesh-convergence study, unit verification, and comparison with physical uncertainty. A stable calculation can still be inaccurate if the model or boundary conditions are wrong.

Challenges, Limitations, and Best Practices

Numerical methods approximate both mathematics and reality. Discretization error may be reduced by refinement, but refinement increases memory and computation time. Round-off may dominate at excessively small step sizes. Nonlinear equations may have multiple roots, and an algorithm may converge to an undesired one. Regression may encode biased measurements. PDE models may be sensitive to boundary conditions and material properties.

Best practice includes bracketing roots when possible, using pivoting in elimination, scaling poorly sized equations, monitoring residuals, selecting tolerances related to engineering requirements, and reporting uncertainty rather than excessive digits. Results should be reviewed by an appropriately qualified person when they influence safety, compliance, or expensive production decisions.

Chapter Summary

Numerical methods convert engineering problems into computable approximations. Root-finding methods include guaranteed but slower bisection and faster Newton–Raphson or secant methods. Interpolation estimates values between observations, whereas regression estimates noisy relationships through an objective such as least squares. Finite differences approximate derivatives, while trapezoidal and Simpson rules approximate integrals with different accuracy orders. Linear systems can be solved by pivoted elimination, LU factorization, or iterative methods. Euler and Runge–Kutta methods solve initial-value ODEs, while finite-difference and finite-element methods support PDE simulation. Convergence, stability, conditioning, residuals, truncation error, and round-off error must be assessed systematically. Reliable scientific computing combines mathematical analysis, appropriate software, verification, validation, and responsible engineering judgement.

Key Terms

Error: Difference between an exact or reference value and an approximation.

Relative error: Absolute error divided by the magnitude of the exact value.

Truncation error: Error caused by terminating an infinite mathematical process.

Round-off error: Error caused by finite-precision arithmetic.

Conditioning: Sensitivity of a mathematical problem to input perturbations.

Stability: Resistance of an algorithm to amplification of errors.

Root: A value r for which f(r)=0.

Bisection: Bracketing root method based on repeated interval halving.

Newton–Raphson method: Tangent-based iterative root solver.

Interpolation: Estimation within the range of known data.

Regression: Estimation of a relationship from possibly noisy observations.

Residual: Difference remaining when an approximate solution is substituted into an equation.

Finite difference: Derivative approximation using values at discrete points.

Trapezoidal rule: Numerical integration method based on linear segments.

Simpson's rule: Integration method using quadratic approximations.

LU factorization: Decomposition of a matrix into lower- and upper-triangular factors.

Convergence: Tendency of numerical approximations toward the desired solution.

Stiffness: ODE property requiring restrictive step sizes for explicit stability.

Finite-difference grid: Discrete set of points used to approximate a field equation.

Verification: Checking whether a computation correctly implements its intended model.

Review Questions

Short Answer Questions

  1. Distinguish truncation error from round-off error.
  2. State the condition that guarantees a root is bracketed for bisection.
  3. Why is extrapolation generally less reliable than interpolation?
  4. What is the purpose of partial pivoting in Gaussian elimination?
  5. Define the residual of an approximate linear-system solution.

Long Answer Questions

  1. Explain bisection, Newton–Raphson, and secant methods, including their assumptions, advantages, and failure modes.
  2. Derive the composite trapezoidal rule conceptually and compare its accuracy with Simpson's rule.
  3. Explain conditioning and stability and show why they are different properties.
  4. Describe a reliable workflow for solving and validating an engineering ODE numerically.
  5. Compare explicit finite-difference and finite-element approaches for PDE simulation.

Analytical / Application Questions

  1. Use Newton's method to solve x³ − 5x + 1 = 0 from a specified initial estimate, and report a residual and stopping criterion.
  2. A temperature sensor provides irregularly spaced measurements. Decide whether interpolation or regression is more appropriate for estimating a missing value, and justify the decision.
  3. Design a mesh-refinement and time-step study for a one-dimensional heat-conduction model. Specify the quantities that should be compared before accepting the result.

Multiple Choice Questions with Answers

Question 1

Which condition guarantees at least one root in [a,b] for a continuous function?

A. f(a) = f(b)

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

C. f′(a)f′(b) < 0

D. a and b are both positive

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

Question 2

What is the Newton–Raphson iteration for f(x)=0?

A. x_{k+1}=x_k+f(x_k)

B. x_{k+1}=x_k−f′(x_k)/f(x_k)

C. x_{k+1}=x_k−f(x_k)/f′(x_k)

D. x_{k+1}=f(x_k)/x_k

Correct Answer: C. x_{k+1}=x_k−f(x_k)/f′(x_k)

Question 3

For a smooth function, the central finite-difference approximation shown in the chapter has truncation error of what order?

A. O(h)

B. O(h²)

C. O(h³)

D. O(1/h)

Correct Answer: B. O(h²)

Question 4

In the standard composite Simpson's rule, the number of subintervals must be:

A. Odd

B. Even

C. Prime

D. At least three

Correct Answer: B. Even

Question 5

What does partial pivoting primarily reduce?

A. The number of unknowns

B. Measurement uncertainty

C. Numerical error caused by poor pivots

D. The physical dimensions of the system

Correct Answer: C. Numerical error caused by poor pivots

Question 6

For Euler's method applied to y′=f(t,y), which update is correct?

A. y_{n+1}=y_n+h f(t_n,y_n)

B. y_{n+1}=y_n+f(t_n,y_n)/h

C. y_{n+1}=h y_n+f(t_n,y_n)

D. y_{n+1}=y_n−h f(t_n,y_n)

Correct Answer: A. y_{n+1}=y_n+h f(t_n,y_n)

Question 7

For the explicit one-dimensional heat-equation scheme, r=α∆t/(∆x)² must satisfy which standard stability condition?

A. r≥2

B. r=1

C. r≤1/2

D. r<−1

Correct Answer: C. r≤1/2

Question 8

Which statement best distinguishes interpolation from regression?

A. Interpolation always uses derivatives

B. Regression is intended to represent noisy data and need not pass through every point

C. Interpolation can only be used for linear data

D. Regression cannot be used for prediction

Correct Answer: B. Regression is intended to represent noisy data and need not pass through every point

Question 9

If an approximate solution x is obtained for Ax=b, which quantity is the residual?

A. Ax

B. A+b

C. b−Ax

D. x−b

Correct Answer: C. b−Ax

Question 10

Which statement about decreasing a numerical step size is correct?

A. It always decreases total error

B. It can reduce truncation error but eventually round-off may become important

C. It makes every method unconditionally stable

D. It removes modelling error

Correct Answer: B. It can reduce truncation error but eventually round-off may become important

Applied Mathematics
Chapter 11 of 15