Can anyone explain why Mathematica does not return a conditional expression that handles the case of p=-1
for Integrate[x^p,x]
?
Mathematica returns x^(1 + p)/(1 + p)
, which diverges for p=-1
. In order for Mathematica to return Log[x]
, p
must be set to -1
before the integration. Is there a subtle reason why this is actually correct behavior?
1 Answer
With V10 one can see that the special case p = -1
is explicitly excluded:
FunctionDomain[Integrate[x^p, x], p, Reals]
Reason: The general formula
Integrate[x^p, x]
would result in a division by zero error with p = -1
:
Limit[Integrate[x^p, x], p -> -1]
Integrating over a certain interval one gets the expected results:
Integrate[x^#, x] & /@ Range[-3, 3]
One might want to define:
xpp[x_^-1] := Integrate[x^-1, x]
xpp[x_^p_] := Integrate[x^p, x]
Now
xpp[x^-1]
and
xpp[b^2]
Another possibility:
Assuming[p == -1, Integrate[x^p, x]]
Assuming[p != -1, Integrate[x^p, x]]
Limit[x^(1 + p)/(1 + p), p -> -1]
) $\endgroup$Integrate
returns a generically correct result. For a measure zero set of values in the parameter space it might not hold. One can get a "full" result usingIntegrate[t^p,{t,1,x}, Assumptions->x>1]
(and taking a limit for the special casep->1
, per other comments). $\endgroup$