12
$\begingroup$
Integrate[a/(Sin[t]^2 + a^2), {t, 0, 2 Pi}]

$$\int_0^{2 \pi } \frac{a}{a^2+\sin ^2(t)} \, dt$$

gives $0$

This cannot be true. What is going on?

If I insert a number into a, it gives a reasonable result:

NIntegrate[2/(Sin[t]^2 + 4), {t, 0, 2 Pi}]

give 2.80993

$\endgroup$
2
  • $\begingroup$ Note Integrate itself gets it right if you give a a value,( 2 Pi/Sqrt[5] here ) $\endgroup$
    – george2079
    Jun 1, 2015 at 20:17
  • 3
    $\begingroup$ A relevant link. $\endgroup$ Jun 2, 2015 at 0:51

6 Answers 6

13
$\begingroup$
$Version

(*
Out[228]= "8.0 for Microsoft Windows (64-bit) (October 7, 2011)"
*)

The result provided by Mathematica is correct:

Integrate[a/(a^2 + Sin[t]^2), {t, 0, 2 π}]

(*
Out[213]= (2 π)/(Sqrt[1 + 1/a^2] a)
*)

Now the same procedure as "always" which "explains" the zero result. The indefinite integral is

Integrate[a/(a^2 + Sin[t]^2), t]

(*
Out[214]= ArcTan[(Sqrt[1 + a^2] Tan[t])/a]/Sqrt[1 + a^2]
*)

This result is not continuous for real a. In this graph we can see the jumps as well as the necessary additional terms to restore continuity.

The jump must be determined by taking (directed) limits. Assuming first $a>0$ gives

Simplify[Limit[ArcTan[(Sqrt[1 + a^2] Tan[t])/a]/Sqrt[1 + a^2], 
   t -> π/2, Direction -> +1], a > 0] - 
 Simplify[Limit[ArcTan[(Sqrt[1 + a^2] Tan[t])/a]/Sqrt[1 + a^2], 
   t -> π/2, Direction -> -1], a > 0]

(*
Out[408]= π/Sqrt[1 + a^2]
*)

and therefore

With[{a = 1/2}, 
 Plot[{ArcTan[(Sqrt[1 + a^2] Tan[t])/a]/Sqrt[1 + a^2], 
   ArcTan[(Sqrt[1 + a^2] Tan[t])/a]/Sqrt[1 + a^2] + π/Sqrt[1 + a^2], 
   ArcTan[(Sqrt[1 + a^2] Tan[t])/a]/Sqrt[1 + a^2] + (2 π)/Sqrt[
    1 + a^2]}, {t, 0, 2 π}]]

150601_plot_int.jpg

The blue (lower) curve is the original antiderivative, the red (middle) curve has π/Sqrt[1+a^2] added, and is the continiuous continuation between π/2 and 3π/2, finally the brown (upper) curve does it for the rest adding again the same amount π/Sqrt[1+a^2].

Hence taking the difference of the antiderivative at the endpoints according to the fundamental theorem of calculus would lead to zero on the blue curve, and is only correct for the continuous version leading to the correct result given in the beginning.

EDIT #1

The case $a<0$ need not be discussed separately because of the (anti)symmetry of the integral.

Note that because the antiderivative vanishes at both ends the integral is equal to the "total" jump, which here is twice the amount of the jump at $\pi/2$.

This and other examples point to the (tentative) rule: if the result of Integrate[] is zero despite the fact that the integrand is positive check for jumps and calculate them using the directed Limits. The integral will then be the sum of the jumps over the whole interval.

$\endgroup$
6
$\begingroup$

The result zero does not look correct. But you can get the correct result by using PrincipalValue -> True

r = Integrate[a/(Sin[t]^2 + a^2), {t, 0, 2 Pi}, PrincipalValue -> True]

Mathematica graphics

now r /. a -> 2.0 gives the value you show

Mathematica graphics

The original answer, without PrincipalValue -> True gives

   r = Integrate[a/(Sin[t]^2 + a^2), t]

Mathematica graphics

Maple gets this right, but with a sign added:

Maple result

$\endgroup$
5
$\begingroup$

Mathematica 10.1 seems to have fixed this bug:

answer from 10.1

$\endgroup$
2
$\begingroup$

Another, in my opinion simpler, alternative is to use the symmetry.

4 Integrate[a/(a^2 + Sin[t]^2), {t, 0, π/2}]

(* (2 π)/(Sqrt[1 + 1/a^2] a) *)

without additional assumptions.

$\endgroup$
2
$\begingroup$

I confirmed the result in both Mathematica 9 and 10 on Linux.

Using an assumption seems to work:

Integrate[a/(Sin[t]^2 + a^2), {t, 0, 2 π}, Assumptions -> a > 0]
(2 π)/Sqrt[1 + a^2]

which agrees with NIntegrate.

I'm not sure about the source of the discrepancy though. It could be a bug or the way the assumptions are made, i.e. by default a is considered complex, so either the integral is zero for complex a (didn't do the calcs) or Integrate gets confused somehow.

In any case, always remember to play around with the assumptions and numerically test the results.

Cheers

$\endgroup$
2
  • $\begingroup$ The answer about adding PrincipalValue also makes me suspect that the problem is a is treated as a complex number. So rather than a > 0, ElementQ[a, Reals] is probably sufficient :) $\endgroup$
    – CompuChip
    Jun 1, 2015 at 13:37
  • $\begingroup$ @CompuChip how does $a$ being complex validate Mathematica output? The integral is still non-zero for e.g. $a=1+3i$. $\endgroup$
    – Ruslan
    Jun 1, 2015 at 13:43
1
$\begingroup$

A bit late, but consider the following function:

$$f_c(a,x)=\frac1{\sqrt{1+a^2}}\left(x+\arctan\left(\frac{\sin\,x\cos\,x}{a^2+a\sqrt{1+a^2}+\sin^2 x}\right)\right)$$

You can verify the following identity in Mathematica:

fc[a_, x_] := (x + ArcTan[(Sin[x] Cos[x])/(a^2 + a Sqrt[1 + a^2] + Sin[x]^2)])/Sqrt[1 + a^2]
D[fc[a, x], x] == a/(a^2 + Sin[x]^2) // Simplify
   True

Compare this with the antiderivative produced by Integrate[]:

f[a_, x_] = Integrate[a/(a^2 + Sin[x]^2), x]
With[{a = 1/2}, Plot[{f[a, x], fc[a, x]}, {x, 0, 2 π}, PlotStyle -> {Orange, Blue}]]

two different antiderivatives

and we see that $f_c(a,x)$ is continuous over $[0,2\pi]$, while $f(a,x)$ is not. Thus, $f(a,x)$ is not suitable for computing the definite integral through the FTC. But, if you use $f_c(a,x)$,

fc[a, 2 π] - fc[a, 0]
  2 π/Sqrt[1 + a^2]

Again, see O. Pavlyk's blog entry for more details.

$\endgroup$

Your Answer

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

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