# ODE Problems

## Mathematical Specification of an ODE Problem

To define an ODE Problem, you simply need to give the function $f$ and the initial condition $u₀$ which define an ODE:

`f`

should be specified as `f(t,u)`

(or in-place as `f(t,u,du)`

), and `u₀`

should be an AbstractArray (or number) whose geometry matches the desired geometry of `u`

. Note that we are not limited to numbers or vectors for `u₀`

; one is allowed to provide `u₀`

as arbitrary matrices / higher dimension tensors as well.

## Problem Type

### Constructors

`ODEProblem(f,u0,tspan,callback=CallbackSet(),mass_matrix=I)`

: Defines the ODE with the specified functions.

### Fields

`f`

: The function in the ODE.`u0`

: The initial condition.`tspan`

: The timespan for the problem.`callback`

: A callback to be applied to every solver which uses the problem. Defaults to nothing.`mass_matrix`

: The mass-matrix. Defaults to`I`

, the`UniformScaling`

identity matrix.

# Refined ODE Problems

The refined ODE types are types that specify the ODE to a much greater degree of detail, and thus give the solver more information and make it easier to optimize. There are three different kinds of refined problems: split (IMEX) problems, partitioned problems, and constrained problems.

## Mathematical Specification of a Split ODE Problem

To define a `ODEProblem`

in split form, you simply need to give a tuple of functions $(f_1,f_2,\ldots,f_n)$ and the initial condition $u₀$ which define an ODE:

`f`

should be specified as `f(t,u)`

(or in-place as `f(t,u,du)`

), and `u₀`

should be an AbstractArray (or number) whose geometry matches the desired geometry of `u`

. Note that we are not limited to numbers or vectors for `u₀`

; one is allowed to provide `u₀`

as arbitrary matrices / higher dimension tensors as well.

## Mathematical Specification of a Partitioned ODE Problem

To define a Partitioned `ODEProblem`

, you need to give a tuple of functions $(f_1,f_2,\ldots,f_n)$ and the tuple of initial conditions $(u₀,v₀,...)$ (tuple of the same size) which define an ODE:

like e.g. `ODEProblem((f_1, f_2,...), (u0, v0, ...), tspan)`

. Each of the `f_i`

should be specified as `f_1(t,u,v,...)`

, or in-place as `f_1(t,u,v,...,du)`

. The initial conditions should be `AbstractArray`

s (or numbers) whose geometry matches the desired geometry of `u`

. Note that we are not limited to numbers or vectors for `u₀`

; one is allowed to provide `u₀`

as arbitrary matrices / higher dimension tensors as well.

In some cases, the solvers may specify the functions in a split form, for example:

see the solver's documentation for the form it is expecting.

## Mathematical Specification of an Second Order ODE Problem

To define an ODE Problem, you simply need to give the function $f$ and the initial condition $u₀$ which define an ODE:

`f`

should be specified as `f(t,u,du)`

(or in-place as `f(t,u,du,ddu)`

), and `u₀`

should be an AbstractArray (or number) whose geometry matches the desired geometry of `u`

. Note that we are not limited to numbers or vectors for `u₀`

; one is allowed to provide `u₀`

as arbitrary matrices / higher dimension tensors as well.

From this form, a partitioned ODE

is generated.

### Constructors

`SecondOrderODEProblem(f,u0,du0,tspan,callback=CallbackSet(),mass_matrix=I)`

: Defines the ODE with the specified functions.

### Fields

`f`

: The function in the ODE.`u0`

: The initial condition.`du0`

: The initial derivative.`tspan`

: The timespan for the problem.`callback`

: A callback to be applied to every solver which uses the problem. Defaults to nothing.`mass_matrix`

: The mass-matrix. Defaults to`I`

, the`UniformScaling`

identity matrix.

## Example Problems

Example problems can be found in DiffEqProblemLibrary.jl.

To use a sample problem, such as `prob_ode_linear`

, you can do something like:

```
# Pkg.add("DiffEqProblemLibrary")
using DiffEqProblemLibrary
prob = prob_ode_linear
sol = solve(prob)
```

`DiffEqProblemLibrary.prob_ode_linear`

— Constant.Linear ODE

with initial condition $u0=1/2$, $α=1.01$, and solution

with Float64s

`DiffEqProblemLibrary.prob_ode_2Dlinear`

— Constant.4x2 version of the Linear ODE

with initial condition $u0=1/2$, $α=1.01$, and solution

with Float64s

`DiffEqProblemLibrary.prob_ode_bigfloatlinear`

— Constant.Linear ODE

with initial condition $u0=1/2$, $α=1.01$, and solution

with BigFloats

`DiffEqProblemLibrary.prob_ode_bigfloat2Dlinear`

— Constant.4x2 version of the Linear ODE

with initial condition $u0=1/2$, $α=1.01$, and solution

with BigFloats

`DiffEqProblemLibrary.prob_ode_large2Dlinear`

— Constant.100x100 version of the Linear ODE

with initial condition $u0=1/2$, $α=1.01$, and solution

with Float64s

4x2 version of the Linear ODE

with initial condition $u0=1/2$, $α=1.01$, and solution

on Float64. Purposefully not in-place as a test.

`DiffEqProblemLibrary.prob_ode_threebody`

— Constant.The ThreeBody problem as written by Hairer:

From Hairer Norsett Wanner Solving Ordinary Differential Euations I - Nonstiff Problems Page 129

Usually solved on `t₀ = 0.0`

; `T = parse(BigFloat,"17.0652165601579625588917206249")`

Periodic with that setup.

`DiffEqProblemLibrary.prob_ode_pleides`

— Constant.Pleides Problem

where

and inital condtions are

and with $xᵢ′(0)=yᵢ′(0)=0$ except for

From Hairer Norsett Wanner Solving Ordinary Differential Euations I - Nonstiff Problems Page 244

Usually solved from 0 to 3.

`DiffEqProblemLibrary.prob_ode_vanderpol`

— Constant.Van der Pol Equations

with $μ=1.0$ and $u0=[0,\sqrt{3}]$

Non-stiff parameters.

`DiffEqProblemLibrary.prob_ode_vanderpol_stiff`

— Constant.Van der Pol Equations

with $μ=10^6$ and $u0=[0,\sqrt{3}]$

Stiff parameters.

`DiffEqProblemLibrary.prob_ode_rober`

— Constant.The Robertson biochemical reactions:

where $k₁=0.04$, $k₂=3\times10^7$, $k₃=10^4$. For details, see:

Hairer Norsett Wanner Solving Ordinary Differential Euations I - Nonstiff Problems Page 129

Usually solved on `[0,1e11]`

`DiffEqProblemLibrary.prob_ode_rigidbody`

— Constant.Rigid Body Equations

with $I₁=-2$, $I₂=1.25$, and $I₃=-1/2$.

The initial condition is $y=[1.0;0.0;0.9]$.

From Solving Differential Equations in R by Karline Soetaert

or Hairer Norsett Wanner Solving Ordinary Differential Euations I - Nonstiff Problems Page 244

Usually solved from 0 to 20.