File Exchange

## The Mittag-Leffler function

version 1.3.0.0 (11.7 KB) by Roberto Garrappa

### Roberto Garrappa (view profile)

Evaluation of the Mittag-Leffler function with 1, 2 or 3 parameters

Updated 07 Dec 2015

Evaluation of the Mittag-Leffler (ML) function with 1, 2 or 3 parameters by means of the OPC algorithm [1]. The routine evaluates an approximation Et of the ML function E such that |E-Et|/(1+|E|) approx 1.0e-15

E = ML(z,alpha) evaluates the ML function with one parameter alpha for the corresponding elements of z; alpha must be a real and positive scalar. The one parameter ML function is defined as
E = sum_{k=0}^{infty} z^k/Gamma(alpha*k+1)
with Gamma the Euler's gamma function.

E = ML(z,alpha,beta) evaluates the ML function with two parameters alpha and beta for the corresponding elements of z; alpha must be a real and positive scalar and beta a real scalar. The two parameters ML function is defined as

E = sum_{k=0}^{infty} z^k/Gamma(alpha*k+beta)

E = ML(z,alpha,beta,gama) evaluates the ML function with three parameters alpha, beta and gama for the corresponding elements of z; alpha must be a real scalar such that 0<alpha<1, beta any real scalar and gama a real and positive scalar; the arguments z must satisfy |Arg(z)| > alpha*pi. The three parameters ML function is defined as

E = sum_{k=0}^{infty} Gamma(gama+k)*z^k/Gamma(gama)/k!/Gamma(alpha*k+beta)

NOTE: This routine implements the optimal parabolic contour (OPC) algorithm described in [1] and based on the inversion of the Laplace transform on a parabolic contour suitably choosen in one of the regions of analyticity of the Laplace transform.

REFERENCES:
[1] R. Garrappa, Numerical evaluation of two and three parameter Mittag-Leffler functions, SIAM Journal of Numerical Analysis, 2015, 53(3), 1350-1369

Please, report any problem or comment to : roberto dot garrappa at uniba dot it

### Cite As

Roberto Garrappa (2020). The Mittag-Leffler function (https://www.mathworks.com/matlabcentral/fileexchange/48154-the-mittag-leffler-function), MATLAB Central File Exchange. Retrieved .

David Roodman

### David Roodman (view profile)

Professor Garrappa, thanks very much for making this available. I have just ported it to Stata/Mata. See https://github.com/droodman/Mittag-Leffler-for-Stata. I validated the implementation with Tran Quoc Viet's excellent set of test values.

Mata Labor

Splendid!

Roberto Garrappa

### Roberto Garrappa (view profile)

Dear Golan Bel, thank you for your comment. My aim was to avoid the possibility of providing a matrix as input since the results could be confused with those from the evaluation of the ML function with a matrix argument, which is a completely different computation. I will modify the code in order to better clarify this point and give a warning when on tries to give a matrix as input. If you are interested in evaluating the matrix ML function I suggest the code http://www.mathworks.com/matlabcentral/fileexchange/66272-mittag-leffler-function-with-matrix-arguments and the related paper https://doi.org/10.1007/s10915-018-0699-5

Golan Bel

### Golan Bel (view profile)

I believe that there is a problem with the code when trying to provide a matrix as an input.
The line in the code where the loop runs from 1:length(z) should be modified to run from 1:(Number of elements in the input array). For example for a matrix it should be N*M where [N,M]=size(z);

Junsheng Duan

Tran Quoc Viet

### Tran Quoc Viet (view profile)

Dear Prof. Roberto Garrappa,

Thank you very much.

Here is the place I put the Fortran module which was translated from your Matlab code:

This version of code supports both scalar and array (1D, 2D, 3D) input. Therein I have also released 76 test cases for calculation of both the Mittag-Leffler function and it derivative. (Well tested with gfortran 4.9.2 and ifort 18.0.0.)

You know, it take a couple of days to separate this module out of my own library. That is the reason why I reply you quite late. From now on this module is portable and be able to work independently.

Best regards,
Viet.

Roberto Garrappa

### Roberto Garrappa (view profile)

Dear Tran Quoc Viet, thank you very much for you comments and appreciation. A description of the code is available in the SIAM paper [1]. Since the algorithm is based on the numerical inversion of the Laplace transform, the variable t is the real value of the generalization of the ML function for which the LT is known. Anyway, in order to evaluate the ML function, and not its generalization, the variable t is conventionally put equal to 1 and therefore it could be eliminated from the code. You are very welcome to translate the code in Fortran and share it on public domains. Please, just insert in the code a reference to the paper [1] where the algorithm is described.

[1] R. Garrappa, Numerical evaluation of two and three parameter Mittag-Leffler functions, SIAM Journal of Numerical Analysis, 2015, 53(3), 1350-1369

Tran Quoc Viet

### Tran Quoc Viet (view profile)

Dear Prof. Roberto Garrappa,
Your code works excellently when compared with others, e.g. the one from Prof. Igor Podlubny. It runs fast and especially much more accurate than the others. When we increase the value of epilson, e.g. from 1.0e-15 to 1.0e-8. It runs faster than that of Prof. Igor Podlubny with a controllable and acceptable accuracy.

Could I ask you one question? What is the role of the "t" in function E = LTInversion(t,lambda,alpha,beta,gama,log_epsilon) ?

Recently I have translated your Matlab code into Fortran language. You know, performance of the Fortran code runs fantastically, like an intrinsic function. Could I share it on public domain?

Beiping Duan

### Beiping Duan (view profile)

Great! Much faster and more accurate than mlf.m uploaded by Prof. Igor Podlubny, which can not reach the desired accuracy when alpha>0.6.

Thank you very much!

Hongguang Sun

John Hollkamp

### John Hollkamp (view profile)

Thanks for the .m file! One question about the order alpha though. The code requires that alpha must be a real and positive scalar. Is it possible to alter the code so that it can handle complex values of alpha and still accurately evaluate the Mittag-Leffler function (output should be complex if alpha is complex)? Thanks!

Ivan Matychyn

Roberto Garrappa

### Roberto Garrappa (view profile)

Dear Sam, this code is not devised for matrix arguments. Anyway, we are working on this subject and we should release a code of this kind in a couple of months.

Sam

### Sam (view profile)

Thanks for this .m file. I would like to ask if this can be used for MLF where z is a matrix i.e MLF with matrix argument. If no, is there available source code to compute MLF with matrix argument.

Roberto Garrappa

### Roberto Garrappa (view profile)

The algorithm implemented by this code is described in the paper:
R. Garrappa, Numerical Evaluation of two and three parameter Mittag-Leffler functions, SIAM Journal of Numerical Analysis, 2015, 53(3), 1350-1369 - doi: http://dx.doi.org/10.1137/140971191

Pantelis Sopasakis

azurekim89

Roberto Garrappa

### Roberto Garrappa (view profile)

Dear Amr AndelAty, this function works for arguments on the whole complex plane. The paper in the reference is still under review. Thank you for your suggestion.

Amr AbdelAty

Amr AbdelAty

### Amr AbdelAty (view profile)

This paper "Evaluation of generalized Mittag–Leffler functions on the real line" says that the argument should be positive. Does this apply to this file?
I couldn't find the paper in the references.
Also I suggest removing the imaginary part of the output if the input is pure real.