# Symbolic Integration gives wrong answer [closed]

I have tried to integrate the following expression in Mathematica 10.1

Integrate[x^m (1 - x)^i, {x, p, 1}, Assumptions -> 1 > p > 0 && i > -1]

(*Out[1]=-Beta[p, 1 + m, 1 + i] + (Gamma[1 + i] Gamma[1 + m])/Gamma[2 + i + m]*)


Which is incorrect for m ≤−1:

-Beta[p, 1 + m, 1 + i] + (Gamma[1 + i] Gamma[1 + m])/Gamma[2 + i + m] /. m -> -1

(*Infinity::indet: Indeterminate expression ComplexInfinity+ComplexInfinity encountered. >>
Out[2]=Indeterminate*)


While

Block[{p = 0.1, m = -1, i = 1},
Integrate[x^m (1 - x)^i, {x, p, 1}]
]
(*Out[3]=1.40259*)


So the problem is that Mathematica represents the answer using beta function which is actually approaching infinity when m approaches -1. At the same time the original integral value stays finite since p>0.

While I understand where and why Mathematica makes a mistake, I would like to know

1. How can I get the correct symbolic result using Mathematica?
2. How to avoid this kind of errors in future?

## closed as off-topic by Daniel Lichtblau, C. E., Öskå, MarcoB, m_goldbergSep 18 '15 at 13:05

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Daniel Lichtblau, C. E., Öskå, MarcoB, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

• You did not show that the result is incorrect for m<-1. Moreover some numeric tests work out just fine e.g. m->-11/10,p->2/5,i->33/10}. I think that earns a close vote. – Daniel Lichtblau Sep 17 '15 at 19:46
• I did test only for some integer m. Your example shows me that I don't understand something. Beta function definition is upload.wikimedia.org/math/7/8/6/… and for m ≤-1 it has to give infinity, isn't that right? With non integer m I get finite answer like you did. – icemtel Sep 17 '15 at 20:38
• You are getting indeterminate forms when substituting negative integers. In principle one could get better results by taking limits. But I don't think Limit will handle these. – Daniel Lichtblau Sep 17 '15 at 21:21
• The question is why only integer? If I try to evaluate Beta[0.1,-0.2,3] using its mathematical definition Integrate[x^(-1.2) (1 - x)^2, {x, 0, 0.1}] I get infinity. trying to evaluate N@Beta[0.1, -0.2, 3] gives finite answer instead. – icemtel Sep 18 '15 at 8:05
• That's not the definition everywhere. Analytic continuation takes it outside the range where the integral works. See the functions site. – Daniel Lichtblau Sep 18 '15 at 14:15

Mathematica gives generic answers, and you will need to handle the singularity at m=-1 as a separate case. Even simpler than your example is:

Integrate[x^m, x]

x^(1 + m)/(1 + m)


If you then evaluate at m=-1 you also get infinity

Integrate[x^m, x]//.m->-1


Note that the generic answer holds for all m not equal to -1. The answer is correct for $m \neq -1$. For example,

Block[{p = 0.1, m = -1.1, i = 1}, Integrate[x^m (1 - x)^i, {x, p, 1}]]


and

-Beta[p, 1 + m, 1 + i] + (Gamma[1 + i] Gamma[1 + m])/Gamma[2 + i + m] /. {m -> -1.1, p -> 0.1, i -> 1}


both return the same answer: 1.61802

• It gives incorrect answer for any m≤1, not only m=-1 (see the definition of beta function).= – icemtel Sep 17 '15 at 19:10
• It gives the same answer for the case you suggest with p = 0.1, m = -1.1, i = 1 – bill s Sep 17 '15 at 20:01