MathGroup Archive 2011

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

Search the Archive

Re: Keeping it real

  • To: mathgroup at smc.vnet.net
  • Subject: [mg120287] Re: Keeping it real
  • From: Heike Gramberg <heike.gramberg at gmail.com>
  • Date: Sat, 16 Jul 2011 05:43:48 -0400 (EDT)
  • References: <201107150120.VAA23674@smc.vnet.net>

If you use Refine with appropriate Assumptions, you get a slightly better result:

Block[{a, c0, d0},
 Block[{$Assumptions = 0 < a < d0 && 0 < a < d0 + c0 z, pos},
  int = Expand@
    Refine[2*a*
      Integrate[((-d0/z^2)/(c0 + d0/z))/
        Sqrt[-a^2 + z^2 (c0 + d0/z)^2], z]]
  ]]

output:

-2 I Log[-((2 d0 (-I a + Sqrt[-a^2 + (d0 + c0 z)^2]))/(
    d0 + c0 z))] + (
 2 a Log[(2 d0 ((-a^2 + d0 (d0 + c0 z))/Sqrt[-a^2 + d0^2] +
      Sqrt[-a^2 + (d0 + c0 z)^2]))/z])/Sqrt[-a^2 + d0^2]

Note that the second Log-term is now real (provided the parameters satisfy the assumptions made). The first
Log-term can be simplified a bit further by using ComplexExpand. Since I want to leave the second Log as it
is, I just extract the first Log and apply ComplexExpand:

result = Block[{a, c0, d0, int},
  Block[{$Assumptions = 0 < a < d0 && 0 < a < d0 + c0 z, pos},
   int = Expand@
     Refine[2*a*
       Integrate[((-d0/z^2)/(c0 + d0/z))/
         Sqrt[-a^2 + z^2 (c0 + d0/z)^2], z]];
   pos = Position[int, -2 I Log[___]][[1]];
   ReplacePart[int,
    pos -> Expand@Simplify@ComplexExpand[Extract[int, pos]]]]
  ]

Output:

2 Arg[I a - Sqrt[-a^2 + (d0 + c0 z)^2]] - 2 I Log[2 d0] + (
 2 a Log[(2 d0 ((-a^2 + d0 (d0 + c0 z))/Sqrt[-a^2 + d0^2] +
      Sqrt[-a^2 + (d0 + c0 z)^2]))/z])/Sqrt[-a^2 + d0^2]

Which is real except for the constant term -2 I Log[2 d0]. Since an indefinite integral is unique up
to an arbitrary constant, you can add 2 I Log[2 d0] to get a real solution.


Heike.



On 15 Jul 2011, at 02:20, amannuc wrote:

> I am facing perhaps the "age-old" question of limiting the indefinite
> integrals that Mathematica returns. In particular, I am trying to
> avoid complex numbers. I have tried using "Assumptions" in the Integrate
> command to no avail.
>
> The specific integral is:
>
> SetAttributes[{c0, d0}, {Constant}] (* Probably redundant. See Block
> function *)
> Simplify[Block[{a, c0, d0},
>  2.0 * a *
>   Integrate[
> ((-d0/z^2)/(c0 + d0/z))/Sqrt[-a^2 + z^2 (c0 + d0/z)^2],
>    z,
> Assumptions -> {z \[Element] Reals, a \[Element] Reals,
>      c0 \[Element] Reals, d0 \[Element] Reals}]]]
>
>
>
> Admirably, Mathematica returns an answer, although with complex
> numbers. I verified the answer is correct by taking its derivative.
> The returned answer is:
> (0. - 2. I) Log[-((2 d0 (-I a + Sqrt[-a^2 + (d0 + c0 z)^2]))/(
>    d0 + c0 z))] + ((0. + 2. I) a Log[(
>   2 d0 ((I (-a^2 + d0 (d0 + c0 z)))/Sqrt[a^2 - d0^2] +
>      Sqrt[-a^2 + (d0 + c0 z)^2]))/z])/Sqrt[a^2 - d0^2]
>
> Note all the "I"s. This is a fairly simple answer returned. I doubt
> that is the only solution. When I evaluate it for cases of interest, I get
> complex numbers, which can't be right in my particular case which is
> based on a physical problem.
>
>
> Thanks for any insights.
>
> --
> Tony Mannucci
>



  • Prev by Date: Re: Numerical accuracy/precision - this is a bug or a feature?
  • Next by Date: Re: Compile and Total
  • Previous by thread: Keeping it real
  • Next by thread: Re: Keeping it real