Page 1

0

Fractional Derivatives, Fractional

Integrals, and Fractional Differential

Equations in Matlab

Ivo Petráš

Technical University of Košice

Slovak Republic

1. Introduction

The term fractional calculus is more than 300 years old. It is a generalization of the ordinary

differentiation and integration to non-integer (arbitrary) order. The subject is as old as the

calculus of differentiation and goes back to times when Leibniz, Gauss, and Newton invented

this kind of calculation. In a letter to L’Hospital in 1695 Leibniz raised the following question

(Miller and Ross, 1993): “Can the meaning of derivatives with integer order be generalized to

derivatives with non-integer orders?" The story goes that L’Hospital was somewhat curious

about that question and replied by another question to Leibniz. “What if the order will

be 1/2?" Leibniz in a letter dated September 30, 1695 replied: “It will lead to a paradox,

from which one day useful consequences will be drawn." The question raised by Leibniz for

a fractional derivative was an ongoing topic in the last 300 years. Several mathematicians

contributed to this subject over the years. People like Liouville, Riemann, and Weyl made

major contributions to the theory of fractional calculus. The story of the fractional calculus

continued with contributions from Fourier, Abel, Leibniz, Grünwald, and Letnikov.

Nowadays, the fractional calculus attracts many scientists and engineers. There are several

applications of this mathematical phenomenon in mechanics, physics, chemistry, control

theory and so on (Caponetto et al., 2010; Magin, 2006; Monje et al., 2010; Oldham and Spanier,

1974; Oustaloup, 1995; Podlubny, 1999). It is natural that many authors tried to solve the

fractional derivatives, fractional integrals and fractional differential equations in Matlab.

A few very good and interesting Matlab functions were already submitted to the MathWorks,

Inc. Matlab Central File Exchange, where they are freely downloadable for sharing among

the users. In this chapter we will use some of them. It is worth mentioning some addition to

Matlab toolboxes, which are appropriate for the solution of fractional calculus problems. One

of them is a toolbox created by CRONE team (CRONE, 2010) and another one is the Fractional

State–Space Toolkit developed by Dominik Sierociuk (Sierociuk, 2005). Last but not least we

should also mention a Matlab toolbox created by Dingyü Xue (Xue, 2010), which is based on

Matlab object for fractional-order transfer function and some manipulation with this class of

the transfer function. Despite that the mentioned toolboxes are mainly for control systems,

they can be “abused" for solutions of general problems related to fractional calculus as well.

10

Page 2

2Will-be-set-by-IN-TECH

2. Fractional calculus fundamentals

2.1 Special functions

Here we should mention the most important function used in fractional calculus - Euler’s

gamma function, which is defined as

?∞

This function is a generalization of the factorial in the following form:

Γ(n) =

0

tn−1e−tdt.(1)

Γ(n) = (n − 1)! (2)

This gamma function is directly implemented in the Matlab with syntax []=gamma().

Another function, which plays a very important role in the fractional calculus, was in fact

introduced in 1953. It is a two-parameter function of the Mittag-Leffler type defined as

(Podlubny, 1999):

∞

∑

k=0

The Mittag-Leffler function (3) can be expressed in the integral representation as

Eα,β(z) =

zk

Γ(αk + β),

(α > 0,

β > 0). (3)

Eα,β(z) =

1

2πi

?

C

tα−βet

tα− zdt,(4)

the contour C starts and ends at −∞ and circles around the singularities and branch points of

the integrand.

There are some relationships (given e.g. in (Djrbashian, 1993; Podlubny, 1999)):

E1,1(z) = ez,

E1/2,1(√z) =

2

√πe−zerfc(−√z),

E2,1(z) = cosh(√z),

E2,1(−z2) = cos(z),

E1,2(z) =ez− 1

z

.

For β = 1 we obtain the Mittag-Leffler function in one parameter (Podlubny, 1999):

Eα,1(z) =

∞

∑

k=0

zk

Γ(αk + 1)≡ Eα(z). (5)

For the numerical evaluation of the Mittag-Leffler function (3) with the default accuracy set

to 10−6the Matlab routine [e]=mlf(alf,bet,c,fi), written by Podlubny and Kacenak

