MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Integrate yields complex results

  • To: mathgroup at
  • Subject: [mg128004] Re: Integrate yields complex results
  • From: "Dr. Wolfgang Hintze" <weh at>
  • Date: Sat, 8 Sep 2012 03:09:08 -0400 (EDT)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • References: <k29m8f$ab8$>

On 6 Sep., 10:19, matteo.poggi... at 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.

In[2]:= f1 =
  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

Best regards,

  • Prev by Date: Re: Landau letter, Re: Mathematica as a New Approach...
  • Next by Date: Re: A new FrontEnd
  • Previous by thread: Integrate yields complex results
  • Next by thread: Re: Integrate yields complex results