# Difficulty with computing a limit

I meet some difficulties when trying to compute this limit,

Limit[1/n*Integrate[1/(Cos[x]^2 + 4 Sin[2 x] + 4), {x, 0, Pi*n}],   n -> Infinity,Assumptions -> n \[Element] Integers]


The output is,

Limit::cas: Warning: Contradictory assumption(s) (n\[Element]Integers&&(Re[n]<=1/2||n\[NotElement]Reals))&&n>4096 encountered. >>


The limit is finite though.

-
I'm on version 9.0.1 and I don't need to take the limit :Simplify[1/n*Integrate[1/(Cos[x]^2 + 4 Sin[2 x] + 4), {x, 0, Pi*n}], Assumptions -> n \[Element] Integers] is zero. –  b.gatessucks Jul 30 '13 at 7:56
@b.gatessucks it cannot be $0$. –  Chris's sis Jul 30 '13 at 7:57
For $n=1, 2, 3,...$ Mathematica yields $\displaystyle\frac{\pi}{2}$. Could you confirm if it so? I also need to check my work and see why I initially got a different result. –  Chris's sis Jul 30 '13 at 8:08

Break it up:

int = Assuming[Element[n, Integers],
Integrate[1/(Cos[x]^2 + 4 Sin[2 x] + 4), {x, 0, Pi*n}]]
(*  (n*Pi)/2  *)


now

Limit[1/n*int, n -> Infinity]
(* Pi/2 *)


You do not even need limit.

(1/n)*int

(*  Pi/2 *)


To do it as you did, you need to put the Assuming first, so it covers the integral part, like this

Assuming[Element[n, Integers],
Limit[1/n*Integrate[1/(Cos[x]^2 + 4 Sin[2 x] + 4), {x, 0, Pi*n}],n -> Infinity]]

(* Pi/2  *)


Limit[1/n*Integrate[1/(Cos[x]^2 + 4 Sin[2 x] + 4), {x, 0, Pi*n}],
n -> Infinity,Assumptions -> n \[Element] Integers]


So, the Integrate part never knew that n was an integer ! This is important. Since without this information, integrate will generate an answer this like this:

int = Integrate[1/(Cos[x]^2 + 4 Sin[2 x] + 4), {x, 0, Pi*n}]
(* 1/2 (-ArcTan[2] + ArcTan[2 (1 + Tan[n Pi])]) *)

Assuming[Element[n, Integers], Limit[1/n*int, n -> Infinity]]
(* 0 *)


Compare the result on Integrate when it sees the assumption on n being integer:

Assuming[Element[n, Integers], Integrate[1/(Cos[x]^2 + 4 Sin[2 x] + 4), {x, 0, Pi*n}]]
(* (n Pi)/2  *)


big difference

1/2 (-ArcTan[2] + ArcTan[2 (1 + Tan[n Pi])])


vs

(n Pi)/2

-
Nasser, thanks! (+1) I'm still a bit confused. If we firstly consider the indefinite integral and then take the limits, we get (for $n=1$) Limit[(1/2) ArcTan[2 Sec[x] (Cos[x] + Sin[x])], x -> 0] and Limit[(1/2) ArcTan[2 Sec[x] (Cos[x] + Sin[x])], x -> Pi] both evaluate ArcTan[2]/2. Thus, the value should be $0$. –  Chris's sis Jul 30 '13 at 8:22
In the message above I only considered the case $n=1$. As you also noticed, for all $n$ the values should be the same,i.e. $\displaystyle \frac{\pi}{2}$. –  Chris's sis Jul 30 '13 at 8:36
From your first line we know that int = Assuming[Element[n, Integers], Integrate[1/(Cos[x]^2 + 4 Sin[2 x] + 4), {x, 0, Pin}]] ( (n*Pi)/2 *). This means that if we set $n=1$, then the integral from $0$ to $\pi$ is $\pi/2$. If you firstly compute the indefinite integral, and then compute the integration limits you get to the conclusion the integral evaluates $0$. –  Chris's sis Jul 30 '13 at 9:07
That is Integrate[1/(Cos[x]^2 + 4 Sin[2 x] + 4), x] = 1/2 ArcTan[2 Sec[x] (Cos[x] + Sin[x])]. Now, Limit[(1/2) ArcTan[2 Sec[x] (Cos[x] + Sin[x])], x -> Pi]= ArcTan[2]/2 and Limit[(1/2) ArcTan[2 Sec[x] (Cos[x] + Sin[x])], x -> 0]= ArcTan[2]/2. This leads us to the fact that Integrate[1/(Cos[x]^2 + 4 Sin[2 x] + 4), {x, 0, Pi}]]=0 that contradicts the fact that the integral should evaluate $\pi/2$. –  Chris's sis Jul 30 '13 at 9:09