Solves a higher
(2.nd) order ordinary differential equation (ODE)
with known solution,
x = cos(kt ²) + at + b
x' = −2kt sin(kt ²) + a
x" = −2k sin(kt ²) −
4k ²t ² cos(kt ²)
proposed
for resolution as
x" = −2k sin(kt ²) −
4k ² (x − at - b)
t ²
with (necessarily)
x(0) = b + 1 and x'(0) = a, by the (usual)
Runge-Kutta 4.th order method.
The independent variable is t.
The two initial values are supposed given.
The equation is converted into an equivalent
system of first order equations, as is typically recommended.
Important
The RK4 (4.th orderRunge-Kutta) method
supplies all the derivatives, up to n − 1,
besides the desired (numerically) integrated function.
So, in this example of a 2.nd order ODE
(n = 2), the method supplies n functions:
the function itself (derivative of order 0), x(t);
and the 1.st derivative (derivative of order 1),
x'(t).
Draws graphs for: x and x',
where the numerical and analytical solutions
are superimposed; and x", known analytical.
(This webpage is in version 2.) |