Re: Try it again, Mathematica! Was: Can't integrate sqrt(a+b*cos(t)+c*cos(2t))
- To: mathgroup at smc.vnet.net
- Subject: [mg90839] Re: Try it again, Mathematica! Was: Can't integrate sqrt(a+b*cos(t)+c*cos(2t))
- From: "Kevin J. McCann" <Kevin.McCann at umbc.edu>
- Date: Sat, 26 Jul 2008 04:19:41 -0400 (EDT)
- Organization: University System of Maryland
- References: <g6710s$sb6$1@smc.vnet.net> <g6c959$bpg$1@smc.vnet.net>
Here is the response I got from Mathematica support: *** my email *** I have enclosed a nb with a strange integration problem that Alois Steindl and I have been looking at. As you will see, the first time I execute the integral, it returns the input after a long time, i.e. no answer. The second time I evaluate the same integral it again takes a long time, but then returns an answer. The third time it returns the same answer as the second, but it is nearly instantaneous. What's going on? *** response *** Information is being cached and there are time limits on internal functions like Simplify which prevent getting an answer on the first try, giving an answer on the second try and almost nothing happening on the third try. Here are the timings of these on my Windows: In[1]:= Timing[Integrate[Sqrt[5 - 4*Cos[t] + Cos[2*t]], {t, 0, Pi}]] Out[1]= {62.187, Integrate[Sqrt[5 - 4*Cos[t] + Cos[2*t]], {t, 0, Pi}]} In[2]:= Timing[Integrate[Sqrt[5 - 4*Cos[t] + Cos[2*t]], {t, 0, Pi}]] Out[2]= {9.610000000000003, (1/5)*Sqrt[2 + 4*I]* (-5*I*EllipticE[-(3/5) - (4*I)/5] + (2 + I)*Sqrt[5]* EllipticE[-(3/5) + (4*I)/5] - (12 - 4*I)* EllipticK[-(3/5) - (4*I)/5] + (6 - 2*I)*Sqrt[5]* EllipticK[8/5 - (4*I)/5] + 4*I*Sqrt[5]*EllipticPi[1/5 + (2*I)/5, -(3/5) + (4*I)/5] + (8 + 4*I)*EllipticPi[1 - 2*I, -(3/5) - (4*I)/5])} In[3]:= Timing[Integrate[Sqrt[5 - 4*Cos[t] + Cos[2*t]], {t, 0, Pi}]] Out[3]= {0.5460000000000036, (1/5)*Sqrt[2 + 4*I]* (-5*I*EllipticE[-(3/5) - (4*I)/5] + (2 + I)*Sqrt[5]* EllipticE[-(3/5) + (4*I)/5] - (12 - 4*I)* EllipticK[-(3/5) - (4*I)/5] + (6 - 2*I)*Sqrt[5]* EllipticK[8/5 - (4*I)/5] + 4*I*Sqrt[5]*EllipticPi[1/5 + (2*I)/5, -(3/5) + (4*I)/5] + (8 + 4*I)*EllipticPi[1 - 2*I, -(3/5) - (4*I)/5])} After working on this issue, I thought that it would be nicer if we had a warning message generated after the first trial. I have forwarded your examples to our development group and I filed a suggestion report about having such a message. We apologize for any inconvenience caused by this issue. Sincerely, Zubeyir Cinkir Technical Support Wolfram Research, Inc. Alois Steindl wrote: > Hello, > I played around a little bit and found the following interesting > behaviour: > > In[1]:= Integrate[Sqrt[5 - 4*Cos[t] + Cos[2*t]], {t, 0, Pi}] > Out[1]:= \!\( > \*SubsuperscriptBox[\(\[Integral]\), \(0\), \(\[Pi]\)]\( > SqrtBox[\(5 - 4\ Cos[t] + Cos[2\ t]\)] \[DifferentialD]t\)\) > > In[2]:= Integrate[Sqrt[5 - 4*Cos[t] + Cos[2*t]], {t, 0, Pi}] > Out[2]:= 1/5 Sqrt[ > 2 + 4 I] (-5 I EllipticE[-(3/5) - (4 I)/5] + (2 + I) Sqrt[5] > EllipticE[-(3/5) + (4 I)/5] - (12 - 4 I) EllipticK[-(3/5) - ( > 4 I)/5] + (6 - 2 I) Sqrt[5] EllipticK[8/5 - (4 I)/5] + > 4 I Sqrt[5] > EllipticPi[ > 1/5 + (2 I)/5, -(3/5) + (4 I)/5] + (8 + 4 I) EllipticPi[ > 1 - 2 I, -(3/5) - (4 I)/5]) > > So it seems, it helps to ask Mathematica twice. > > Best wishes, > Alois >