A more elegant version of this function?

52 Views Asked by At

I challenged myself.

The goal was to find a function $f$ with two variables $x$ and $y$ real, which results $1$ if $x=y$ and results $0$ if $x ≠ y$. But, the fonction can only use additions, soustractions, multiplications, divisions, exponents and roots.

My solution is : $f(x,y) =1 - \sqrt{ \frac{ \sqrt{ (x-y)^{2} } } { x-y+0^{(x-y)^{2}} } ^{2}}$

And my question is : is there a solution more elegant using the same restrictions ?

EDIT : I suppose $0^0 = 1$

1

There are 1 best solutions below

5
On BEST ANSWER

If you assume $0^0=1$, then just use:

$$f(x, y)=0^{(x-y)^2}$$