(2005) can be used. Another Matlab function f=gml_fun(a,b,c,x,eps0)for a generalized

Mittag-Leffler function was created by YangQuan Chen (Chen, 2008).

In Fig. 1(a) and Fig. 1(b) are plotted the well-known functions (ezand cos(z)) computed via

the Matlab routine []=mlf() created for the evaluation of the Mittag-Leffler function.

Another important function Ek(t,λ;μ,ν) of the Mittag-Leffler type was introduced by

(Podlubny, 1999). The function is defined by

Ek(t,λ;μ,ν) = tμk+ν−1E(k)

μ,ν(λtμ),

(k = 0,1,2,...), (6)

240

Engineering Education and Research Using MATLAB

Page 3

Fractional Derivatives, Fractional Integrals, and Fractional Differential Equations in Matlab3

−2−10

z

12

0

2

4

6

8

E1,1(z)

(a) E1,1(z),where −2 < z < 2

0246

−1

−0.5

0

0.5

1

z

E2,1(−z2)

(b) E2,1(−z2), where 0 < z < 2π

Fig. 1. Mittag-Leffler function (3) for various parameters

where E(k)

μ,ν(z) is k-th derivative of the Mittag-Leffler function of two parameters given by

E(k)

μ,ν(z) =

∞

∑

i=0

(i + k)! zi

i! Γ(μi + μk + ν),

(k = 0,1,2,...). (7)

2.2 Fractional derivatives and integrals

Fractional calculus is a generalization of integration and differentiation to non-integer-order

fundamental operatoraDα

continuous integrodifferential operator is defined as

⎧

⎪

The three most frequently used definitions for the general fractional differintegral are: the

Grünwald-Letnikov (GL) definition, the Riemann-Liouville (RL) and the Caputo definition

(Miller and Ross, 1993; Oldham and Spanier, 1974; Podlubny, 1999). Other definitions are

connected with well-known names as for instance Weyl, Fourier, Cauchy, Abel, etc.

t, where a and t are the bounds of the operation and α ∈ R. The

aDα

t=

⎪

⎩

⎨

dα

dtα

1

?t

: α > 0,

: α = 0,

a(dτ)α: α < 0.

The GL definition is given as

aDα

tf(t) = lim

h→0h−α

[t−a

∑

j=0

h]

(−1)j

?α

j

?

f(t− jh), (8)

where [.] means the integer part. The RL definition is given as

aDα

tf(t) =

1

Γ(n − α)

dn

dtn

?t

a

f(τ)

(t − τ)α−n+1dτ, for

(n − 1 < α < n), (9)

241

Fractional Derivatives, Fractional Integrals, and Fractional Differential Equations in Matlab

Page 4

4Will-be-set-by-IN-TECH

where Γ(.) is the gamma function. The Caputo definition of fractional derivatives can be

written as

aDα

tf(t) =

1

Γ(n − α)

?t

a

f(n)(τ)

(t − τ)α−n+1dτ,for

(n − 1 < α < n).(10)

In this chapter we will consider mainly the GL, the RL, and the Caputo definitions. This

consideration is based on the fact that, for a wide class of functions, the three best known

definitions - GL, RL, and Caputo - are equivalent under some conditions (Podlubny, 1999).

Asit wasalreadymentioned,under

Riemann-Liouville and the Caputo derivative are equivalent.

Riemann-Liouville fractional derivative asRL

then the relationship between them is:

the homogeneousinitialconditions

Let us denote the

the

aDα

tt(t) and the Caputo definition asC

aDα

tf(t),

RL

aDα

tt(t) =C

aDα

tf(t)+

n−1

∑

k=0

(t − a)k−α

Γ(k − α + 1)f(k)(a),

for f(k)(a) = 0 (k = 0,1,...,n − 1).

The initial conditions for the fractional-order differential equations with the Caputo

derivatives are in the same form as for the integer-order differential equations.

advantage because applied problems require definitions of fractional derivatives, where there

are clear interpretations of initial conditions, which contain f(a), f

In addition, for approximation purpose we consider the Laplace transform method of the

fractional differintegralaDα

RL and Caputo definitions, under the zero initial conditions is:

It is an

?(a), f

??(a), etc.

t. The Laplace transform of the join operator of order α for the GL,

