ODE Integration

Integrates ODEs while assessing accuracy, stability, and computational cost.

Conceptual context

Many physical laws are written as differential equations because they describe how a quantity changes from its current state. When no useful analytical solution exists, continuous evolution is replaced by a sequence of numerical steps. That replacement introduces non-neutral choices. hh sets the resolution, the integration method determines how slopes are combined, and NN sets the basic cost. The central task is to distinguish an accurate approximation from a curve that looks smooth but is unstable. This requires comparing ynumy_num, yrefy_ref, and EgE_g over the interval from t0t_0 to tft_f.

🟢 Essential level

Integrating an ODE means reconstructing how yy evolves from its instantaneous rate dydt\frac{dy}{dt}.

A computer does not move continuously through time: it advances by increments hh and calculates a yn+1y_{n+1} at each update. Euler uses one slope and is simple, but it accumulates more error. Heun corrects the prediction by averaging k1k_1 and k2k_2. RK4 combines k1k_1, k2k_2, k3k_3, and k4k_4 to represent curvature within the step more accurately. Formal algebraic details of these corrections are introduced at the formal level below.

A smaller step often improves accuracy, although it increases NN and computational cost. A smooth-looking curve does not by itself guarantee a correct result: the algorithm can silently invent oscillation, spurious growth, or the wrong decay rate. The basic check is repeating the calculation with a smaller step and observing whether the result settles down. Stability requires more than a plausible shape: the method must avoid artificial oscillation or growth. Comparing ynumy_num with yrefy_ref gives EgE_g and tests convergence under refinement. The correct choice depends on physical scales, required tolerance, stiffness, and the computational budget available for repeated derivative evaluations.

🔵 Formal level

Basic formulas

The dynamics is expressed as a first-order ODE relating dydt\frac{dy}{dt} to tt and yy.

First-order ODE

dydt=f(t,y)\frac{dy}{dt}=f(t,y)

Explicit Euler advances from the current state using the slope at the start of the interval.

Explicit Euler step

yn+1=yn+hf(tn,yn)y_{n+1}=y_n+h f(t_n,y_n)

Heun's method forms a prediction using k1k_1 and corrects it with k2k_2, so it uses information from the beginning and estimated end.

Heun step

yn+1=yn+h2(k1+k2)y_{n+1}=y_n+\frac{h}{2}(k_1+k_2)

RK4 calculates four slopes, k1k_1, k2k_2, k3k_3, and k4k_4, at different locations within the interval. Their weighted combination gives a fourth-order approximation.

Fourth-order Runge-Kutta step

yn+1=yn+h6(k1+2k2+2k3+k4)y_{n+1}=y_n+\frac{h}{6}(k_1+2k_2+2k_3+k_4)

Real student questions

Is a smaller step always better? Only up to a point. It reduces truncation error but increases cost and may expose roundoff.

Is RK4 always superior to Euler? No. It is often more accurate for smooth problems, but it costs more and does not solve stiffness by itself.

Does a smooth graph guarantee correctness? No. A wrong solution can be smooth. A convergence test is required.

What does stability mean? The method does not artificially amplify numerical perturbations in the regime being studied.

Why compare with half the step? It shows whether the solution approaches a limit and reveals the effective method order.

Final synthesis

hh controls resolution and cost; the method controls how slope information is used. A reliable solution must be dimensionally consistent, stable, and convergent. EgE_g and refinement tests turn a computed curve into a physically defensible approximation.

Formal development

This section is part of the complete theory. See the subscription options to access it.

🔴 Structural level

This section is part of the complete theory. See the subscription options to access it.

Deep physical interpretation

This section is part of the complete theory. See the subscription options to access it.

Order of magnitude

This section is part of the complete theory. See the subscription options to access it.

Personalized resolution method

This section is part of the complete theory. See the subscription options to access it.

Special cases and extended example

This section is part of the complete theory. See the subscription options to access it.

Cross-cutting connections and study paths

This section is part of the complete theory. See the subscription options to access it.