3
$\begingroup$

Mathematica evaluates the following integral as:

In[1]:= Assuming[p \[Element] Integers && p > 0, 
 Integrate[Sin[x]*Cos[x]^p/(Cos[x] + 2), {x, 0, Pi}]]

Out[1]= -2^p Beta[2/3, -p, 1 + p] + ((-1)^ p Hypergeometric2F1[1, 1, 1 - p, 2])/p

However, when I evaluate the resulting expression, I encounter a complex infinity. For example, for p = 3:

In[2]:= -2^3 Beta[2/3, -3,  1 + 3] + ((-1)^3 Hypergeometric2F1[1, 1, 1 - 3, 2])/3

During evaluation of In[96]:= Infinity::indet: Indeterminate expression ComplexInfinity+ComplexInfinity encountered. >>    
Out[2]= Indeterminate

Did I make a simple mistake in In[1] that is causing this problem? Certainly $\sin x\cos^p x/(\cos x + 2)$ is real and finite over the whole real line, for $p\in\mathbb{N}$.

$\endgroup$
5
  • $\begingroup$ What happens if you append // FullSimplify to the integral within Assuming[]? $\endgroup$ Commented Jun 10, 2013 at 16:38
  • $\begingroup$ Interesting. Adding FullSimplify[] within Assuming[] yields ComplexInfinity. But how could that be? For example, replacing p by 3 inside the integral gives a real result: Integrate[Sin[x]*Cos[x]^3/(Cos[x] + 2), {x, 0, Pi}] = 26/3 - 8 Log[3]. $\endgroup$
    – Doubt
    Commented Jun 10, 2013 at 16:43
  • 1
    $\begingroup$ Anyway... if I input only the integral, and I extract the expression inside the resulting ConditionalExpression[], I get (Hypergeometric2F1[1, 1 + p, 2 + p, -1/2] + (-1)^p Hypergeometric2F1[1, 1 + p, 2 + p, 1/2])/(2 (1 + p)), which certainly is sensible for positive integer p. $\endgroup$ Commented Jun 10, 2013 at 16:45
  • $\begingroup$ Great 0x4A4D, this works, but where did I go wrong in In[1]? $\endgroup$
    – Doubt
    Commented Jun 10, 2013 at 16:52
  • 2
    $\begingroup$ I really don't know. Sometimes, the software just does the darndest things... $\endgroup$ Commented Jun 10, 2013 at 17:03

1 Answer 1

2
$\begingroup$

If you plot the real parts of each half of your integral together

Plot[{Re[-2^p Beta[2/3, -p, 1 + p]], Re[((-1)^p Hypergeometric2F1[1, 1, 1 - p, 2])/p]}, {p, 0, 10}]

you'll see that each half goes to infinity in opposite directions, so the two singularities must cancel each other. Mathematica is stumbling over combining the two separate singularities exactly. There is no problem doing so if you plot the real part of the whole integral,

Plot[{Re[-2^p Beta[2/3, -p, 1 + p] + ((-1)^p Hypergeometric2F1[1, 1, 1 - p, 2])/p]}, {p, 0, 10}]

which means that it is a question of numerical precision. This is made clear by evaluating

Re[-2^p Beta[2/3, -p, 1 + p] + ((-1)^p Hypergeometric2F1[1, 1, 1 - p, 2])/p] /. p -> 2.9999999

which returns a finite value of -0.122232, versus adding another nine,

Re[-2^p Beta[2/3, -p, 1 + p] + ((-1)^p Hypergeometric2F1[1, 1, 1 - p, 2])/p] /. p -> 2.99999999

which returns an indeterminate value.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.