3 releases

0.1.2 Jan 4, 2025
0.1.1 Jan 4, 2025
0.1.0 Jan 4, 2025

#364 in Algorithms

Download history 303/week @ 2025-01-01 24/week @ 2025-01-08

327 downloads per month

MIT license

28KB
379 lines

Build Status REUSE Documentation PyPI

mittagleffler

This library implements the two-parameter Mittag-Leffler function.

Currently only the algorithm described in the paper by Roberto Garrapa (2015) is implemented. This seems to be the most accurate and computationally efficient method to date for evaluating the Mittag-Leffler function.

Links

Other implementations

  • ml.m (MATLAB): implements three-parameter Mittag-Leffler function.
  • ml_matrix.m (MATLAB): implements the matrix-valued two-parameter Mittag-Leffler function.
  • MittagLeffler.jl (Julia): implements the two-parameter Mittag-Leffler function and its derivative.
  • MittagLeffler (R): implements the three-parameter Mittag-Leffler function.
  • mittag-leffler (Python): implements the three-parameter Mittag-Leffler function.
  • mlf (Fortran 90): implements the three-parameter Mittag-Leffler function.
  • mlpade (MATLAB): implements the two-parameter Mittag-Leffler function.
  • MittagLeffler (Stata): implements the three-parameter Mittag-Leffler function.
  • MittagLefflerE (Mathematica): implements the two-parameter Mittag-Leffler function.

Rust Crate

The library is available as a Rust crate that implements the main algorithms. Evaluating the Mittag Leffler function can be performed directly by

use mittagleffler::MittagLeffler;

let alpha = 0.75;
let beta = 1.25;
let z = Complex64::new(1.0, 2.0);
println!("E_{}_{}({}) = {}", alpha, beta, z, z.mittag_leffler(alpha, beta));

let z: f64 = 3.1415;
println!("E_{}_{}({}) = {}", alpha, beta, z, z.mittag_leffler(alpha, beta));

This method will call the best underlying algorithm and take care of any special cases that are known in the literature, e.g. for (alpha, beta) = (1, 1) we know that the Mittag-Leffler function is equivalent to the standard exponential. To call a specific algorithm, we can do

use mittagleffler::GarrappaMittagLeffler

let eps = 1.0e-8;
let ml = GarrappaMittagLeffler::new(eps);

let z = Complex64::new(1.0, 2.0);
println!("E_{}_{}({}) = {}", alpha, beta, z, ml.evaluate(z, alpha, beta));

The algorithm from Garrappa (2015) has several parameters that can be tweaked for better performance or accuracy. They can be found in the documentation of the structure, but should not be changed unless there is good reason!

Python Bindings

The library also has Python bindings (using pyo3) that can be found in the python directory. The bindings are written to work with scalars and with numpy arrays equally. For example

import numpy as np
from pymittagleffler import mittag_leffler

alpha, beta = 2.0, 2.0
z = np.linspace(0.0, 1.0, 128)
result = mittag_leffler(z, alpha, beta)

These are available on PyPI under the name pymittagleffler.

Dependencies

~1MB
~20K SLoC