MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

Exp[I x] vs. Cos[x] + I Sin[x] in Integrate

  • To: mathgroup at
  • Subject: [mg2035] Exp[I x] vs. Cos[x] + I Sin[x] in Integrate
  • From: "Brian J. Albright" <albright at>
  • Date: Sat, 16 Sep 1995 01:41:10 -0400
  • Organization: UCLA Department of Physics and Astronomy


A friend of mine and I have recently run into some apparent 
peculiarities with the MMa Integrate function.  If we enter
the following

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

then we get 

  Out[1]:= 0

Unfortunately, this is not the right answer.  The correct answer, 
obtainable through contour integration, is 2 Pi I (1 - 2/Sqrt[3]).
Interestingly, if we rewrite the integrand, changing "Exp[I x]" 
into "Cos[x] + I Sin[x]":

  In[2]:= Integrate[ (Cos[x] + I Sin[x]) / (2 + Sin[x]), {x,0,2 Pi}]

then we get

                    4 I Pi
  Out[2]:= 2 I Pi - -------

which matches our paper-and-pencil result.  Does anyone know why
MMa gives different answers for the two?  

Thanks in advance.


ps. Incidentally, if I write the "Sin[x]" in In[1] as 
"(Exp[I x] - Exp[-I x]) / (2 I)", I get

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

  Out[3]:= 0

Also, if I use NIntegrate rather than Integrate, I get 

  In[4]:= Chop[ NIntegrate[ Exp[I x] / (2 + Sin[x]), {x,0,2 Pi}] ]

  Out[4]:= -0.972012 I

compare with 

  In[5]:= Out[2]//N

  Out[5]:= -0.972012

Brian J. Albright                            |
Department of Physics and Astronomy, UCLA    |      To err is human...
albright at                    |         to err really big       |             is government.

  • Prev by Date: System of Equation
  • Next by Date: Re: Advice on "MMA for Scientists and Engineers" Book
  • Previous by thread: System of Equation
  • Next by thread: front-end elsewhere on a LAN