L{0Dα

tf(t); s} = sαF(s). (11)

Laplace transform technique is considered as an efficient way in solving differential equations

with integer order and fractional order as well. For differential equations with fractional

order, the Laplace transform technique works effectively only for relatively simple equations,

because of the difficulties of calculating inversion of Laplace transforms. This problem was

solved by applying a numerical inverse Laplace transform algorithms in fractional calculus

(Sheng et al., 2011). Three numerical inverse Laplace transform algorithms in Matlab, named

invlap(), gavsteh(), and nilt(), were described there and tested.

The Laplace transforms for several known Mittag-Leffler type functions are summarized as

follows (Magin, 2006; Podlubny, 1999):

L{Eα(−λtα)} =

sα−1

sα+ λ,

sα−β

sα+ λ,

L{tα−1Eα,α(−λtα)} =

1

sα+ λ,

k!sα−β

(sα∓ λ)k+1.

(12)

L{tβ−1Eα,β(−λtα)} =

L{Ek(t,±λ;α, β)} =

2.3 Numerical methods for fractional calculus

There are many numerical methods appropriate for the fractional calculus computation. They

were describedinseveral worksand a goodsurveycan be found in (Vinagre et al., 2000; 2003).

In the above-mentioned papers are described the time domain and frequency methods in

242

Engineering Education and Research Using MATLAB

Page 5

Fractional Derivatives, Fractional Integrals, and Fractional Differential Equations in Matlab5

the form of IIR and FIR approximations together with illustrative examples. Some of the

mentioned frequency methods in both forms of approximation have been realized as the

Matlab routinesinDuarteValerio’stoolboxcalledninteger(seedetail reviewin(Valério,2005)).

Also created in this toolbox was a Simulink block nid for fractional derivative and integral,

where the order of derivative/integral and method of its approximation can be selected.

2.3.1 Grünwald-Letnikov method

For numerical calculation of fractional-order derivatives we can use the relation (13) derived

from the GL definition (8). This approach is based on the fact that for a wide class of functions

the threedefinitions -GL (8), RL(9), and Caputo’s(10) -areequivalentif f(a) = 0. The relation

for the explicit numerical approximation of q-th derivative at the points kh, (k = 1,2,...) has

the following form (Dorˇ cák, 1994; Podlubny, 1999):

(k−Lm/h)Dq

tkf(t) ≈ h−q

k

∑

j=0

(−1)j

?q

j

?

f(tk−j) = h−q

k

∑

j=0

c(q)

j

f(tk−j), (13)

where Lmis the “memory length", tk= kh, h is the time step of calculation and c(q)

0,1,...,k) are binomial coefficients. For their calculation we can use for instance the following

expression (Dorˇ cák, 1994):

j

(j =

c(q)

0

= 1,

c(q)

j

=

?

1 −1 + q

j

?

c(q)

j−1. (14)

The binomial coefficients c(q)

Writing the factorial as a gamma function (2), it allows the binomial coefficient to be

generalized to non-integer arguments. We can write the relations:

?q

Obviously, for this simplification we pay a penalty in the form of some inaccuracy. If f(t) ≤

M, we can easily establish the following estimate for determining the memory length Lm,

providing the required accuracy ?:

j

(j = 0,1,...,k) can be also expressed by using a factorial.

(−1)j

j

?

= (−1)j

Γ(q+ 1)

Γ(j+ 1)Γ(q − j +1)=

Γ(j − q)

Γ(−q)Γ(j+ 1). (15)

Lm≥

?

M

?|Γ(1− q)|

?1/q

.(16)

The above-describednumericalmethodiscalledPowerSeriesExpansion(PSE)ofagenerating

function. It is important to note that PSE leads to approximation in the form of polynomials,

that is, the discretized fractional operator is in the form of FIR filter, which has only zeros

(Chen and Moore, 2002; Vinagre et al., 2003).

The resulting discrete transfer function, approximating fractional-order operators, can be

expressed in z-domain as follows:

0D±r

kTG(z) =Y(z)

F(z)=

?1

T

?±r

PSE

??

1 − z−1?±r?

n

≈ T∓rRn(z−1), (17)

243

Fractional Derivatives, Fractional Integrals, and Fractional Differential Equations in Matlab