0
$\begingroup$

I'm having trouble evaluating this integral where the integrand depends on a derivative of cosine multiplied by a power law. q is strictly non-integer in this case, for example, 3/4 or 0.75.

derivC[q_, x_] := 
Module[{s = Ceiling[q]}, 
1/Gamma[s - q] NIntegrate[Derivative[s][Cos][x - u] u^(s-q-1), {u, 0, x}]]]

I get the errors that the integral failed to converge and that the integrand evaluated to Overflow, Indeterminate, or Infinity.

Specifically, if I do

list :=
Flatten[Evaluate@Table[
Evaluate@Table[{x, q, derivC[q, x]}, {q, 0, 2, 0.1}], {x, 0.1, 10, 0.2}], 1]

and then try to plot list using ListPlot3D then these errors show up.

Any help is appreciated.

$\endgroup$
  • $\begingroup$ Your integral is singular-undefined at q == 0 and other even integers, but the gamma factor annihilates the result. Should q == 0 be excluded, or take a limit as q -> 0, or what? $\endgroup$ – Michael E2 Aug 3 '17 at 20:11
  • $\begingroup$ I actually have an If statement there that catches all integer q. When q is integer there is actually no integral by definition, that's why this problem occurs only for non-integer q. $\endgroup$ – Buddhapus Aug 3 '17 at 20:47
  • $\begingroup$ I don't see any If, but in any case, you could just ignore integer q in my answer, since it agrees with your derivC[] at other values of q. $\endgroup$ – Michael E2 Aug 3 '17 at 23:24
1
$\begingroup$

You could integrate by parts first, to get rid of the singularity (integrable when q is not an even integer). This results in the gamma factor losing its singularity at integers as well. I'll leave it to the OP whether that makes sense in the actual use case, but the chances seem good to me that it's the only way to make sense of integer q.

derivC[q_, x_] := 
 Module[{s = Ceiling[q]}, 
  1/Gamma[1 - q + s] (Derivative[s][Cos][0] x^(s - q) + 
     NIntegrate[Derivative[s + 1][Cos][x - u] u^(s - q), {u, 0, x}])]

Flatten[Table[{x, q, derivC[q, x]},
   {x, 0.1, 10, 0.2}, {q, 0.1, 2, 0.1}], 1] // ListContourPlot

Mathematica graphics

| improve this answer | |
$\endgroup$
0
$\begingroup$
derivC[q_, x_] := Module[{s = Ceiling[q], ep = 10^-6},1/Gamma[s - q]*
NIntegrate[Derivative[s][Cos][x - u] u^(s - q - 1), {u, ep, 1, 2, x}, 
Method -> {"GlobalAdaptive", "SymbolicProcessing" -> 0}]]

ListContourPlot[Partition[Flatten[Table[{x, q, derivC[q, x]},
{q, 0, 2, 0.1}, {x, 0.1, 10, 0.1}]], 3], FrameLabel -> {"x", "q"}]

enter image description here

ListPlot3D[Partition[Flatten[Table[{x, q, derivC[q, x]}, {q, 0, 2, 0.1}, {x, 0.1, 10, 0.1}]], 3],AxesLabel -> {"x", "q"}]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Does the partition effectively break up the nested table into 3-coordinate points? also, what do the bounds {u, ep, 1, 2, x} mean? $\endgroup$ – Buddhapus Aug 3 '17 at 19:02
  • $\begingroup$ @Buddhapus 1) I'm don't know(Needs tests), 2) tests for singularities in point 1 and 2 see documentation NIntegrate $\endgroup$ – Mariusz Iwaniuk Aug 3 '17 at 19:10

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.