Logical comparison of two values with algebra

33 Views Asked by At

Suppose I have two real numbers A and B (A $\wedge$ B $\subset$ $\mathbb{R}$).

I want to do some algebra over these number and get 1 if they are equal and get 0 if not.

For example:

In this equation $sin(A)^2+cos(b)^2$ if A and B are equal we get 1 but we will not get 0 if they are not.

or obviously:

$A \times \frac{1}{B}$ will generate one if A and B are the same otherwise we will get something else.

I look for some sort of algebra to not only get one if the numbers are the same but also get 0 if they are different.

I prefer multiplication (second equation) as I can create a matrix algebra for that.

1

There are 1 best solutions below

3
On

If you allow the floor function, $\lfloor x\rfloor$, you could use $$\left\lfloor \frac{1}{(A-B)^2+1}\right\rfloor$$