UNIHIVE

Study Hub UNIPORT MTH 492

MTH 492 · Numerical Methods

Systems and higher-order equations

Turning a higher-order ODE into a first-order system and applying RK methods to it.

Our notes

1 min read

Why systems

Most physical laws are second order (Newton's law, circuits, beams), and many models couple several unknowns (predator-prey, reacting chemicals). Numerical methods are written for first-order systems, so we rewrite everything in that form.

Reducing order

For y″ = f(x, y, y′), set u₁ = y and u₂ = y′. Then:

  • u₁′ = u₂
  • u₂′ = f(x, u₁, u₂)

An n-th order equation becomes n first-order equations.

Example

The pendulum θ″ + (g/L) sin θ = 0 becomes θ′ = ω, ω′ = −(g/L) sin θ.

Applying RK4 to a system

Treat u = (u₁, u₂) as a vector. Each kᵢ is a vector; every component is updated with the same stage values. In code, write f to return a vector.

Worked example: one Euler step on a system

y″ = −y, y(0) = 0, y′(0) = 1 (exact y = sin x), h = 0.1.

  • u₁′ = u₂, u₂′ = −u₁; start (u₁, u₂) = (0, 1).
  • Euler: u₁ = 0 + 0.1 × 1 = 0.1; u₂ = 1 + 0.1 × (−0) = 1.
  • So y(0.1) ≈ 0.1 (exact sin 0.1 = 0.0998).

Worked example: RK4 on the same system

k₁ = (1, 0); k₂ = (1, −0.05); k₃ = (0.9975, −0.05); k₄ = (0.995, −0.09975).
u₁ = 0 + (0.1/6)(1 + 2 + 1.995 + 0.995) = 0.0998333, against sin 0.1 = 0.0998334. ✓

(Check k₃: u at the midpoint is (0 + 0.05 × 1, 1 + 0.05 × (−0.05)) = (0.05, 0.9975), so k₃ = (0.9975, −0.05).)

Energy and long runs

For oscillators, Euler's method makes the energy grow every step (the orbit spirals out); RK4 loses energy very slowly. For very long simulations (planets, molecular dynamics) special symplectic methods (leapfrog, Verlet) keep the energy bounded.

Boundary value problems are different

If the conditions are given at two ends (y(a) and y(b)), we cannot simply march from one end. That needs the shooting or finite difference methods of the next topics.

Exams usually ask

  • Write a higher-order ODE as a first-order system.
  • Carry out one RK4 step on a 2 × 2 system.

Common mistake

Updating u₁ first and then using the new u₁ to compute u₂ in the same stage. All components of a stage use the old values.

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 MTH 492 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.