Re: Integral question

*To*: mathgroup at smc.vnet.net*Subject*: [mg73712] Re: Integral question*From*: "dimitris" <dimmechan at yahoo.com>*Date*: Sun, 25 Feb 2007 04:37:59 -0500 (EST)*References*: <eropmh$9cb$1@smc.vnet.net>

>=2E..which not only does not look like what I have found by hand... Mathematica and CAS in general do not follow the way that a human would evaluate an integral (*). For example here Mathematica uses (I believe) the Extended Risch Algorithm for Indefinite Integration. Moreover it does not mean that the obtained result from you and the result returned by Mathematica must agree. Remember that a function has an infinite number of antiderivatives which differ in an arbitrary constant known as the constant of integration (or in general in function whose derivative is equal to zero). Let now In[18]:= expr = 1/Sqrt[v^2 - c*s^2] math52 = Integrate[1/Sqrt[v^2 - c*s^2], s] hand = ArcSin[(Sqrt[c]*s)/v]/Sqrt[c] Out[18]= 1/Sqrt[(-c)*s^2 + v^2] Out[19]= (I*Log[-2*I*Sqrt[c]*s + 2*Sqrt[(-c)*s^2 + v^2]])/Sqrt[c] Out[20]= ArcSin[(Sqrt[c]*s)/v]/Sqrt[c] Then In[35]:= D[math52, s] Simplify[%] Out[35]= (I*(-2*I*Sqrt[c] - (2*c*s)/Sqrt[(-c)*s^2 + v^2]))/ (Sqrt[c]*(-2*I*Sqrt[c]*s + 2*Sqrt[(-c)*s^2 + v^2])) Out[36]= 1/Sqrt[(-c)*s^2 + v^2] So Mathematica's result is correct! In[42]:= D[hand, s] Simplify[%] Out[42]= 1/(Sqrt[1 - (c*s^2)/v^2]*v) Out[43]= 1/(Sqrt[1 - (c*s^2)/v^2]*v) As you see differentation of hand didn't give expr! Only for v>=0 last expression reduces to expr. In[67]:= (FullSimplify[%, #1[v, 0]] & ) /@ {GreaterEqual, Less} Out[67]= {1/Sqrt[(-c)*s^2 + v^2], -(1/Sqrt[(-c)*s^2 + v^2])} Note also In[68]:= (D[#1, s] & )[hand - math52] (FullSimplify[%, #1[v, 0]] & ) /@ {GreaterEqual, Less} Out[68]= 1/(Sqrt[1 - (c*s^2)/v^2]*v) - (I*(-2*I*Sqrt[c] - (2*c*s)/Sqrt[(-c)*s^2 + v^2]))/ (Sqrt[c]*(-2*I*Sqrt[c]*s + 2*Sqrt[(-c)*s^2 + v^2])) Out[69]= {0, -(2/Sqrt[(-c)*s^2 + v^2])} > My question is: How can I get what I found by hand using Mathematica You can work as follows: In[92]:= integrand = (Simplify[#1, v >= 0] & )[expr*ds /. s -> (v/Sqrt[c])*t /. ds -> D[(v/Sqrt[c])*t, t]] Integrate[integrand, t] % /. t -> (Sqrt[c]/v)*s Out[92]= 1/(Sqrt[c]*Sqrt[1 - t^2]) Out[93]= ArcSin[t]/Sqrt[c] Out[94]= ArcSin[(Sqrt[c]*s)/v]/Sqrt[c] (*) Copy/Paste the following in a notebook and execute the codel; be ready to be imressed (the code is adopted by Trott's Guidebook for Programming). In[1]:= (* keep where messages are sent to *) old$Messages = $Messages; (* a bag for collecting the steps *) bag = {}; (* as a side effect, collect all steps *) $MessagePrePrint = AppendTo[bag, #]&; (* redirect messages *) $Messages = nowhere; On[]; (* do the integration *) Integrate[1/Sqrt[v^2 - c*s^2], s]; Off[]; (* restore where messages are sent to *) $Messages = old$Messages; $MessagePrePrint = Short; In[16]:= {Depth[bag], Length[bag], ByteCount[bag], LeafCount[bag], StringLength[ToString[FullForm[bag]]]} Out[16]= {19, 5522, 1403096, 62702, 474122} In[25]:= Short[bag,100] Best Regards Dimitris P=2ES. In another CAS (due to the policy of this forum I can't mention its name) I took int(1/sqrt(v^2-c*s^2),s); 1/2 c s arctan(--------------) 2 2 1/2 (v - c s ) ---------------------- 1/2 c in agreement with the result you obtained by hand. But I still regard as more correct Mathematica's result! =CF/=C7 Tulga Ersal =DD=E3=F1=E1=F8=E5: > Dear Mathematica users, > > Let's consider the integral > > Integrate[1/Sqrt[v^2 - c*s^2], s] > > where v and c are positive reals. When I calculate the integral by hand, = I get > > ArcSin[(Sqrt[c]*s)/v]/Sqrt[c] > > However, if I evaluate the integral in Mathematica, I get > > (I*Log[(-2*I)*Sqrt[c]*s + 2*Sqrt[-(c*s^2) + v^2]])/Sqrt[c] > > which not only does not look like what I have found by hand, but > also, for v=4, c=2, s=1, for example, gives > > 0.255525 + 1.47039 i > > as opposed to just 0.255525. > > If you evaluate the integral in Mathematica with the said values (v=4, = c=2) > > Integrate[1/Sqrt[4^2 - 2*s^2], s] > > you get the answer > > ArcSin[s/(2*Sqrt[2])]/Sqrt[2] > > which agrees with what I have found by hand. > > My question is: How can I get what I found by hand using Mathematica > without having to assign values to v and c before evaluating the > integral? I tried adding the assumptions v>0, c>0, but it didn't help. > > I'd appreciate your help. > > Thanks, > Tulga