# Integral of x^p

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?

• Well, $\lim_{p\rightarrow -1} \frac{x^{p+1}}{p+1}=\ln(x)$. Not that mathematica knows this, though (try Limit[x^(1 + p)/(1 + p), p -> -1])
– acl
Aug 29, 2014 at 19:21
• Oh yes, I had indeed noticed that the log was not recovered in the limit. Aug 29, 2014 at 19:30
• Actually the log is recovered in the limit. It's just that mathematica doesn't recover it correctly.
– acl
Aug 29, 2014 at 19:33
• Indefinite 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 using Integrate[t^p,{t,1,x}, Assumptions->x>1] (and taking a limit for the special case p->1, per other comments). Aug 29, 2014 at 21:03
• I think the answer to this question has been given here.
– Jens
Aug 30, 2014 at 1:09

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]] 