# Fractional derivative calculator in Mathematical Softwares

Are there any fractional derivative calculators available in any Computer Algebra Systems or other Mathematical softwares?

I wish to find the value of $$D^a\ln(1+e^x)$$ for $$x=0,a=0.9$$. Is there a way to do it using manually or a suitable open source software? From this paper, page 7546, the value of the function above is defined as softplus activation function, and its fractional derivative is given as $$\lim\limits_{h\to0}\dfrac1{h^{a}}\sum_{n=0}^{\infty}(-1)^n\dfrac{\Gamma(a+1)\left(1+e^{x-nh}\right)}{\Gamma(n+1)\Gamma(1-n+a)}$$ I am unable to understand how to evaluate this limit at $$x=0,a=0.9$$. The paper linked has shown the plot of the function as different values of $$a$$, but it is unclear how or what software they used. Any hints? Thanks beforehand.

• Are you aware of the convolutional formula : $\displaystyle D^{\alpha }f(x)={\frac {1}{\Gamma (1-\alpha )}}{\frac {d}{dx}}\int _{0}^{x}{\frac {f(t)}{\left(x-t\right)^{\alpha }}}\,dt$ ? Jun 27, 2022 at 17:55
• See here Jun 27, 2022 at 18:39

### Mathematical Softwares

That's actually a good question. Up to now, only a few programs can determine derivatives of fractional order, and those that can can only do so for a few specific functions.

The best-known example of this is probably Wolfram|Alpha: The command FractionalD[f[x], {x, α}] gives the Riemann–Liouville Fractional Derivative of order $$\alpha$$ of the function $$f$$ with respect of $$x$$ ($$\operatorname{_{0}D^{\alpha}_{x}}\left( f\left( x \right) \right)$$). However, this only works for a few functions so far like some monomials. Wolfram|Alpha also has a small article about the command in which they explain the possibilities that the command opens up (see Wolfram > Language > Reference > FractionalD). There is also the command CaputoD[f, {x, α}], wich gives the Caputo Fractional Differintegral of order $$\alpha$$ of the function $$f$$ with respect of $$x$$ ($$\operatorname{_{0}^{C}D^{\alpha}_{x}}\left( f\left( x \right) \right)$$). Wolfram|Alpha has also a small article about the command in which they explain the possibilities that the command opens up (see Wolfram > Language > Reference > CaputoD).

### Manual Calculation of the Fractional Derivative

#### Calculation Via Series Expansion

In this method we try to split the function to be differentiated into an infinite sum of simpler differentiated functions and then differentiate them. Your example $$\ln\left( 1 + e^{x} \right) = \ln\left( 1 + z \right)$$ lends itself perfectly to this, since there is a wonderfully simple series expansion around $$1$$ given by $$\ln\left( 1 + z \right) = \sum_{k = 1}^{\infty}\left[ \frac{\left( -1 \right)^{k + 1}}{k} \cdot z^{k} \right]$$ aka $$\ln\left( 1 + e^{x} \right) = \sum_{k = 1}^{\infty}\left[ \frac{\left( -1 \right)^{k + 1}}{k} \cdot \left( e^{x} \right)^{k} \right] = \sum_{k = 1}^{\infty}\left[ \frac{\left( -1 \right)^{k + 1}}{k} \cdot e^{k \cdot x} \right]$$ (Mercator Series).

