I saw this question How I can get faster
I tried help that. But I can not understand. I want to write a faster code for:
m = 1;
u[x_, t_] = (t^α*x*(2*t^2 + (1 + α)*(2 + α)))/Gamma[3 + α];
DUt = FullSimplify[(1/Gamma[m - α])*
Integrate[(t - τ)^(m - α - 1)*
D[u[x, τ], {τ, m}],
{τ, 0, t}],
Assumptions -> {m - 1 < α < m, t > 0}]
Any suggestion?
Answer
This is your definition:
m = 1;
u[x_, t_] = (t^\[Alpha]*x*(2*t^2 + (1 + \[Alpha])*(2 + \[Alpha])))/
Gamma[3 + \[Alpha]];
Your code makes 3.19 seconds on Mma10.4.1
DUt = FullSimplify[(1/Gamma[m - \[Alpha]])*Integrate[(t - \[Tau])^(m - \[Alpha] - 1)*D[u[x, \[Tau]], {\[Tau], m}], {\[Tau], 0, t}],
Assumptions -> {m - 1 < \[Alpha] < m, t > 0}] // AbsoluteTiming
(* {3.18669, (1 + t^2) x} *)
which is not bad at all. If one calculates the integral separately it takes 0.02 sec:
int = Integrate[(t - \[Tau])^(m - \[Alpha] - 1)*D[u[x, \[Tau]], {\[Tau], m}], {\[Tau], 0, t}];
FullSimplify[(1/Gamma[m - \[Alpha]])*int,
Assumptions -> {m - 1 < \[Alpha] < m, t > 0}] // AbsoluteTiming
(* {0.0244041, (1 + t^2) x} *)
But I do not see a serious gain in it.
Have fun!
Comments
Post a Comment