Fractional derivative API
FractionalCalculus.jl has a disciplinary type system, by specifying which type you want to use, you can use the relating algorithm to compute fractional differentiation and fractional integral.
This page contain all of the existing API we can use for computing fractional derivative.
FractionalCalculus.fracdiff
— FunctionCaputo sense fractional derivative.
fracdiff(f::Function, α, start_point, end_point, step_size ::Caputo)
Example:
julia> fracdiff(x->x^5, 0.5, 0, 2.5, 0.0001, Caputo_Direct())
Returns a tuple (result, error), which means the value of this derivative is 141.59714979764541, and the error estimate is 1.1532243848672914e-6.
When the input end points is an array, fracdiff will compute
Refer to Caputo derivative
Caputo sense fractional derivative with first derivative known.
fracdiff(fd, α, start_point, end_point, Caputo_Direct_First_Diff_Known())
If the first order derivative of a function is already known, we can use this method to compute the fractional order derivative more precisely.
The inout function should be the first order derivative of a function
Example
julia> fracdiff(x->5*x^4, 0.5, 0, 2.5, Caputo_Direct_First_Diff_Known())
Return the semi-derivative of $f(x)=x^5$ at $x=2.5$.
Compared with Caputo_Direct method, this method don't need to specify step size, more precision are guaranteed.
Caputo sense fractional derivative with first and second derivative known.
fracdiff(fd1, fd2, α, start_point, end_point, Caputo_Direct_First_Second_Diff_Known)
If the first and second order derivative of a function is already known, we can use this method to compute the fractional order derivative more precisely.
Example
julia> fracdiff(x->5*x^4, x->20*x^3, 0.5, 0, 2.5, Caputo_Direct_First_Second_Diff_known())
Return the semi-derivative of $f(x)=x^5$ at $x=2.5$.
Compared with Caputo_Direct method, this method don't need to specify step size, more precision are guaranteed.
Caputo sense Piecewise algorithm
fracdiff(f, α, end_point, h, Caputo_Piecewise())
Using the piecewise algorithm to obtain the fractional derivative at a specific point.
Example
julia> fracdiff(x->x^5, 0.5, 2.5, 0.001, Caputo_Piecewise())
Return the fractional derivative of $f(x)=x^5$ at point $x=2.5$.
Caputo sense Diethelm computation
fracdiff(f, α, end_point, h, Caputo_Diethelm())
Using quadrature weights(derived from product trapezoidal rule) to approximate the derivative.
Example
julia> fracdiff(x->x, 0.5, 1, 0.007, Caputo_Diethelm())
1.128378318687192
!!!info "Scope" 0 < α < 1
fracdiff()
Use the high precision algorithm to compute the Caputo sense fractional derivative.
Grünwald–Letnikov sense fractional dervivative.
fracdiff(f, α, start_point, end_point, GL_Direct())
Example:
julia> fracdiff(x->x^5, 0, 0.5, GL_Direct())
Please note Grunwald-Letnikov sense fracdiff only support 0 < α < 1.
Please refer to Grünwald–Letnikov derivative for more details.
Grünwald Letnikov sense derivative approximation
fracdiff(f, α, end_point, h, GL_Multiplicative_Additive())
Grünwald–Letnikov multiplication-addition-multiplication-addition··· method to approximate fractional derivative.
Example
julia> fracdiff(x->x, 0.5, 1, 0.007, GL_Multiplicative_Additive())
1.127403405642918
The GL_Multiplicative_Additive
method is not accruate, please use it at your own risk.
Grünwald Letnikov sense derivative approximation
fracdiff(f, α, end_point, h, GL_Lagrange_Three_Point_Interp())
Using Lagrange three poitns interpolation to approximate the fractional derivative.
Example
julia> fracdiff(x->x, 0.5, 1, 0.007, GL_Lagrange_Three_Point_Interp())
1.1283963376811044
The GL_Multiplicative_Additive
method is not accruate, please use it at your own risk.
Grünwald Letnikov sense derivative approximation
fracdiff(f::Union{Function, Number}, α::AbstractArray, end_point, h, ::GL_Finite_Difference)::Vector
Use finite difference method to obtain Grünwald Letnikov sense fractional derivative.
Example
julia> fracdiff(x->x, 0.5, 1, 0.01, GL_Finite_Difference())
1.1269695801851276
GL_Finite_Difference
method is not accruate, please use it at your own risk.
fracdiff(f, α, point, h, GL_High_Precision())
Use the high precision algorithms to compute the Grunwald letnikov fractional derivative.
The value interval passing in the function should be a array!
fracdiff(f, α, a, x, h, Hadamard_LRect())
Compute Hadamard sense using left rectangular formula.
fracdiff(f, α, a, x, h, Hadamard_Trap())
Compute Hadamard sense using right rectangular formula.
fracdiff(f, α, a, x, h, Hadamard_Trap())
Compute Hadamard sense using Trapezoidal formula.
fracdiff(f, α, end_point, h, Riesz_Symmetric())
Compute fractional derivative of Riesz sense using Triangular Strip Matrix algorithm.
Riemann Liouville sense derivative approximation
fracdiff(f, α, end_point, h, RLDiff_Approx())
Using approximation to obtain fractional derivative value.
Example
julia> fracdiff(x->x^5, 0.5, 2.5, 0.0001, RLDiff_Approx())
The RLDiff_Approx algorithm only support for 0 < α < 1.
Riemann Liouville sense derivative using Triangular Strip Matrix to discrete and compute.
fracdiff(f, α, end_point, h, RLDiff_Matrix())
Using Triangular Strip Matrix to approximate fractional derivative.
Example
julia> fracdiff(x->x^5, 0.5, 2.5, 0.0001, RLInt_Matrix())
Triangular Strip Matrix method returns the derivative in the interval $[0, T]$ in Vector
With the advancing Triangular Strip Matrix method, you can not only compute fractional derivatives, integer order, higher order derivative is also supported!!
Try to set α as an integer, arbitrary integer of course! I promise you would enjoy it😏
Numerical methods for fractional calculus by Li, Changpin Page 57
Linear Spline Interpolation
FractionalCalculus.FracDiffAlg
— TypeBase type of fractional differentiation algorithms, in FractionalCalculus.jl, all of the fractional derivative algorithms belong to FracDiffAlg
FractionalCalculus.Caputo
— TypeCaputo sense fractional derivative algorithms, please refer to Caputo derivative for more details.
FractionalCalculus.GL
— TypeGrünwald–Letnikov sense fractional derivative algorithms, please refer to Grünwald–Letnikov derivative for more details
FractionalCalculus.RLDiff
— TypeRiemann-Liouville sense fractional derivative algorithms, please refer to Riemann-Liouville derivative
FractionalCalculus.Hadamard
— TypeHadamard sense fractional derivative algorithms.
FractionalCalculus.Riesz
— TypeRiesz sense fractional derivative algorithms.
FractionalCalculus.Caputo_Direct
— TypeNote Caputo Direct algorithms belong to direct computing, precise are ensured, but maybe cause more memory allocation and take more compilation time.
Using the direct mathematic expression:
\[^CD_t^α=\frac{1}{\Gamma(n-α)}\int_0^t\frac{f^{(n)}(τ)}{(t-τ)^{α+1-n}}\]
As for the derivative inside the integral, we use the Complex Step Differentiation to obtain a more accurate value.
FractionalCalculus.Caputo_Direct_First_Diff_Known
— TypeWith first derivative known, we can direct use the derivative to compute a more accurate result.
FractionalCalculus.Caputo_Direct_First_Second_Diff_Known
— TypeWith first and second derivative known, we can direct use derivative and second derivative to compute a more accurate result.
FractionalCalculus.Caputo_Piecewise
— TypeUsing piecewise linear interpolation function to approximate input function and combining Caputo derivative then implement summation.
FractionalCalculus.Caputo_Diethelm
— TypeDiethelm's method for computingn Caputo sense fractional derivative using product trapezoidal rule and Richardsin extrapolation
FractionalCalculus.GL_Direct
— TypeGrunwald Letnikov direct compute method to obtain fractional derivative, precision are guaranteed but cause more memory allocation and compilation time.
FractionalCalculus.GL_Finite_Difference
— TypeUsing Grünwald–Letnikov finite difference method to compute Grünwald–Letnikov sense fractional derivative.
FractionalCalculus.GL_Multiplicative_Additive
— TypeUsing Grünwald–Letnikov multiplication-addition-multiplication-addition··· method to compute fractional derivative in Grünwald Letnikov sense.
FractionalCalculus.GL_Lagrange_Three_Point_Interp
— TypeUsing Lagrange three points interpolation method to compute fractional derivative in Grünwald Letnikov sense.
FractionalCalculus.RLDiff_Approx
— TypeUsing Linear interpolation to approximate fractional derivative in Riemann Liouville fractional derivative sense.
FractionalCalculus.RLDiff_Matrix
— TypeUsing Triangular Strip Matrix to discrete the derivative.
FractionalCalculus.Hadamard_LRect
— TypeUsing finite part integral of left rectangular formula to compute the fractional hadamard derivative.
FractionalCalculus.Hadamard_RRect
— TypeUsing finite part integral of right rectangular formula to compute the fractional hadamard derivative.
FractionalCalculus.Hadamard_Trap
— TypeUsing finite part integral of trapezoidal formula to compute the fractional hadamard derivative.
FractionalCalculus.Riesz_Symmetric
— TypeUsing the Triangular Strip Matrices to compute the fractional derivative Riesz derivative.
FractionalCalculus.@fracdiff
— Macro@fracdiff(f, α, point)
Return the α-order derivative of f at specific point.
julia> @fracdiff(x->x, 0.5, 1)
1.1283791670955188
FractionalCalculus.@semifracdiff
— Macro@semifracdiff(f, point)
Return the semi-derivative of f at spedific point.
julia> @semifracdiff(x->x, 1)
1.1283791670955188