FractionalDiffEq.jl provides FDE solvers to DifferentialEquations.jl ecosystem, including FODE(Fractional Ordinary Differential Equations), FDDE(Fractional Delay Differential Equations) and many more. There are many performant solvers available, capable of solving many kinds of fractional differential equations.
If you have already installed Julia, you can install FractionalDiffEq.jl in REPL using the Julia package manager:
pkg> add FractionalDiffEq
Let's see if we have an fractional order initial value problem:
So we can use FractionalDiffEq.jl to solve the problem:
using FractionalDiffEq, Plots
fun(u, p, t) = 1-u
u0 = [0, 0]; tspan = (0, 20);
prob = FODEProblem(fun, 1.8, u0, tspan)
sol = solve(prob, PECE(), dt=0.001)
plot(sol)
And if you plot the result, you can see the result of the above IVP:
Let's see if we have an initial value problem:
using FractionalDiffEq, Plots
tspan = (0, 30)
rightfun(x, y) = 172/125*cos(4/5*x)
prob = MultiTermsFODEProblem([1, 1/16, 4/5, 3/2, 1/25, 6/5], [3, 2.5, 2, 1, 0.5, 0], rightfun, [0, 0, 0, 0, 0, 0], tspan)
sol = solve(prob, PIEX(), dt=0.01)
plot(sol, legend=:bottomright)
Or use the example file to plot the numerical approximation, we can see the FDE solver in FractionalDiffEq.jl is amazingly powerful:
FractionalDiffEq.jl is a powerful tool to solve a system of fractional differential equations, if you are familiar with DifferentialEquations.jl, it would be just like out of the box.
Let's see if we have a Chua chaos system:
By using the NonLinearAlg
algorithms to solve this problem:
using FractionalDiffEq, Plots
function chua!(du, x, p, t)
a, b, c, m0, m1 = p
du[1] = a*(x[2]-x[1]-(m1*x[1]+0.5*(m0-m1)*(abs(x[1]+1)-abs(x[1]-1))))
du[2] = x[1]-x[2]+x[3]
du[3] = -b*x[2]-c*x[3]
end
α = [0.93, 0.99, 0.92];
x0 = [0.2; -0.1; 0.1];
tspan = (0, 100);
p = [10.725, 10.593, 0.268, -1.1726, -0.7872]
prob = FODEProblem(chua!, α, x0, tspan, p)
sol = solve(prob, BDF(), dt=0.01)
plot(sol, vars=(1, 2), title="Chua System", legend=:bottomright)
And plot the result:
There are also many powerful solvers for solving fractional delay differential equations.
With history function:
using FractionalDiffEq, Plots
ϕ(x) = x == 0 ? (return 19.00001) : (return 19.0)
f(t, y, ϕ) = 3.5*y*(1-ϕ/19)
α = 0.97; τ = 0.8; tspan = (0,56)
fddeprob = FDDEProblem(f, ϕ, α, constant_lags=[τ], tspan)
sol = solve(fddeprob, DelayPECE(), dt=0.05)
plot(sol, xlabel="y(t)", ylabel="y(t-τ)")
For more performant solvers, please refer to the FractionalDiffEq.jl Solvers page.
- More performant algorithms
- Better docs
- More interesting ideas~
If you are interested in Fractional Differential Equations and Julia, welcome to raise an issue or file a Pull Request!!