Engineering Mathematics for NM: Numerical Differentiation, and the Exact and Bernoulli Equations

The Naval Architecture and Marine Engineering (NM) paper’s Section 1 names two things the shared Engineering Mathematics chapters do not teach, and this chapter is written for exactly those two. The first is numerical methods for differentiation: the shared Numerical Methods chapter integrates by the trapezoidal and Simpson rules but never differentiates a table, so the forward, backward and central difference formulas, their truncation errors, the second-derivative formula, the Newton forward-difference derivative and Richardson extrapolation are here. The second is the non-linear half of "linear, non-linear, first and higher order ordinary differential equations": the borrowed first-order chapter teaches the separable, homogeneous and linear forms, so the exact equation, its integrating factors and the Bernoulli equation, which a substitution turns linear, are here too. Everything else in the NM Section 1 list is in the shared chapters. Both topics are small, quick and reliably examinable: a difference quotient on three tabulated values, or a test for exactness, is a one-mark question that costs a minute.
Overview

1. Difference formulas from the Taylor series

1 min read · 2 parts

Every numerical-differentiation formula is a truncated Taylor series. Writing f(x + h) = f(x) + hf′(x) + (h²/2)f″(x) + (h³/6)f‴(x) + … and solving for f′ gives the forward difference f′(x) ≈ [f(x + h) − f(x)]/h, whose leading error is −(h/2)f″(ξ): first order, O(h). Expanding f(x − h) instead gives the backward difference [f(x) − f(x − h)]/h, also O(h). Subtracting the two expansions cancels the f″ terms and leaves the central difference f′(x) ≈ [f(x + h) − f(x − h)]/(2h), whose leading error is −(h²/6)f‴(ξ): second order, O(h²). Adding them cancels f′ and gives the second-derivative formula f″(x) ≈ [f(x + h) − 2f(x) + f(x − h)]/h², also O(h²), with leading error −(h²/12)f⁗.

The four formulas and their errors
FormulaExpressionTruncation error
Forward difference[f(x + h) − f(x)]/h−(h/2)f″, order h
Backward difference[f(x) − f(x − h)]/h+(h/2)f″, order h
Central difference[f(x + h) − f(x − h)]/(2h)−(h²/6)f‴, order h²
Second derivative[f(x + h) − 2f(x) + f(x − h)]/h²−(h²/12)f⁗, order h²
🧠 Check the formula on a function whose derivative you know
For f(x) = x³ at x = 1 with h = 0.1: forward gives (1.331 − 1)/0.1 = 3.31, central gives (1.331 − 0.729)/0.2 = 3.01, and the exact value is 3. The forward error 0.31 is close to (h/2)f″ = 0.05 × 6 = 0.3; the central error 0.01 is exactly (h²/6)f‴ = 0.01 × 6/6 = 0.01, because the Taylor series of a cubic stops at the third term.

Every numerical-differentiation formula is a truncated Taylor series. Writing f(x + h) = f(x) + hf′(x) + (h²/2)f″(x) + (h³/6)f‴(x) + … and solving for f′ gives the forward difference f′(x)…

2. Differentiating a table: Newton’s formula and Richardson extrapolation

1 min read · 2 parts

When f is known only at equally spaced points x₀, x₀ + h, x₀ + 2h, …, build the forward-difference table Δf₀ = f₁ − f₀, Δ²f₀ = Δf₁ − Δf₀, and so on. Differentiating Newton’s forward interpolation polynomial at x₀ gives f′(x₀) ≈ (1/h)[Δf₀ − Δ²f₀/2 + Δ³f₀/3 − Δ⁴f₀/4 + …]. Keeping only the first term is the forward difference; each further term raises the order. If the data come from a polynomial of degree n, the nth differences are constant and the (n + 1)th vanish, so the series terminates and the derivative is exact.

Richardson extrapolation removes the leading error term by combining two step sizes. If D(h) has error ch², then D(h/2) has error ch²/4, and eliminating c gives the improved estimate D = [4D(h/2) − D(h)]/3, of order h⁴. For a first-order formula (error ch) the combination is 2D(h/2) − D(h). The same idea applied to the trapezoidal rule is Romberg integration.

⚠️ A smaller step is not always better
Truncation error falls as h shrinks, but the round-off error in f(x + h) − f(x), divided by h, grows as 1/h. The total error therefore has a minimum at an optimum step, below which the answer gets worse. A question asking what happens as h → 0 on a computer with finite precision wants this answer, not "the error goes to zero".

