# General result from Integrate differs from result with special values

Can someone explain why these outputs differ?

In[5]:= g1 =
Integrate[Exp[-I x (n + 1)]/( Exp[I x] + 2), {x, 0, 2 Pi},
Assumptions -> Element[n, Integers]];

In[6]:= g1 /. n -> 3


During evaluation of In[6]:= Infinity::indet: Indeterminate expression 0 ComplexInfinity encountered.

Out[6]= Indeterminate

In[7]:= g2 = Integrate[Exp[-I x (3 + 1)]/( Exp[I x] + 2), {x, 0, 2 Pi}]

Out[7]= π/16


The last is correct, the first seems to apply some incorrect assumptions? Note

In[8]:= g1

Out[8]= 2^(-1 - n) Beta[-(1/2), -1 - n, 0] Sin[n π]


See Background for context.

• General result is valid: {Block[{\$MaxExtraPrecision = 300, eps = 10^-300}, N[Limit[2^(-1 - n) Beta[-(1/2), -1 - n, 0] Sin[n \[Pi]], n -> 3 + eps], 100]] // Chop, N[Pi/16, 100]} Jul 14, 2018 at 14:37
• Thanks you @MariuszIwaniuk, that answers it for me. Jul 18, 2018 at 10:33

g1[n_?IntegerQ] := Integrate[Exp[-I x (n + 1)]/(Exp[I x] + 2), {x, 0, 2 Pi} ];