Group Abstract Group Abstract

Message Boards Message Boards

1
|
8.9K Views
|
4 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Write code for fractional calculus?

Posted 8 years ago
POSTED BY: Oscar Peña
4 Replies
Anonymous User
Anonymous User
Posted 8 years ago
POSTED BY: Anonymous User

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

POSTED BY: Mariusz Iwaniuk
Posted 8 years ago

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

POSTED BY: Oscar Peña
POSTED BY: Mariusz Iwaniuk
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard