# Evaluate conditional expression

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:= 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.

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

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]   *)

• 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. – DaPhil May 8 '14 at 8:24
• Without the assumption it is much faster but gives me conditional expressions. – DaPhil May 8 '14 at 8:26
• @DaPhil Yes, I tried this integral and you are right. It takes infinite time with assumptions and about 13 s without. – Alexei Boulbitch May 8 '14 at 12:33
• 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. – DaPhil May 8 '14 at 12:42