Re: Integrating Abs[Sin[]^2]
- To: mathgroup at smc.vnet.net
- Subject: [mg38860] Re: Integrating Abs[Sin[]^2]
- From: "David W. Cantrell" <DWCantrell at sigmaxi.org>
- Date: Thu, 16 Jan 2003 03:20:40 -0500 (EST)
- References: <b032m9$mv4$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Jos R Bergervoet <antispam at nospam.com> wrote: > in computing the following: > > result = Integrate[ Abs[Sin[k x]]^2, {x,0,1}] > N[ result /. k->I+1 ] > > (* Analytical approach gives 0.261044 + 0.616283 I, WRONG !!! *) > > k=I+1; NIntegrate[ Abs[Sin[k x]^2], {x,0,1}] > > (* Numerical check gives 0.679391 *) > > So why is the analytical result for |Sin[k x]|^2 wrong? It might be of interest that another CAS which I use also gives both of those results. > What should I do to circumvent such errors? One thing that works in Mathematica (as well as in the other CAS) is to Integrate[ Abs[Sin[(a+b*I) x]]^2, {x,0,1}]. This gives (a*Sinh[2*b] - b*Sin[2*a]) / (4*a*b), which agrees with your result below. BTW, I'm mildly surprised that telling Mathematica explicitly that k should be assumed to be complex in the integration doesn't work. David > PS: For those interested, the correct analytical result is: > > (Sinh[2Im[k]]/Im[k] - Sin[2Re[k]]/Re[k]) / 4