UNIHIVE

Study Hub UNIPORT ENG 303

ENG 303 · Engineering Mathematics V (Numerical Methods and Computer Application)

Difference equations and initial-value ODEs

Linear difference equations, Euler's method, Heun's method, the classical fourth-order Runge-Kutta method, step size and stability, and systems.

Our notes

2 min read

Difference equations

A difference equation links terms of a sequence, for example yₙ₊₂ − 5yₙ₊₁ + 6yₙ = 0. Try yₙ = rⁿ: r² − 5r + 6 = 0, so r = 2 or 3, and yₙ = A·2ⁿ + B·3ⁿ.
Worked example. With y₀ = 2, y₁ = 5: A + B = 2 and 2A + 3B = 5 give A = B = 1, so yₙ = 2ⁿ + 3ⁿ. Check y₂: formula 4 + 9 = 13; recurrence 5 × 5 − 6 × 2 = 13. ✓
Numerical methods for ODEs are themselves difference equations, which is why their stability can be studied this way.

Euler's method

For y′ = f(x, y), y(x₀) = y₀: yₙ₊₁ = yₙ + h f(xₙ, yₙ). First order (global error ∝ h).
Worked example. y′ = y, y(0) = 1, h = 0.1: y₁ = 1 + 0.1 × 1 = 1.1; y₂ = 1.1 + 0.11 = 1.21. True y(0.2) = e^0.2 = 1.221403.

Heun's (improved Euler) method

Predict with Euler, then average the slopes: yₙ₊₁ = yₙ + (h/2)[f(xₙ, yₙ) + f(xₙ₊₁, yₙ + hf(xₙ, yₙ))]. Second order. For the example: y₁ = 1 + 0.05(1 + 1.1) = 1.105.

Classical fourth-order Runge-Kutta (RK4)

k₁ = f(xₙ, yₙ)
k₂ = f(xₙ + h/2, yₙ + hk₁/2)
k₃ = f(xₙ + h/2, yₙ + hk₂/2)
k₄ = f(xₙ + h, yₙ + hk₃)
yₙ₊₁ = yₙ + (h/6)(k₁ + 2k₂ + 2k₃ + k₄)
Worked example. y′ = y, y(0) = 1, h = 0.1: k₁ = 1; k₂ = 1.05; k₃ = 1 + 0.05 × 1.05 = 1.0525; k₄ = 1 + 0.1 × 1.0525 = 1.10525.
y₁ = 1 + (0.1/6)(1 + 2.1 + 2.105 + 1.10525) = 1 + (0.1/6)(6.31025) = 1.105171, matching e^0.1 = 1.105171 to six figures. Error ∝ h⁴.

Step size and stability

For y′ = −λy (λ > 0), Euler's method gives yₙ₊₁ = (1 − λh)yₙ, which blows up unless h < 2/λ. "Stiff" problems (very fast and slow parts together, as in chemical kinetics) need implicit methods (backward Euler) or tiny steps. Adaptive methods (such as RK45) change h to keep the estimated error within a tolerance.

Systems and higher-order ODEs

A second-order ODE such as y″ + 3y′ + 2y = 0 becomes two first-order ones: y′ = v, v′ = −3v − 2y; apply RK4 to the pair, updating both together at each stage.

Exams usually ask: solve a linear difference equation; carry out Euler, Heun or RK4 steps; compare with the exact solution; convert a second-order ODE to a system; explain stability limits.

Common mistake: in RK4, evaluating k₂ at yₙ + hk₁ instead of yₙ + hk₁/2. The middle slopes use half steps.

Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.

Read

Watch

We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.

All ENG 303 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.