![]() |
Prev | Next |
yf = runge_kutta_4(f, ti, yi, dt)
t
is a scalar and
y
is a vector with size @(@
n
@)@,
k = f(t, y)
returns a vector of size @(@
n
@)@ that is the value of @(@
f(t, y)
@)@
at the specified values.
runge_kutta_4
. In this table,
s
and
t
are
scalars,
d
is a decimal number (i.e., a float
)
and
u
and
v
are vectors with size @(@
n
@)@.
operation | result |
d * s
| scalar |
s + t
| scalar |
s * u
| vector with size @(@ n @)@ |
d * u
| vector with size @(@ n @)@ |
s * u
| vector with size @(@ n @)@ |
u + v
| vector with size @(@ n @)@ |
def runge_kutta_4(f, ti, yi, dt) :
k1 = dt * f(ti , yi)
k2 = dt * f(ti + .5*dt , yi + .5*k1)
k3 = dt * f(ti + .5*dt , yi + .5*k2)
k4 = dt * f(ti + dt , yi + k3)
yf = yi + (1./6.) * ( k1 + 2.*k2 + 2.*k3 + k4 )
return yf
runge_kutta_4
to solve an ODE.