File Exchange

image thumbnail

Solving Multiterm Fractional Differential Equations (FDE)

version (15.6 KB) by Roberto Garrappa
Solve Multiterm Fractional Differential Equations by first-order implicit product trapezoidal rule


Updated 23 Mar 2018

View License

MT_FDE_PI1_Im Solves on the interval [t0,T] an initial value problem for the multiterm fractional differential equation
lam_Q D^(al_Q) y(t) + ... + lam_1 D^(al_1) y(t) = f(t,y(t))
y(0) = y0(1), y'(0) = y0(2), ... y^m(0) = y0(m)
with m the smallest integer greater than max(al_1,...,al_Q). The problem is solved by means of the implicit product-integration rule of rectangular type having order 1 of convergence.

Further information on this code are available in the following paper

[1] Garrappa R.: Numerical Solution of Fractional Differential Equations: a Survey and a Software Tutorial, Mathematics 2018, 6(2), 16 doi:
downloadable pdf:

Cite As

Roberto Garrappa (2021). Solving Multiterm Fractional Differential Equations (FDE) (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (13)

Abdulhamit OZDEMIR

Liu Kevin

Very good ! but i have a question? Can i put this FDE solver into the simulation environment?especially for simscape electricity?
Recently,i try to build some mechanical model and simulation including fractional differential equation in time domain.The ODEs cannot fulfill the needs.


@Sheldon Park: I got the same issue, then by following the guidance of Roberto Garrappa, I use smaller step-size then I worked.
However, fde12 can run with alpha > 0.8, if alpha < 0.8 then I have to use step-size h < 2^(-20) or so, which finally caused an error because of too small step-size.
@Roberto Garrappa: could you check your fde12 again using smaller fractional-orders such as alfa =0.02 or so? I believe it will get problems with small orders.

Roberto Garrappa

@Sheldon Park: different codes implement different methods, thus differences are normal. Ode23t.m is a variable step-size method which better treats the stiffness of your system close to the initial point. fde12 implements a substantially explicit method with fixed step-size and the step-size you selected is not sufficient to obtain a stable behavior. A smaller step-size, for instance h=2^(-10), surely may help. I strongly recommend to carefully read the description of the method and his properties (reported in the code and in the referenced papers) before using the code. A final question: why posting this comment here whilst it is related to the code ?

Sheldon Park

Thanks for contributing fde12. I'm trying to solve a set of coupled equations containing fractional derivatives. To validate that I'm using it correctly, I tested on a simple problem using ODE and fde12 (with alpha=1.0). I would have expected the same result. Unfortunately, they don't. The ODE output makes sense but fde12 output blows up quickly. I'm not sure if I'm using it correctly. Any advice you can provide would be greatly appreciated. Thank you. -Sheldon

Here's the reaction I'm solving:
A + B < ---- > AB (kon=forward, koff=backward)
| k_el (rate of elimination for B)
The code I'm running is:

format compact
k_el = 1.7;
kon = 100;
koff = 2.5;
% function definition
myfun = @(t,y) [-kon*y(1)*y(2) + koff*y(3);
-kon*y(1)*y(2) + koff*y(3) - k_el*y(2);
kon*y(1)*y(2) - koff*y(3)];
% using ODE
tspan = [0, 50];
tic; sol = ode23t(myfun,tspan,[4;2.5;0]); toc;
figure(1); plot(sol.x,sol.y); legend; grid;
% using fde12
t0=0; tfinal=50;
h=2^(-6); alpha=1.0;
tic; [t, qsol]=fde12(alpha,myfun,t0,tfinal,[4;2.5;0],h); toc;
figure(2); plot(t,qsol(1,:)); legend; grid;

P Tamilalagan

I request any one to give me any idea to solve fractional differential equations with delay. My personal email id is

P Tamilalagan

Respected @Roberto Garrappa
Thank you very much for your kind reply, I am very much happy to communicate with such a helping minded person. Now, I am able to solve fractional order differential equations by Matlab. I request you to give me an idea to solve fractional delay differential equations. If possible kindly give me some sample codes, since i am little bit poor in Matlab.

Thanks in advance.

Ramashis Banerjee

@Roberto Garrappa Sir, please tell me how to solve FODE backward in time using your code? Please guide me sir.

Thank you in advance.

Roberto Garrappa

Dear P. Tamilalagan you can find other codes for FDEs in my mathworks author profile or in my web-page

P Tamilalagan

I need Matlab code for fractional differential equations, I require any suggestion or idea. Could you help me?

Roberto Garrappa

As clearly explained the code is devised for multi-term fractional differential equations and not for fractional differential equations with delay.

tom tom

do the Matlab code for delayed fractional-order differential equations ?

Tareq Abuaisha

very good function to solve an multi-term fractional-order differential equation. Well done Roberto!

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!