Write code for fractional calculus?

Dear,
I’m trying to write some code that need fractional calculus, and I’ve seen that Mathematica supports it (http://mathworld.wolfram.com/FractionalDerivative
.html), however, is there any built in function to work with it? I haven’t been able to find any.

Thank you very much,
Óscar

Hello

Mathematica have No built-in function to support fractional calculus.

I have pointed out Wolfram Support several years ago, but nothing at all happens. It’s too bad!.

Code below it’s not pefect but it works in most simple cases. My code is fractional calculus of Riemann–Liouville.

   FractionalD[nu_, f_, t_, opts___] := 
   Integrate[(t - x)^(-nu - 1) (f /. t -> x), {x, 0, t}, opts, 
   GenerateConditions -> False]/Gamma[-nu]
   
  FractionalD[mu_?Positive, f_, t_, opts___] := 
  Module[{m = Ceiling[mu]}, 
  D[FractionalD[-(m - mu), f, t, opts], {t, m}]]

  f1[x_] := x;
  FractionalD[1/2, f1[t], t] /. t -> x (* half derivative*)
   (* (2 Sqrt[x])/Sqrt[\[Pi]] *)

  f2[x_] := (2 Sqrt[x])/Sqrt[\[Pi]];
  FractionalD[1/2, f2[t], t] /. t -> x (* half derivative*)
   (* 1 *)

 f3[x_] := x;
 FractionalD[-1/2, f3[t], t] /. t -> x (* half integral*)
 (* (4 x^(3/2))/(3 Sqrt[\[Pi]])*)


f4[x_] :=  (4 x^(3/2))/(3 Sqrt[\[Pi]]);
 FractionalD[-1/2, f4[t], t] /. t -> x (* half integral*)
 (* x^2/2*)

 f5[x_] :=  x;
 FractionalD[-1, f5[t], t] /. t -> x (* integral*)
 (* x^2/2*)

 f6[x_] := x;
 FractionalD[1, f6[t], t] /. t -> x (* derivative. Dosen't work .Use D[f6[x],x] *)
 (* 0 *)

 f7[x_] := Sin[x];
 FractionalD[1/2, f7[t], t] /. t -> x (* half integral*)
 (* Sqrt[2] (Cos[x] FresnelC[Sqrt[2/\[Pi]] Sqrt[x]] + 
    FresnelS[Sqrt[2/\[Pi]] Sqrt[x]] Sin[x])*)

PS:A bonus

  f8[x_] := x;
  n = 1/2;
  InverseLaplaceTransform[LaplaceTransform[f8[x], x, s]*s^n, s, x] (*half derivative*)
   (* (2 Sqrt[x])/Sqrt[\[Pi]]*)
  n1 = -1/2;
  InverseLaplaceTransform[
  LaplaceTransform[f8[x], x, s]*s^n1, s, x](*half integral*)
  (* (4 x^(3/2))/(3 Sqrt[\[Pi]])*)

EDITED: 4.4.2018

Improved a little code.

 FractionalD[\[Alpha]_, f_, x_, opts___] := Integrate[(x - t)^(-\[Alpha] - 1) (f /. x -> t), {t, 0, x}, opts, GenerateConditions -> False]/Gamma[-\[Alpha]]
 FractionalD[\[Alpha]_?Positive, f_, x_, opts___] :=  Module[{m = Ceiling[\[Alpha]]}, If[\[Alpha] \[Element] Integers, D[f, {x, \[Alpha]}], 
 D[FractionalD[-(m - \[Alpha]), f, x, opts], {x, m}]]]

f[x_] := x^2
FractionalD[1, f[x], x]
(* 2 x *)

f[x_] := Sin[x]
FractionalD[-1, f[x], x]
(* 1 - Cos[x]. Where 1 is a integration constant *)

Regards,MI

Hi, Thanks for the fast reply and the code! I’ll test it right now. However, do you also happen to have the code for the Riesz fractional derivative?

Thanks!
Óscar

From this paper:

  RieszD[\[Alpha]_, f_, x_, opts___] := -1/(2*Cos[\[Alpha]*Pi/2])*1/Gamma[\[Alpha]]*(Integrate[(x - t)^(-\[Alpha] - 1) (f /. x -> t), {t, -Infinity, x}, opts, 
  GenerateConditions -> False] + Integrate[(t - x)^(-\[Alpha] - 1) (f /. x -> t), {t, x, Infinity},opts, GenerateConditions -> False])
  RieszD[\[Alpha]_?Positive, f_, x_, opts___] := Module[{m = Ceiling[\[Alpha]]}, D[RieszD[-(m - \[Alpha]), f, x, opts], {x, m}]]

  f[x_] := Exp[-x]
  RieszD[1/2, f[x], x, Assumptions -> x > 0]
  (* -(((1/2 - I/2) E^-x)/Sqrt[2]) *)
  
  f1[x_] := Sin[x]
  RieszD[1/2, f1[x], x]
  (* (Sqrt[\[Pi]/2] Sqrt[1/x] Sqrt[x] (Cos[x] - Sin[x]) + Sqrt[\[Pi]/2] (Cos[x] + Sin[x]))/(2 Sqrt[2 \[Pi]]) *)

I’m don’t know is my code right, because I have not found any examples to check it out?

I’d love to hear what code requires Fractional Calculus to be useful. Can you cite your source and it’s “need” for this?