0

Suppose I have $X,Y$ that are equal to one or zero.

Is it possible to formulate a binary variable that is equal to $1$ if both $X,Y$ have the same value (i.e. $X=0$, $Y=0$ or $X=1$, $Y=1$) or equal to $0$ if they are different (i.e. $X=1$, $Y=0$ or $X=0$, $Y=1$)

Something like $(2X-1)(2Y-1)$ is kind of close but not there.

Thank you!

Travis Willse
  • 99,363

1 Answers1

1

If true is $1$ and false is $0$, then $x+y \equiv 0 \, \textrm{mod}(2)$ if and only if the binary variables $x$ and $y$ are equal.