Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- rungeKuttaConstantStep :: VectorSpace vec => (Double -> vec -> vec) -> vec -> Double -> Double -> [(Double, vec)]
- rungeKuttaAdaptiveStep :: VectorSpace vec => (Double -> vec -> vec) -> vec -> Double -> Double -> (vec -> Double) -> Double -> [(Double, vec)]
Documentation
rungeKuttaConstantStep Source #
:: VectorSpace vec | |
=> (Double -> vec -> vec) | = dy/dt = f(t, y) |
-> vec | Initial y |
-> Double | Initial time |
-> Double | Step size |
-> [(Double, vec)] | Infinite list of (time, y). Use e.g. |
Solve a system of first-order differential equations with RK4 (»the standard Runge-Kutta«).
Solution of a planetary model (with adjusted gravity and small friction for a prettier non-elliptic trajectory),
\[ \begin{align} \mathbf {\ddot x} &= - \underbrace{ g \frac {\mathbf x} {\|\mathbf x\|^{3-\varepsilon}}}_{\text{Gravity} } - \underbrace{ \mu \|\mathbf{\dot x}\| \mathbf{\dot x}}_{\text{Friction} } \\ \mathbf{x}(0) &= \begin{pmatrix}100\\0\end{pmatrix} \\ \mathbf{\dot x}(0) &= \begin{pmatrix}4\\4\end{pmatrix} \\ \varepsilon &= 0.06 \\ g &= 2200 \\ \mu &= 0.0001 \end{align} \]
rungeKuttaAdaptiveStep Source #
:: VectorSpace vec | |
=> (Double -> vec -> vec) | = dy/dt = f(t, y) |
-> vec | Current y |
-> Double | Current time |
-> Double | Initial step size |
-> (vec -> Double) | Norm function to calculate how good our estimate is |
-> Double | Error tolerance |
-> [(Double, vec)] | Infinite list of (time, y). Use e.g. |
Solve a system of first-order differential equations with RKF45 (Runge-Kutta-Feinberg, adaptive step size using 4th-and-5th-order Runge-Kutta).
Solution for a double pendulum: