A Quick Tour of DifferentialEquations.jl

DifferentialEquations.jl is a metapackage for solving differential equations in Julia. The basic workflow is:

  • Define a problem
  • Solve a problem
  • Plot the solution

The API between different types of differential equations is unified through multiple dispatch.

See the DifferentialEquations.jl Documentation.

Example: Lotka-Volterra ODE

$$\begin{align} x' &= ax - bxy\\ y' &= -cy + dxy \end{align}$$

In [1]:
using DifferentialEquations
# Define a problem
p = (1.0,2.0,1.5,1.25) # a,b,c,d
f = function (du,u,p,t) # Define f as an in-place update into du
    a,b,c,d = p
    du[1] = a*u[1] - b*u[1]*u[2]
    du[2] = -c*u[2]+ d*u[1]*u[2]
end
u0 = [1.0;1.0]; tspan = (0.0,10.0)
prob = ODEProblem(f,u0,tspan,p);
In [2]:
# Solve the problem
sol = solve(prob);
In [3]:
# Plot the solution using the plot recipe
using Plots; gr() # Using the Plotly Backend
plot(sol,title="All Plots.jl Attributes are Available")