When f is known only at equally spaced points x₀, x₀ + h, x₀ + 2h, …, build the forward-difference table Δf₀ = f₁ − f₀, Δ²f₀ = Δf₁ − Δf₀, and so on. Differentiating Newton’s forward…

3. Exact equations and integrating factors

1 min read · 1 part

The first-order equation M(x, y) dx + N(x, y) dy = 0 is exact when its left side is the total differential of some function u(x, y), which happens exactly when ∂M/∂y = ∂N/∂x (on a simply connected region). The solution is u(x, y) = C, found by integrating M with respect to x (holding y constant), then adding the terms of N that contain no x. For (2xy + 3) dx + (x² + 4y) dy = 0: ∂M/∂y = 2x = ∂N/∂x, so it is exact; ∫M dx = x²y + 3x, and N contributes the y-only term 4y, whose integral is 2y². The solution is x²y + 3x + 2y² = C.

An equation that is not exact can often be made so by an integrating factor μ. If (∂M/∂y − ∂N/∂x)/N is a function of x alone, μ = exp∫[(∂M/∂y − ∂N/∂x)/N] dx; if (∂N/∂x − ∂M/∂y)/M is a function of y alone, μ = exp∫[(∂N/∂x − ∂M/∂y)/M] dy. Some forms are recognised on sight: y dx − x dy is made exact by 1/x², 1/y² or 1/(xy), giving −d(y/x), d(x/y) and d(ln x − ln y) respectively. The linear equation dy/dx + Py = Q is the special case whose integrating factor is e∫P dx.

⚠️ Test exactness with the cross-derivatives, not the same-variable ones
The test is ∂M/∂y against ∂N/∂x — M is differentiated by y and N by x. Comparing ∂M/∂x with ∂N/∂y is the commonest slip and proves nothing.

