Theoretica
A C++ numerical and automatic mathematical library
ode.h File Reference

Numerical methods for ordinary differential equations. More...

#include "../algebra/vec.h"

Go to the source code of this file.

Classes

class  theoretica::ode::ode_solution_t< Vector >
 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...
 

Namespaces

 theoretica
 Main namespace of the library which contains all functions and objects.
 
 theoretica::ode
 Numerical methods for ordinary differential equations.
 

Typedefs

using theoretica::ode::ode_solution = ode_solution_t< vec< real > >
 The solution of an ODE with any number of variables.
 
using theoretica::ode::ode_solution1d = ode_solution_t< real >
 The solution of an ODE in 1 variable.
 
using theoretica::ode::ode_solution2d = ode_solution_t< vec2 >
 The solution of an ODE in 2 variables.
 
using theoretica::ode::ode_solution3d = ode_solution_t< vec3 >
 The solution of an ODE in 3 variables.
 
using theoretica::ode::ode_solution4d = ode_solution_t< vec4 >
 The solution of an ODE in 4 variables.
 
template<typename Vector >
using theoretica::ode::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 theoretica::ode::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 theoretica::ode::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 theoretica::ode::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 theoretica::ode::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 theoretica::ode::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 theoretica::ode::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 theoretica::ode::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 theoretica::ode::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 > theoretica::ode::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 > theoretica::ode::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 > theoretica::ode::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 > theoretica::ode::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 > theoretica::ode::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 > theoretica::ode::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 > theoretica::ode::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...
 

Detailed Description

Numerical methods for ordinary differential equations.