Re: Integrate yields complex results
- To: mathgroup at smc.vnet.net
- Subject: [mg128004] Re: Integrate yields complex results
- From: "Dr. Wolfgang Hintze" <weh at snafu.de>
- Date: Sat, 8 Sep 2012 03:09:08 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
- References: <k29m8f$ab8$1@smc.vnet.net>
On 6 Sep., 10:19, matteo.poggi... at gmail.com wrote: > Hi, using Mathematica 8.0 I computed this expression: > > Integrate[((1 + y^2) (1 + x^2 + y^2)^(1/2))^(-1), y] > > obtaining ugly complex Logarithms which cannot be simplified even with ExpToTrig. The correct real result is given by Mathematica 5.2 and is > > ArcTan[xy/((x+^2+y^2+1)^(1/2))] > > How is possible to obtain this result with 8.0 version. > I even tried to calculate Real and Imaginary part, but 8.0 refuses to do that. Please help me. I need to use Mathematica for research. Your integral is In[1]:= f = Integrate[((1 + y^2)*(1 + x^2 + y^2)^(1/2))^(-1), y] Out[1]= (I* Log[(4*I*(1 + x^2 + I*y))/(x*(-I + y)) + (4*I* Sqrt[1 + x^2 + y^2])/(-I + y)])/(2*x) - (I*Log[-((4*I*(1 + x^2 - I*y))/(x*(I + y))) - (4*I* Sqrt[1 + x^2 + y^2])/(I + y)])/(2*x) Getting more and more annoyed, I didn't succeed to find the simplification until I eventually remembered the option TargetFunctions which used to be useful in telling ComplexExpand more precisely what to do. Thus In[2]:= f1 = FullSimplify[ ComplexExpand[f, TargetFunctions -> {Re, Im}], {x > 0, y > 0}] Out[2]= (-Pi + ArcTan[(x*y)/Sqrt[1 + x^2 + y^2]])/x This is in fact your integral which as an indefinite integral correctly provides an antiderivative. Indeed, the first derivative with respect to y is In[3]:= Simplify[D[f1, y]] Out[3]= 1/((1 + y^2)*Sqrt[1 + x^2 + y^2]) which gives back the integrand. Now, let's have a look at the definite integral between 0 and t: In[1]:= Timing[ g = Integrate[((1 + y^2)*(1 + x^2 + y^2)^(1/2))^(-1), {y, 0, t}, Assumptions -> {Element[{x, t}, Reals], t > 0}]] Out[1]= {15.709, (I*(2*I*ArcCot[(t*x)/Sqrt[1 + t^2 + x^2]] + Log[-((2*I)/x)] - Log[(2*I)/x]))/(2*x)} This takes some time (15.7 seconds) and gives again a complex result despite the Assumptions. (For comparision, version 5.2 needs just 1.3 seconds for the final real result). Simplifying it similarly gives In[2]:= Timing[ g1 = FullSimplify[ ComplexExpand[g, TargetFunctions -> {Re, Im}], {x > 0, y > 0}]] Out[2]= {0.1709999999999976, (Pi - 2*ArcCot[(t*x)/Sqrt[1 + t^2 + x^2]])/(2*x)} This result is okay but more complicated than necessary. I didn't have the nerve so late at night to simplify it in version 8. Now the definite integral can of course be calculated by hand by taking the difference of f1 calculated earlier: In[319]:= fi = Simplify[(f1 /. y -> t) - (f1 /. y -> 0)] Out[319]= ArcTan[(t*x)/Sqrt[1 + t^2 + x^2]]/x That's the result we liked to get immediately. Summarizing, I would refuse to say that version 8 is really very helpful in this caculation. It is the other way round: as a user you must be generously and time-consumingly helpful towards version 8 to obtain a satisfactory result. If I had a wish free from Wolfram I would like to have the function Integrate improved as soon as possible restoring the power of version 5.2. Best regards, Wolfgang