The first-order equation M(x, y) dx + N(x, y) dy = 0 is exact when its left side is the total differential of some function u(x, y), which happens exactly when ∂M/∂y = ∂N/∂x (on a simply…

4. The Bernoulli equation

1 min read

The Bernoulli equation dy/dx + P(x)y = Q(x)yⁿ is non-linear for n ≠ 0, 1, but the substitution v = y1−n makes it linear: dividing by yⁿ and using dv/dx = (1 − n)y−n dy/dx gives dv/dx + (1 − n)P v = (1 − n)Q, solved by the integrating factor e(1−n)∫P dx. For n = 0 it is already linear and for n = 1 it is separable, which is why those two are excluded.

Worked example, the logistic equation dy/dx = y − y², that is dy/dx − y = −y² (n = 2). With v = 1/y: dv/dx + v = 1, so v = 1 + Ce−x. If y(0) = 0.5 then v(0) = 2 and C = 1, so y = 1/(1 + e−x), which rises from 0.5 towards 1; at x = ln 2 it is 1/(1 + 0.5) = 0.667.

  • Identify n from the power of y on the right; the substitution is v = y1−n, not v = yⁿ.
  • After substituting, the coefficient of v is (1 − n)P and the right side is (1 − n)Q; forgetting the factor (1 − n) is the usual error.
  • Convert the initial condition to v before finding the constant, then convert back to y at the end.

The Bernoulli equation dy/dx + P(x)y = Q(x)yⁿ is non-linear for n ≠ 0, 1, but the substitution v = y1−n makes it linear: dividing by yⁿ and using dv/dx = (1 − n)y−n dy/dx gives dv/dx + (1 −…

5. Where the rest of NM Section 1 is taught

1 min read · 2 parts
NM Section 1, mapped onto the chapters that teach it
Syllabus wordingWhere it is taught
Determinants and matrices, systems of linear equations, eigen values and eigen vectorsLinear Algebra chapter
Functions, definite and indefinite integralsThe borrowed single-variable calculus chapters
Chain rules, partial and directional derivatives, gradient, divergence, curl, line, surface and volume integrals, Stokes, Gauss and GreenMultivariable Calculus and Vector Calculus chapters
First-order linear equations; higher-order ODEs, PDEs, separation of variables, Laplace transformationThe borrowed first-order chapter and the Differential Equations chapter
Fourier seriesThe first section of the Transforms chapter only
Analytical functions of complex variables, complex analysisComplex Variables chapter
Numerical integration; probability and statisticsNumerical Methods (its quadrature section) and Probability and Statistics chapters
Numerical differentiation; exact and Bernoulli equationsThis chapter
ℹ️ Numerical integration in hydrostatics
Naval architecture integrates offsets with Simpson’s rules — waterplane areas, sectional areas, volumes and moments. The quadrature itself is taught in the shared Numerical Methods chapter; its use on half-breadths is in the NM naval architecture chapter.

Key takeaways

  • Forward and backward differences are first order (error −(h/2)f″ and +(h/2)f″); the central difference is second order (error −(h²/6)f‴).
  • f″ ≈ [f(x + h) − 2f(x) + f(x − h)]/h², second order; from a table, f′(x₀) ≈ (1/h)[Δ − Δ²/2 + Δ³/3 − …].
  • Richardson for an h² method: D = [4D(h/2) − D(h)]/3; round-off makes a very small h worse, not better.
  • M dx + N dy = 0 is exact iff ∂M/∂y = ∂N/∂x; y dx − x dy takes 1/x², 1/y² or 1/(xy) as an integrating factor.
  • Bernoulli dy/dx + Py = Qyⁿ: put v = y1−n to get dv/dx + (1 − n)Pv = (1 − n)Q.

Practice questions (24)

Attempt each one before opening the answer. Every explanation names the tempting wrong option as well as the right one, because that is where marks are lost.

  1. The truncation error of the central difference approximation f′(x) ≈ [f(x + h) − f(x − h)]/(2h) is of order

    1. h²
    2. h
    3. h³
    4. h⁴
    Show answer

    Answer: A — h²

    Subtracting the Taylor expansions of f(x + h) and f(x − h) cancels the even-order terms, so the leading error is −(h²/6)f‴: order h². The one-sided forward and backward differences are order h; order h⁴ needs Richardson extrapolation or a five-point formula.
  2. For f(x) = x³, the forward-difference estimate of f′(1) with h = 0.1, to two decimal places, is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 3.31

    [f(1.1) − f(1)]/0.1 = (1.331 − 1)/0.1 = 3.31, against the exact 3. The error 0.31 is roughly (h/2)f″(1) = 0.05 × 6 = 0.3, as the first-order error term predicts. The central difference would give 3.01.
  3. For f(x) = x⁴, the central-difference estimate of the second derivative at x = 1 with h = 0.1, to two decimal places, is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 12.02

    [f(1.1) − 2f(1) + f(0.9)]/h² = (1.4641 − 2 + 0.6561)/0.01 = 0.1202/0.01 = 12.02, against the exact f″(1) = 12. The error 0.02 equals (h²/12)f⁗ = (0.01/12) × 24 = 0.02, the formula’s leading error term.
Show the other 21 questions
  1. Central-difference estimates of f′(1) for f(x) = x³ are 3.04 with h = 0.2 and 3.01 with h = 0.1. The Richardson-extrapolated estimate, to two decimal places, is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 3

    The central difference has error ch², so D = [4D(h/2) − D(h)]/3 = (4 × 3.01 − 3.04)/3 = (12.04 − 3.04)/3 = 3.00, the exact value. Averaging the two estimates gives 3.025; using the first-order combination 2D(h/2) − D(h) gives 2.98.
  2. A function is tabulated at x = 0, 1, 2, 3 as f = 2, 5, 10, 17. Using Newton’s forward-difference formula for the derivative, f′(0) is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 2

    First differences 3, 5, 7; second differences 2, 2; third difference 0. With h = 1, f′(0) = Δf₀ − Δ²f₀/2 + Δ³f₀/3 = 3 − 1 + 0 = 2. The data are f = x² + 2x + 2, whose derivative at 0 is exactly 2. Stopping at the first difference gives 3.
  3. Which statements about numerical differentiation are correct?

    1. halving h roughly halves the truncation error of the forward difference
    2. halving h roughly quarters the truncation error of the central difference
    3. round-off error grows as h becomes very small
    4. the central difference is exact for every cubic polynomial
    Show answer

    Answer: A — halving h roughly halves the truncation error of the forward difference; B — halving h roughly quarters the truncation error of the central difference; C — round-off error grows as h becomes very small

    Forward error is proportional to h and central error to h², so halving h halves one and quarters the other; the subtraction f(x + h) − f(x) loses significant digits as h shrinks, so round-off grows like 1/h. The central difference is exact only up to quadratics: for a cubic its error is (h²/6)f‴, a non-zero constant.
  4. The general solution of the exact equation (2xy + 3) dx + (x² + 4y) dy = 0 is

    1. x²y + 3x + 2y² = C
    2. x²y + 3x + 4y² = C
    3. 2xy + 3x + 2y² = C
    4. x²y + 3y + 2x² = C
    Show answer

    Answer: A — x²y + 3x + 2y² = C

    ∂M/∂y = 2x = ∂N/∂x, so it is exact. Integrating M in x gives x²y + 3x; the only term of N free of x is 4y, which integrates to 2y². Writing 4y² forgets to integrate, and 2xy + … keeps M instead of its integral.
  5. The equation (3x²y + ky²) dx + (x³ + 4xy) dy = 0 is exact for k = ____.

    Numerical answer — type the value.

    Show answer

    Answer: 2

    ∂M/∂y = 3x² + 2ky and ∂N/∂x = 3x² + 4y; equal for all x and y when 2k = 4, so k = 2. Comparing ∂M/∂x with ∂N/∂y instead compares 6xy with 4x and gives no constant k at all.
  6. Which of the following are integrating factors of y dx − x dy = 0?

    1. 1/x²
    2. 1/y²
    3. 1/(xy)
    4. 1/(x + y)
    Show answer

    Answer: A — 1/x²; B — 1/y²; C — 1/(xy)

    Multiplying by 1/x² gives (y/x²) dx − (1/x) dy = −d(y/x); by 1/y², (1/y) dx − (x/y²) dy = d(x/y); by 1/(xy), dx/x − dy/y = d(ln x − ln y). With 1/(x + y), ∂M/∂y = x/(x + y)² but ∂N/∂x = −y/(x + y)², which differ, so it is not an integrating factor.
  7. The Bernoulli equation dy/dx + y = xy³ becomes linear under the substitution

    1. v = y⁻²
    2. v = y³
    3. v = y⁻³
    4. v = y²
    Show answer

    Answer: A — v = y⁻²

    With n = 3 the substitution is v = y1−n = y−2, giving dv/dx − 2v = −2x, which is linear. Using v = yⁿ = y³ or v = y−n = y−3 does not cancel the non-linearity; v = y² has the right magnitude of exponent but the wrong sign.
  8. The solution of dy/dx = y − y² with y(0) = 0.5, evaluated at x = ln 2, to three decimal places, is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 0.667

    Bernoulli with n = 2: v = 1/y gives dv/dx + v = 1, so v = 1 + Ce−x; v(0) = 2 gives C = 1. At x = ln 2, v = 1 + 1/2 = 1.5 and y = 1/1.5 = 0.667. Leaving the answer as v = 1.5 forgets to convert back to y.
  9. For the Bernoulli equation dy/dx + Py = Qyⁿ, the values of n for which it is already linear or separable, and so needs no substitution, are

    1. n = 0 and n = 1
    2. n = 1 and n = 2
    3. n = −1 and n = 1
    4. n = 0 and n = 2
    Show answer

    Answer: A — n = 0 and n = 1

    With n = 0 the equation is dy/dx + Py = Q, linear; with n = 1 it is dy/dx = (Q − P)y, separable. Every other n, including 2 and −1, needs v = y1−n.
  10. An ordinary differential equation in which the dependent variable and all its derivatives occur only to the first power and are not multiplied together is called:

    1. homogeneous of degree zero
    2. exact
    3. linear
    4. separable
    Show answer

    Answer: C — linear

    That is the definition of a linear ODE, such as y″ + p(x)y′ + q(x)y = r(x). "Exact" is the tempting answer because it is another named class taught alongside, but exactness concerns M dx + N dy being a total differential, which a nonlinear equation can also satisfy.
  11. If dy/dx = 2x and y(0) = 1, then y(2) is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 5

    Integrating, y = x² + C, and y(0) = 1 gives C = 1, so y(2) = 4 + 1 = 5. Answering 4 forgets the constant of integration fixed by the initial condition.
  12. For f(x) = x², the backward-difference estimate of f′(2) with h = 0.1 is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 3.9

    [f(2) − f(1.9)]/0.1 = (4 − 3.61)/0.1 = 3.9, below the exact 4 by h. Answering 4.1 is the forward difference [f(2.1) − f(2)]/0.1.
  13. The integrating factor of the linear equation dy/dx + 2y = x is:

    1. e^(−2x)
    2. e^(2x)
    3. e^(x²)
    4. 2x
    Show answer

    Answer: B — e^(2x)

    For dy/dx + P y = Q the integrating factor is e^(∫P dx) = e^(2x). e^(−2x) is the tempting sign slip, which would leave the left side not an exact derivative.
  14. Using one step of Euler's method with h = 0.1 for dy/dx = x + y, y(0) = 1, the estimate of y(0.1) is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 1.1

    y₁ = y₀ + h f(x₀, y₀) = 1 + 0.1 × (0 + 1) = 1.1 (the exact value is 2e^0.1 − 1.1 = 1.1103). Answering 1.11 uses the slope at the end of the step, which is the implicit (backward) Euler idea.
  15. The solution of dy/dx = −2y with y(0) = 3, evaluated at x = 1, is ____ (three decimal places).

    Numerical answer — type the value.

    Show answer

    Answer: 0.406

    y = 3e^(−2x), so y(1) = 3e^(−2) = 0.406. Answering 1 comes from linear decay y = 3 − 2x, which ignores that the rate is proportional to y.
  16. An undamped spring-mass system obeys y″ + 9y = 0. Its general solution is:

    1. y = A e^(3x) + B e^(−3x)
    2. y = (A + Bx) e^(3x)
    3. y = A cos 3x + B sin 3x
    4. y = A cos 9x + B sin 9x
    Show answer

    Answer: C — y = A cos 3x + B sin 3x

    The characteristic equation m² + 9 = 0 has roots ±3i, giving oscillation at ω = 3. The exponential form is tempting, but it solves y″ − 9y = 0 (roots ±3); cos 9x would use ω² instead of ω.
  17. For f(x) = sin x (x in radians), the central-difference estimate of f′(0) with h = 0.1 is ____ (four decimal places).

    Numerical answer — type the value.

    Show answer

    Answer: 0.9983

    [sin 0.1 − sin(−0.1)]/0.2 = sin 0.1/0.1 = 0.9983, close to the exact cos 0 = 1 with error about h²/6. Answering 1.0000 gives the exact derivative rather than the estimate.
  18. Solve y″ − 3y′ + 2y = 0 with y(0) = 0 and y′(0) = 1. The value of y(1) is ____ (three decimal places).

    Numerical answer — type the value.

    Show answer

    Answer: 4.671

    Roots are 1 and 2, so y = Ae^x + Be^(2x); A + B = 0 and A + 2B = 1 give B = 1, A = −1, hence y(1) = e² − e = 4.671. Swapping the constants gives e − e² = −4.671.
  19. Using one step of Heun's method (improved Euler) with h = 0.1 for dy/dx = y, y(0) = 1, the estimate of y(0.1) is ____ (three decimal places).

    Numerical answer — type the value.

    Show answer

    Answer: 1.105

    Predictor slope k₁ = 1, predicted y = 1.1, corrector slope k₂ = 1.1; y₁ = 1 + 0.05 × (1 + 1.1) = 1.105, close to e^0.1 = 1.10517. Answering 1.1 stops at the Euler predictor.
  20. Solve y″ + 2y′ + 5y = 0 with y(0) = 1 and y′(0) = −1. The value of y at x = π/2 is ____ (three decimal places).

    Numerical answer — type the value.

    Show answer

    Answer: -0.208

    Roots −1 ± 2i give y = e^(−x)(A cos 2x + B sin 2x); y(0) = 1 gives A = 1, and y′(0) = −A + 2B = −1 gives B = 0, so y = e^(−x) cos 2x and y(π/2) = e^(−π/2) cos π = −0.208. Dropping the decay factor gives −1, the undamped value.
  21. Which of the following statements about numerical methods for ordinary differential equations are correct?

    1. Euler's method has a global error of order h
    2. The classical fourth-order Runge-Kutta method has a global error of order h⁴
    3. Heun's method is a second-order Runge-Kutta method
    4. Explicit Euler is stable for y′ = −λy (λ > 0) for every step size h
    Show answer

    Answer: A — Euler's method has a global error of order h; B — The classical fourth-order Runge-Kutta method has a global error of order h⁴; C — Heun's method is a second-order Runge-Kutta method

    Euler is first order, RK4 fourth order, and Heun's predictor-corrector is a two-stage, second-order RK method. The stability statement is the trap: explicit Euler applied to y′ = −λy is stable only for h < 2/λ; implicit (backward) Euler is the unconditionally stable one.