Re: [Mathematica 6] Integrate strange result
- To: mathgroup at smc.vnet.net
- Subject: [mg78436] Re: [Mathematica 6] Integrate strange result
- From: dimitris <dimmechan at yahoo.com>
- Date: Mon, 2 Jul 2007 06:39:45 -0400 (EDT)
- References: <f5vs8m$kob$1@smc.vnet.net>
Nasser Abbasi : > In[13]:= $Version > Out[13]= 6.0 for Microsoft Windows (32-bit) (April 27, 2007) > > The problem is this: When I ask Mathematica to integrate something > involving some constant parameter, it gives an answer for some range > of the constant involved, say range A, and it says there is no answer > for the other range, say range B > > But next, when I specify, using assumptions, that the constant is now > in range B, then Mathematica does given an answer to the integral ! > > Why does it in one case say there is no answer if the constant is in > range B, and in the second case it gives an answer when the constant > is in range B? > > case 1 > ======== > > In[2]:= f = (1 + k*Sin[a]^2)^(1/2); > In[12]:= Assuming[Element[k, Reals], Integrate[f, {a, 0, 2*Pi}]] > > Out[12]= If[k >= -1, 4*EllipticE[-k], Integrate[Sqrt[1 + > k*Sin[a]^2], {a, 0, 2*Pi}, Assumptions -> k < -1]] > > notice in the above, it says for k<-1 there is NO answer > > case 2 > ======= > In[2]:= f = (1 + k*Sin[a]^2)^(1/2); > In[10]:= Assuming[Element[k, Reals] && k < -1, Integrate[f, {a, 0, > 2*Pi}]] > > Out[10]= 0 > > Notice in the above, for k<-1 it gives an answer, which is zero. > > What is it I am missing here? > > thanks > Nasser Cases like this make be believe that the default setting of Integrate should be GenerateConditions->False and the user should use then Mathematica and his knowledge in order to check the validity of Mathematica's answer. Anyway... In[15]:= $Version Out[15]= "5.2 for Microsoft Windows (June 20, 2005)" In[16]:= f = (1 + k*Sin[a]^2)^(1/2); In[17]:= Assuming[Element[k,Reals], Integrate[f, {a, 0, 2*Pi}]] Out[17]= If[k >= -1, 4*EllipticE[-k], Integrate[Sqrt[1 + k*Sin[a]^2], {a, 0, 2*Pi}, Assumptions -> k < -1]] This does not mean necessary that there is not result for k<-1 as I have already pointed out. But first let's check the result. In[20]:= N[({4*EllipticE[-#1], NIntegrate[f /. k -> #1, {a, 0, 2*Pi}]} & ) /@ {1, 4, 3/2, 1/3}] Out[20]= {{7.6404,7.6404},{10.5407,10.5407},{8.21198,8.21198}, {6.77792,6.77792}} In[22]:= Integrate[f, {a, 0, 2*Pi}, Assumptions -> k < -1] Out[22]= 4*EllipticE[-k] Let's check this result. In[40]:= N[4*EllipticE[3/2]] Out[40]= 2.8652477548003574 + 1.3441362690754468*I In[46]:= (Plot[#1[f /. k -> -3/2], {a, 0, 2*Pi}, Ticks -> {Range[0, 2*Pi, Pi/ 4], Automatic}] & ) /@ {Re, Im} In[71]:= NIntegrate[f /. k -> -3/2, {a, 0, 2*Pi}, WorkingPrecision -> 24, MaxRecursion -> 12, MinRecursion -> 10, AccuracyGoal -> 6] Out[71]= 2.8652479807917706155`6.711353888277711 + 1.3441363675513918324`6.3826350048503775*I So the result should 4*EllipticE[-k] for all the real k. A numerical checking shows that above result is valid for complex k as well. In[73]:= N[(4*EllipticE[-k] /. k -> #1 & ) /@ {3 + I, 3 - 2*I, 1 + (1/2)*I}] Out[73]= {9.736080499856337 + 0.8905718316449666*I, 9.870736038882582 - 1.7518013681025801*I, 7.67033114397703 + 0.595841622264112*I} In[74]:= (NIntegrate[f /. k -> #1, {a, 0, 2*Pi}, WorkingPrecision -> 24, MaxRecursion -> 12, MinRecursion -> 10, AccuracyGoal -> 6] & ) /@ {3 + I, 3 - 2*I, 1 + (1/2)*I} Out[74]= {9.73608049985633302967844862164422991981`23.766864551693423 + 0.89057183164496644540579895706558165164`23.057101708530052*I, 9.87073603888258432279427034487344687327`23.764504923275705 - 1.7518013681025809997671108778670636672`23.29617899726841*I, 7.67033114397703040515727777174341024243`23.767040861758336 + 0.59584162226411186959367805598241714342`22.994048617679788*I} Dimitris