# Strange behavior with Conditioned[]

I am using Mathematica 12.0 on Windows and I recently tried to evaluate a conditional expectation, namely

Expectation[Conditioned[X, X < 0.5], Distributed[X, UniformDistribution[{0, 1}]]]


However, when running it, I obtain the error message

\$RecursionLimit::reclim2: Recursion depth of 1024 exceeded during evaluation of X<1/2.


paired with

Hold[Expectation[X \[Conditioned] X < 0.5, X \[Distributed] UniformDistribution[{0, 1}]]]


I tried closing Mathemtica and re-opening it and it correctly gave me the answer of 0.25. Does anyone know why the behavior of the first try?

I also tried

Probability[Conditioned[X, X < 0.5], Distributed[X, UniformDistribution[{0, 1}]]]


which remains unevaluated.

Adding the method Trace returns

Inactive[Integrate][
x*Piecewise[{{0., x < 0}, {2., Inequality[0, LessEqual, x, Less, 0.5]}}, 0],
{x, 0, 1}, GenerateConditions -> False, Assumptions -> True]

• I cannot seem to reproduce this in the Cloud version. Did you try this on a fresh kernel? – J. M.'s ennui Feb 3 '20 at 0:59
• Yes I tried both on a fresh kernel. The first time it gave me the first error, while the second it gave me the correct answer. On both cases the Probability command remains unevaluated. – DMH16 Feb 3 '20 at 1:01
• Can you try adding the option Method -> "Trace" to Expectation[] and see what gets returned? (Also, Probability[] with Conditioned[] expects a relation and not a function, e.g. Probability[Conditioned[0.2 < X < 0.6, X < 0.5], Distributed[X, UniformDistribution[{0, 1}]]].) – J. M.'s ennui Feb 3 '20 at 1:02
• added the output – DMH16 Feb 3 '20 at 1:13
• Perhaps you had defined X in the original session. – John Doty Feb 3 '20 at 1:57