Simplify a long boolean expression

Im pretty new to this plattform and well I have a trouble regarding boolean expression in my CS-class. I have to simplifly this boolean expression and have no clue how to do this.

double x ; double y ;

boolean b = ( (y < -x) ^ (5 * x >= y) ) && ( (x < -y) != (x >= y * 0.2) )

Upvotes: 0

Views: 172

Answers (1)

Assuming pure math, y < -x is equivalent to x < -y, 5 * x >= y is equivalent to x >= y * 0.2 and whateverBoolean1 ^ whateverBoolean2 is equivalent to whateverBoolean1 != whateverBoolean2. Hence you can omit any side of && operator.

I am neglecting freaks of floating point arithmetics (0.2 is not precise number so some counterexample that original and simplified expression are not equivalent could be perhaps found after some effort.)

Upvotes: 2

Related Questions