Using this, we simply get this: \begin{align*} \operatorname{D^{a}}\left[ \ln\left( 1 + e^{x} \right) \right] &= \operatorname{D^{a}}\left[ \sum_{k = 1}^{\infty}\left[ \frac{\left( -1 \right)^{k + 1}}{k} \cdot e^{k \cdot x} \right] \right]\\ \operatorname{D^{a}}\left[ \ln\left( 1 + e^{x} \right) \right] &= \sum_{k = 1}^{\infty}\left[ \operatorname{D^{a}}\left[ \frac{\left( -1 \right)^{k + 1}}{k} \cdot e^{k \cdot x} \right] \right]\\ \operatorname{D^{a}}\left[ \ln\left( 1 + e^{x} \right) \right] &= \sum_{k = 1}^{\infty}\left[ \frac{\left( -1 \right)^{k + 1}}{k} \cdot \operatorname{D^{a}}\left[ e^{k \cdot x} \right] \right]\\ \operatorname{D^{a}}\left[ \ln\left( 1 + e^{x} \right) \right] &= \sum_{k = 1}^{\infty}\left[ \frac{\left( -1 \right)^{k + 1}}{k} \cdot \operatorname{E_{a}}\left( k \cdot x \right) \right]\\ \end{align*} where $$\operatorname{E_{\alpha}}\left( \cdot \right)$$ is the the $$\alpha$$-Fractional Exponential Function. It simply represents the $$\alpha$$-th derivative of $$\exp\left( \cdot \right)$$. However, the exact representation of it is not so simple, since, as Euler already showed, there are different possibilities $$\alpha$$ -th derivative of $$\exp\left( \cdot \right)$$, e.g. $$\operatorname{D^{a}}\left[ e^{\lambda \cdot x} \right] = \lambda^{a} \cdot e^{\lambda \cdot x}$$ (Formula $$\left( 1 \right)$$) and $$\operatorname{D^{a}}\left[ e^{\lambda \cdot x} \right] = \lambda^{n} \cdot \sum_{k = 0}^{\infty}\left[ \frac{\lambda^{k - n}}{\left( k - a \right)!} \cdot x^{k - a} \right]$$ (Formula $$\left( 2 \right)$$), which can be simplified with the Gamma Function and Incomplete Gamma Functions.

##### Via using $$\operatorname{D^{a}}\left[ e^{\lambda \cdot x} \right] = \lambda^{a} \cdot e^{\lambda \cdot x}$$

Via using Formula $$\left( 1 \right)$$, you would get this: \begin{align*} \operatorname{D^{a}}\left[ \ln\left( 1 + e^{x} \right) \right] &= \sum_{k = 1}^{\infty}\left[ \frac{\left( -1 \right)^{k + 1}}{k} \cdot k^{a} \cdot e^{k \cdot x} \right]\\ \operatorname{D^{a}}\left[ \ln\left( 1 + e^{x} \right) \right] &= -\operatorname{Li_{1 - a}}\left( -e^{x} \right) \tag{*}\\ \end{align*} where $$\operatorname{Li_{\alpha}}\left( \cdot \right)$$ is the Polylogarithm.

Aka a solution to your question is $$-\operatorname{Li_{1 - 0.9}}\left( -e^{0} \right) = -\operatorname{Li_{0.1}}\left( -1 \right) = 0.522270\dots$$.

A plot of this would looks like this:

##### Via using $$\operatorname{D^{a}}\left[ e^{\lambda \cdot x} \right] = \lambda^{n} \cdot \sum_{k = 0}^{\infty}\left[ \frac{\lambda^{k - n}}{\left( k - a \right)!} \cdot x^{k - a} \right]$$

Via using Formula $$\left( 2 \right)$$, you would get this: \begin{align*} \operatorname{D^{a}}\left[ \ln\left( 1 + e^{x} \right) \right] &= \sum_{k = 1}^{\infty}\left[ \frac{\left( -1 \right)^{k + 1}}{k} \cdot k^{a} \cdot e^{k \cdot x} \right]\\ \operatorname{D^{a}}\left[ \ln\left( 1 + e^{x} \right) \right] &= \sum_{k = 1}^{\infty}\left[ \frac{\left( -1 \right)^{k + 1}}{k} \cdot k^{a} \cdot \left( \sum_{k = 0}^{\infty}\left[ k^{n} \cdot \frac{k^{k - a}}{\left( k - a \right)!} \cdot x^{k - a} \right] \right)^{k \cdot x} \right] \tag{*}\\ \end{align*} wich is not difend for $$a > 0 ~\wedge~ x = 0$$.

