Theoretica
A C++ numerical and automatic mathematical library
|
Numerical methods for ordinary differential equations. More...
Classes | |
class | ode_solution_t |
The base type for the solution of an ODE, holding a vector \(t\) of the values of the time (independent variable) and a vector \(\vec x\) of the computed variables of the solution at each instant. More... | |
Typedefs | |
using | ode_solution = ode_solution_t< vec< real > > |
The solution of an ODE with any number of variables. | |
using | ode_solution1d = ode_solution_t< real > |
The solution of an ODE in 1 variable. | |
using | ode_solution2d = ode_solution_t< vec2 > |
The solution of an ODE in 2 variables. | |
using | ode_solution3d = ode_solution_t< vec3 > |
The solution of an ODE in 3 variables. | |
using | ode_solution4d = ode_solution_t< vec4 > |
The solution of an ODE in 4 variables. | |
template<typename Vector > | |
using | ode_function = std::function< Vector(real, const Vector &)> |
A function representing a system of differential equations, taking as input the time (independent variable) and the current value of the variables (dependent variables), returning the time derivatives of each variable, such as \(f\) in \(\dot \vec x = f(t, \vec x)\). | |
Functions | |
template<typename Vector , typename OdeFunction = ode_function<Vector>> | |
Vector | step_euler (OdeFunction f, const Vector &x, real t, real h=0.0001) |
Compute one step of Euler's method for ordinary differential equations. More... | |
template<typename Vector , typename OdeFunction = ode_function<Vector>> | |
Vector | step_midpoint (OdeFunction f, const Vector &x, real t, real h=0.0001) |
Compute one step of the midpoint method for ordinary differential equations. More... | |
template<typename Vector , typename OdeFunction = ode_function<Vector>> | |
Vector | step_heun (OdeFunction f, const Vector &x, real t, real h=0.001) |
Compute one step of Heun's method for ordinary differential equations. More... | |
template<typename Vector , typename OdeFunction = ode_function<Vector>> | |
Vector | step_rk2 (OdeFunction f, const Vector &x, real t, real h=0.001) |
Compute one step of the Runge-Kutta method of 2nd order for ordinary differential equations. More... | |
template<typename Vector , typename OdeFunction = ode_function<Vector>> | |
Vector | step_rk4 (OdeFunction f, const Vector &x, real t, real h=0.01) |
Compute one step of the Runge-Kutta method of 4th order for ordinary differential equations. More... | |
template<typename Vector , typename OdeFunction = ode_function<Vector>> | |
Vector | step_k38 (OdeFunction f, const Vector &x, real t, real h=0.001) |
Compute one step of Kutta's 3/8 rule method for ordinary differential equations. More... | |
template<typename Vector , typename OdeFunction = ode_function<Vector>> | |
Vector | step_adams2 (OdeFunction f, const Vector &x0, real t0, const Vector &x1, real t1, real h=0.001) |
Compute one step of the Adams-Bashforth linear multistep method of 2nd order for ordinary differential equations. More... | |
template<typename Vector , typename OdeFunction = ode_function<Vector>> | |
Vector | step_adams3 (OdeFunction f, const Vector &x0, real t0, const Vector &x1, real t1, const Vector &x2, real t2, real h=0.001) |
Compute one step of the Adams-Bashforth linear multistep method of 3rd order for ordinary differential equations. More... | |
template<typename Vector , typename OdeFunction = ode_function<Vector>, typename StepFunction = std::function<Vector(OdeFunction, real, const Vector&)>> | |
ode_solution_t< Vector > | solve_fixstep (OdeFunction f, const Vector &x0, real t0, real tf, StepFunction step, real stepsize=0.001) |
Integrate an ordinary differential equation using any numerical algorithm with a constant step size, such as Runge-Kutta methods. More... | |
template<typename Vector , typename OdeFunction = ode_function<Vector>> | |
ode_solution_t< Vector > | solve_euler (OdeFunction f, const Vector &x0, real t0, real tf, real stepsize=0.0001) |
Integrate an ordinary differential equation over a certain domain with the given initial conditions using Euler's method. More... | |
template<typename Vector , typename OdeFunction = ode_function<Vector>> | |
ode_solution_t< Vector > | solve_midpoint (OdeFunction f, const Vector &x0, real t0, real tf, real stepsize=0.0001) |
Integrate an ordinary differential equation over a certain domain with the given initial conditions using the midpoint method. More... | |
template<typename Vector , typename OdeFunction = ode_function<Vector>> | |
ode_solution_t< Vector > | solve_heun (OdeFunction f, const Vector &x0, real t0, real tf, real stepsize=0.0001) |
Integrate an ordinary differential equation over a certain domain with the given initial conditions using Heun's method. More... | |
template<typename Vector , typename OdeFunction = ode_function<Vector>> | |
ode_solution_t< Vector > | solve_rk2 (OdeFunction f, const Vector &x0, real t0, real tf, real stepsize=0.0001) |
Integrate an ordinary differential equation over a certain domain with the given initial conditions using Runge-Kutta's method of 2nd order. More... | |
template<typename Vector , typename OdeFunction = ode_function<Vector>> | |
ode_solution_t< Vector > | solve_rk4 (OdeFunction f, const Vector &x0, real t0, real tf, real stepsize=0.01) |
Integrate an ordinary differential equation over a certain domain with the given initial conditions using Runge-Kutta's method of 4th order. More... | |
template<typename Vector , typename OdeFunction = ode_function<Vector>> | |
ode_solution_t< Vector > | solve_k38 (OdeFunction f, const Vector &x0, real t0, real tf, real stepsize=0.0001) |
Integrate an ordinary differential equation over a certain domain with the given initial conditions using Kutta's 3/8 rule method. More... | |
Numerical methods for ordinary differential equations.
|
inline |
Integrate an ordinary differential equation over a certain domain with the given initial conditions using Euler's method.
f | A function representing the system of differential equations, following the signature of ode_function. |
x0 | The initial value of the variables |
t0 | The starting value of the time variable |
tf | The final value of the time variable |
stepsize | The constant step size |
|
inline |
Integrate an ordinary differential equation using any numerical algorithm with a constant step size, such as Runge-Kutta methods.
This function does not use a specific method but uses the step argument function to iterate each step of an arbitrary fixed step algorithm. If the step size does not exactly cover the interval of integration, the last step is shortened.
f | A function representing the system of differential equations, following the signature of ode_function. |
x0 | The initial value of the variables |
t0 | The starting value of the time variable |
tf | The final value of the time variable |
step | A function which integrates numerically the differential equation between \(t\) and \(t + h\), such as the functions named ode::step_* |
stepsize | The constant step size |
|
inline |
Integrate an ordinary differential equation over a certain domain with the given initial conditions using Heun's method.
f | A function representing the system of differential equations, following the signature of ode_function. |
x0 | The initial value of the variables |
t0 | The starting value of the time variable |
tf | The final value of the time variable |
stepsize | The constant step size |
|
inline |
Integrate an ordinary differential equation over a certain domain with the given initial conditions using Kutta's 3/8 rule method.
f | A function representing the system of differential equations, following the signature of ode_function. |
x0 | The initial value of the variables |
t0 | The starting value of the time variable |
tf | The final value of the time variable |
stepsize | The constant step size |
|
inline |
Integrate an ordinary differential equation over a certain domain with the given initial conditions using the midpoint method.
f | A function representing the system of differential equations, following the signature of ode_function. |
x0 | The initial value of the variables |
t0 | The starting value of the time variable |
tf | The final value of the time variable |
stepsize | The constant step size |
|
inline |
Integrate an ordinary differential equation over a certain domain with the given initial conditions using Runge-Kutta's method of 2nd order.
f | A function representing the system of differential equations, following the signature of ode_function. |
x0 | The initial value of the variables |
t0 | The starting value of the time variable |
tf | The final value of the time variable |
stepsize | The constant step size |
|
inline |
Integrate an ordinary differential equation over a certain domain with the given initial conditions using Runge-Kutta's method of 4th order.
f | A function representing the system of differential equations, following the signature of ode_function. |
x0 | The initial value of the variables |
t0 | The starting value of the time variable |
tf | The final value of the time variable |
stepsize | The constant step size |
|
inline |
Compute one step of the Adams-Bashforth linear multistep method of 2nd order for ordinary differential equations.
This function is used in solvers to solve an ODE over a certain domain.
f | A function representing the system of differential equations, following the signature of ode_function. |
x | The starting vector of variables |
t | The starting value of the time (independent variable) |
h | The step size |
|
inline |
Compute one step of the Adams-Bashforth linear multistep method of 3rd order for ordinary differential equations.
This function is used in solvers to solve an ODE over a certain domain.
f | A function representing the system of differential equations, following the signature of ode_function. |
x | The starting vector of variables |
t | The starting value of the time (independent variable) |
h | The step size |
|
inline |
Compute one step of Euler's method for ordinary differential equations.
This function is used in solvers to solve an ODE over a certain domain.
f | A function representing the system of differential equations, following the signature of ode_function. |
x | The starting vector of variables |
t | The starting value of the time (independent variable) |
h | The step size |
|
inline |
Compute one step of Heun's method for ordinary differential equations.
This function is used in solvers to solve an ODE over a certain domain.
f | A function representing the system of differential equations, following the signature of ode_function. |
x | The starting vector of variables |
t | The starting value of the time (independent variable) |
h | The step size |
|
inline |
Compute one step of Kutta's 3/8 rule method for ordinary differential equations.
This function is used in solvers to solve an ODE over a certain domain.
f | A function representing the system of differential equations, following the signature of ode_function. |
x | The starting vector of variables |
t | The starting value of the time (independent variable) |
h | The step size |
|
inline |
Compute one step of the midpoint method for ordinary differential equations.
This function is used in solvers to solve an ODE over a certain domain.
f | A function representing the system of differential equations, following the signature of ode_function. |
x | The starting vector of variables |
t | The starting value of the time (independent variable) |
h | The step size |
|
inline |
Compute one step of the Runge-Kutta method of 2nd order for ordinary differential equations.
This function is used in solvers to solve an ODE over a certain domain.
f | A function representing the system of differential equations, following the signature of ode_function. |
x | The starting vector of variables |
t | The starting value of the time (independent variable) |
h | The step size |
|
inline |
Compute one step of the Runge-Kutta method of 4th order for ordinary differential equations.
This function is used in solvers to solve an ODE over a certain domain.
f | A function representing the system of differential equations, following the signature of ode_function. |
x | The starting vector of variables |
t | The starting value of the time (independent variable) |
h | The step size |