2
$\begingroup$

I use of this code Fractional Integral and wrote the following code:

INT[α_, f_, x_, opts___] := 
  Integrate[(x - t)^(-α - 1) (f /. x -> t), {t, 0, x}, opts]/Gamma[-α]
INT[mu_?Positive, f_, x_, opts___] := 
  Module[{m = Ceiling[mu]},
    D[INT[-(m - mu), f, x, opts], {x, m}]]

I run for:

u1[x] = 
  INT[-α, 0.9 - 0.1 x, x, Assumptions -> {x > 0 && Re[β] > -1 && Re[α] > 0}]

u2[x] = 
  INT[-α, 8. u1[x] - 2. x u1[x], x, 
    Assumptions -> {x > 0 && Re[β] > -1 && Re[α] > 0}]

But Mathematica needs a lot of time to make the calculations. Any suggestion code for get faster calculation?

$\endgroup$
4
  • $\begingroup$ your attempt to decompose integral of sums is not as general as needed. For example u1[x] is a sum of two terms but 8 u1[x] has head Times. that said I'm puzzled why thats needed at all, but notice INT[-\[Alpha], u1[x], x, Assumptions...] returns almost immediately while INT[-\[Alpha], 8 u1[x], x, Assumptions...] does not. $\endgroup$ – george2079 Mar 31 '16 at 18:35
  • $\begingroup$ I wrote this code to obtain u1 and then u2 obtain with u1, and u3 with u2 and .... $\endgroup$ – user37694 Mar 31 '16 at 19:11
  • $\begingroup$ This is a part of Homotopy perturbation iteration method. $\endgroup$ – user37694 Mar 31 '16 at 19:18
  • $\begingroup$ FractionalIntegrate $\endgroup$ – flinty Oct 11 '20 at 16:04
3
$\begingroup$

I have two suggestions to speed up the code:

  1. Always Expand the input expression f
  2. Set option GenerateConditions→False to Integrate to bypass convergence test routines.

This Expands the input and passes the result to the integrators internalINT:

INT[α_, f_, x_, opts___] :=
  Module[{expr = Expand[f]},
    internalINT[α, f, x, opts]
  ]

Of the following, the first two definitions for internalINT is your code copied here. The third definition Maps the internalINT over addition (Plus):

SetOptions[Integrate, GenerateConditions -> False];

internalINT[α_, f_, x_, opts___] := 
  Integrate[(x - t)^(-α - 1) (f /. x -> t), {t, 0, x}, opts]/Gamma[-α]

internalINT[mu_?Positive, f_, x_, opts___] := 
  Module[{m = Ceiling[mu]}, D[internalINT[-(m - mu), f, x, opts], {x, m}]]

internalINT[α_, f_Plus, x_, opts___] := Map[internalINT[α, #, x, opts] &, Expand@f]
$\endgroup$
9
  • $\begingroup$ Which code is correct in line four: " internalINT[mu_?Positive, f_, x_, opts___] := Module[{m = Ceiling[mu]}, D[INT[-(m - mu), f, x, opts], {x, m}]]" or "internalINT[mu_?Positive, f_, x_, opts___] := Module[{m = Ceiling[mu]}, D[internalINT[-(m - mu), f, x, opts], {x, m}]]". Both codes are correct I think! $\endgroup$ – user37694 Apr 3 '16 at 14:10
  • $\begingroup$ @user37694 Both are fine; but internalINT[mu_?Positive, f_, x_, opts___] := Module[{m = Ceiling[mu]}, D[internalINT[-(m - mu), f, x, opts], {x, m}]] is preferred. I simply forgot to replace INT with internalINT; I have made the appropriate change in the edit. $\endgroup$ – QuantumDot Apr 3 '16 at 14:16
  • $\begingroup$ Many many thanks. $\endgroup$ – user37694 Apr 3 '16 at 14:18
  • $\begingroup$ @QuantumDot could you please let me know, can you help me for this code? $\endgroup$ – bahram May 2 '16 at 10:10
  • $\begingroup$ @bahram Yes, I can help you. What is your question? $\endgroup$ – QuantumDot May 2 '16 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.