#### Calculation Via "Euler Method"

Euler had come up with his own method for some fractional derivations (see Euler's Approach). He has sorted the derivatives of the function by order and is trying to find a pattern in it. He then tried to transfer this pattern from integer orders to fractional ones.

But here is a problem. Without knowledge of special functions, one cannot come up with a general formula for a Derivative of the $$\alpha$$th order. We would only come up with a special case of Faà di Bruno's Formula.

However, if we assume knowledge of the Polylogarithms and write all derivations with them, we could see a general pattern: \begin{align*} \operatorname{D^{0}}\left[ \ln\left( 1 + e^{x} \right) \right] &= -\operatorname{Li_{-1}}\left( -e^{x} \right)\\ \operatorname{D^{1}}\left[ \ln\left( 1 + e^{x} \right) \right] &= -\operatorname{Li_{0}}\left( -e^{x} \right)\\ \operatorname{D^{2}}\left[ \ln\left( 1 + e^{x} \right) \right] &= -\operatorname{Li_{1}}\left( -e^{x} \right)\\ \operatorname{D^{3}}\left[ \ln\left( 1 + e^{x} \right) \right] &= -\operatorname{Li_{2}}\left( -e^{x} \right)\\ \operatorname{D^{4}}\left[ \ln\left( 1 + e^{x} \right) \right] &= -\operatorname{Li_{3}}\left( -e^{x} \right)\\ \operatorname{D^{5}}\left[ \ln\left( 1 + e^{x} \right) \right] &= -\operatorname{Li_{4}}\left( -e^{x} \right)\\ &\cdots\\ \operatorname{D^{a}}\left[ \ln\left( 1 + e^{x} \right) \right] &= -\operatorname{Li_{1 - a}}\left( -e^{x} \right) \tag{*}\\ \end{align*}

This brings us to the same solution as with Formula $$\left( 1 \right)$$: $$-\operatorname{Li_{1 - 0.9}}\left( -e^{0} \right) = -\operatorname{Li_{0.1}}\left( -1 \right) = 0.522270\dots$$

#### Calculation Via Using Special Differential Operators

##### Riemann–Liouville Operator

The Riemann–Liouville Fractional Operator, on the other hand, uses the formulas for simplifying mutible integrals into single integral for many other differential operators: \begin{align*} \operatorname{_{a}D^{-v}_{x}}\left[ f\left( x \right) \right] \equiv \frac{1}{\Gamma\left( v \right)} \cdot \int\limits_{a}^{x} f\left( u \right) \cdot \left( x - u \right)^{v - 1} \, \operatorname{d}u \tag{3}\\ \end{align*} where $$\Gamma\left( \cdot \right)$$ ist the Complte Gamma Function.

This operator has a so-called Convolutional Formula, wich is just spezial case with $$a = 0$$, but it also takes advantage of the fact that integrating and deriving cancel each other out: \begin{align*} \operatorname{_{0}D^{v}_{x}}\left[ f\left( x \right) \right] \equiv \frac{1}{\Gamma\left( 1 - v \right)} \cdot \operatorname{D^{1}_{x}}\left[ \int\limits_{0}^{x} f\left( u \right) \cdot \left( x - u \right)^{-v}\, \operatorname{d}u \right] \tag{4}\\ \end{align*}

Using Formula $$\left( 4 \right)$$ gives you a simplification of your Problem. But I'll leave the solution with this formula to you as an exercise for you.

You can numerically solve fractional differential equations by using the open-source, Matlab-compatible code that I discussed and used in my answer to a different question: Garrappa, Roberto, Numerical solution of fractional differential equations: a survey and a software tutorial, ZBL06916890.

• But why should you calculate it numerically when you can do it exactly with the common formulas? Apr 8, 2023 at 23:17
• @KevinDietrich, eventually you have to perform a numerical calculation. Many of the exact formulas are not well suited to numerical integration. Apr 11, 2023 at 1:29