1
$\begingroup$

I solved an integral and get a conditional expression as the result. The conditions are quite heavy but if I use Assumptions within my Integral call the computation time is heavily increased. My question, how can I evaluate a conditional expression?

Example:

Integrate[1/Sqrt[z - Cos[x]], {x, 0, 2*Pi}]
Out[1]:= ConditionalExpression[(2 EllipticK[-(2/(-1 + z))])/Sqrt[-1 + z] + (
  2 EllipticK[2/(1 + z)])/Sqrt[1 + z], Re[z] > 1]

And now let's say I know that $z \in \mathbb{R}$. I want to see what conditions are left when I plug that assumption in (of course this is quite an easy case here, but in my case I have tons of conditions and I like to see which disappear because I can make certain assumptions). Again, I could use Assumptions but it will make the computation ultra slow.

$\endgroup$
0

2 Answers 2

2
$\begingroup$

You don't have to re-evaluate the integral with assumptions. You can instead use Simplify with assumptions directly on the conditional expression. In your second example

Integrate[ 1/Sqrt[ x^2 + y^2 - 2 x y Cos[z]], {z, 0, 2π}]

the output is

ConditionalExpression[(2 EllipticK[(-4 x y)/(x - y)^2])/Sqrt[(x - y)^2] 
                      +(2 EllipticK[(4 x y)/(x + y)^2])/Sqrt[(x + y)^2],  
                       (Re[x/y + y/x] >= 2 || Re[x/y + y/x] <= -2 ||
                      NotElement[x/y + y/x, Reals]) &&   Re[(x - y)^2] > 0 && 
                      Re[(x + y)^2] > 0]

Now, you can restrict $x$ and $y$ to be real numbers:

Simplify[ %, Assumptions-> {x ∈ Reals, y ∈ Reals}

Or assume that they are both larger than zero (which implies the former)

Simplify[ %, Assumptions -> {x > 0, y > 0}]

etc. This is reasonably fast and doesn't require re-evaluating the integral over and over again

$\endgroup$
2
$\begingroup$

At my machine HP, Mma 9.0.1.0, WinXP

Timing[Integrate[1/Sqrt[z - Cos[x]], {x, 0, 2*Pi}, 
  Assumptions -> z > 1]]

(*  {1.187500, (
 2 (Sqrt[1 + z] EllipticK[-(2/(-1 + z))] + 
    Sqrt[-1 + z] EllipticK[2/(1 + z)]))/Sqrt[-1 + z^2]}  *)

1.9 seconds is not too much, is it? Might it be that you had some expensive process on the background? Otherwise one can do like this:

    Simplify[ConditionalExpression[(2 EllipticK[-(2/(-1 + z))])/
    Sqrt[-1 + z] + (2 EllipticK[2/(1 + z)])/Sqrt[1 + z], Re[z] > 1], 
 z > 1]

 (*    (2 EllipticK[-(2/(-1 + z))])/Sqrt[-1 + z] + (
     2 EllipticK[2/(1 + z)])/Sqrt[1 + z]   *)
$\endgroup$
4
  • $\begingroup$ Could you try Integrate[1/Sqrt[x^2 + y^2 - 2*x*y*Cos[z]], {z, 0, 2*Pi}, Assumptions -> {x \[Element] Reals, y \[Element] Reals, x > 0, y > 0}], this takes an extremely long time on my machine, and I have just the MathKernel running. I just wanted to make my point with a simple example. $\endgroup$
    – DaPhil
    May 8, 2014 at 8:24
  • $\begingroup$ Without the assumption it is much faster but gives me conditional expressions. $\endgroup$
    – DaPhil
    May 8, 2014 at 8:26
  • $\begingroup$ @DaPhil Yes, I tried this integral and you are right. It takes infinite time with assumptions and about 13 s without. $\endgroup$ May 8, 2014 at 12:33
  • $\begingroup$ I see now that your 2nd part gives the answer and is as correct as the answer from Oliver Jennrich... Unfortunately can't mark both as accepted answer. $\endgroup$
    – DaPhil
    May 8, 2014 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.