# \[ANN\] FdeSolver.jl: solve fractional differential equations (FDEs)

**URL:** <https://discourse.julialang.org/t/ann-fdesolver-jl-solve-fractional-differential-equations-fdes/71371>\
**Category:** Package Announcements\
**Tags:** package, announcement, diffeq, ode, numerics\
**Created:** [November 12, 2021, 10:11am UTC](https://discourse.julialang.org/t/ann-fdesolver-jl-solve-fractional-differential-equations-fdes/71371 "2021-11-12T10:11:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giulio\_Benedetti](https://avatars.discourse-cdn.com/v4/letter/g/f0a364/32.png) [@Giulio\_Benedetti](https://discourse.julialang.org/u/Giulio_Benedetti)\
**Post date:** [November 12, 2021, 10:11am UTC](https://discourse.julialang.org/t/ann-fdesolver-jl-solve-fractional-differential-equations-fdes/71371/1 "2021-11-12T10:11:37Z")

</div>

I’d like to announce a package for solving differential equations (and systems) with fractional derivatives (in the sense of **Caputo** ).

Fractional derivatives are suitable tools for modeling **memory effects** in complex systems, such as [microbial communities](https://www.biorxiv.org/content/10.1101/2021.09.01.458486v1.abstract).

The core function is _FDEsolver_, which includes a numerical solution based on **predictor - corrector methods** (the number of correction steps is customisable).

Here’s how _FDEsolver_ can be used to solve a generalised Lotka-Volterra model with memory:

```julia
using FdeSolver
using Plots

# Inputs
tSpan = [0, 25] # [intial time, final time]
y0 = [34, 6] # initial values
β = [0.98, 0.99] # order of derivatives
par = [0.55, 0.028, 0.84, 0.026] # model parameters

# ODE Model
function F(t, y, par)

    α1 = par[1] # growth rate of the prey population
    β1 = par[2] # rate of shrinkage relative to the product of the population sizes
    γ = par[3] # shrinkage rate of the predator population
    δ = par[4] # growth rate of the predator population as a factor of the product
                     # of the population sizes

    u = y[1] # population size of the prey species at time t[n]
    v = y[2] # population size of the predator species at time t[n]

    F1 = α1 .* u .- β1 .* u .* v
    F2 = - γ .* v .+ δ .* u .* v

    [F1, F2]

end

## Solution
t, Yapp = FDEsolver(F, tSpan, y0, β, par)

# Plot
plot(t, Yapp, linewidth = 5, title = "Solution to LV model with 2 FDEs",
     xaxis = "Time (t)", yaxis = "y(t)", label = ["Prey" "Predator"])
plot!(legendtitle = "Population of")

```

![example2](https://global.discourse-cdn.com/julialang/original/3X/3/4/348edbc1553a5d17dfc7232ccefa236e3592ae52.png)

In the future, we would like to add the following features:

- Support solutions for FDEs with multiterm fractional derivatives in each equation;
- Improve the efficiency (accuracy and speed) of the current solver;
- Expand to other numerical methods.

We happily seek new collaborations, feedback, and ideas, either by getting in touch or simply by opening an issue or pull request in _[FdeSolver.jl](https://github.com/JuliaTurkuDataScience/FdeSolver.jl)_.

This FDE solver is based on some of the [MATLAB solvers](https://www.dm.uniba.it/members/garrappa/software) provided by R. Garrappa (_FDE\_PI2\_Im_ and _FDE\_PI12\_PC_).

For additional examples and information on the solver, check out its [documentation](https://juliaturkudatascience.github.io/FdeSolver.jl/stable/intro/) or the [readme](https://github.com/JuliaTurkuDataScience/FdeSolver.jl#fdesolver).

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [November 12, 2021, 2:27pm UTC](https://discourse.julialang.org/t/ann-fdesolver-jl-solve-fractional-differential-equations-fdes/71371/2 "2021-11-12T14:27:23Z")

</div>

Would it make sense to make this package follow the interface of `DifferentialEquations` where you have a separate `solve` command from the command to setup the problem? That distinction has worked well for them.

---

<div class="post-metadata">

**Author:** ![Giulio\_Benedetti](https://avatars.discourse-cdn.com/v4/letter/g/f0a364/32.png) [@Giulio\_Benedetti](https://discourse.julialang.org/u/Giulio_Benedetti)\
**Post date:** [November 12, 2021, 4:24pm UTC](https://discourse.julialang.org/t/ann-fdesolver-jl-solve-fractional-differential-equations-fdes/71371/3 "2021-11-12T16:24:03Z")

</div>

Hi!

I’m pretty sure that could be implemented.

Besides adding consistency with `DifferentialEquations`, could it also improve the solver in any other way?

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [November 12, 2021, 4:41pm UTC](https://discourse.julialang.org/t/ann-fdesolver-jl-solve-fractional-differential-equations-fdes/71371/4 "2021-11-12T16:41:42Z")

</div>

The reason `DifferentialEquations` chose this approach is it lets you separate the arguments that relate to the solver from the arguments that relate to the problem. The `*Problem` defines things like the function, initial conditions, and parameters for the function, while the `solve` takes parameters like tolerance, convergence criteria, and algorithms used to solve.

There are 2 main reasons why this is nice. It’s a separation of concerns, and it makes it easier to solve the same problem with a variety of different parameters (eg to test what works best).

---

<div class="post-metadata">

**Author:** ![jClugstor](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jclugstor/32/32689_2.png) [@jClugstor](https://discourse.julialang.org/u/jClugstor)\
**Post date:** [January 12, 2022, 3:34am UTC](https://discourse.julialang.org/t/ann-fdesolver-jl-solve-fractional-differential-equations-fdes/71371/5 "2022-01-12T03:34:12Z")

</div>

Thanks for making this, I was thinking about doing the exact same thing to start to learn Julia 🙂 . It will end up being very useful to me.

---

<div class="post-metadata">

**Author:** ![Giulio\_Benedetti](https://avatars.discourse-cdn.com/v4/letter/g/f0a364/32.png) [@Giulio\_Benedetti](https://discourse.julialang.org/u/Giulio_Benedetti)\
**Post date:** [January 25, 2022, 12:48pm UTC](https://discourse.julialang.org/t/ann-fdesolver-jl-solve-fractional-differential-equations-fdes/71371/6 "2022-01-25T12:48:26Z")

</div>

It’s my pleasure. I’ll be very interested to hear from you where and how you will be using it. 🙂
