# always get absolute value of unknown input data (sometimes positive/sometimes negative)

I need to find an absolute value for a variable, but it is homomorphic encrypted. So, sometimes my x might be x=2, or other times x=-4. I want my function to always return the positive value even if the input is positive or negative, without knowing how it actually is. I can't do comparison. All i can do is add/sub/mult with my variable x, and it's negation. Can you think at a mathematic way to build a function that always returns me the positive value?? Thank you!

• Multiply $x$ by itself and compute the square root. – Mauro ALLEGRANZA Jun 8 '17 at 8:12
• Thx, but the problem is that I can multiply x by itself, but then I can not make sqrt ... like i said the value is encrypted so i have a limited number of operations. – Andrei En Jun 8 '17 at 8:14
• Do you have a way to recognize integers, even after encryption? Say you wanted to tell if your number is even or odd rather than positive or negative. Could you simply divide by 2 and check if the outcome is integral, or does the encoding make that impossible? – Vincent Jun 8 '17 at 10:43
• Using add/sub/mult, you always get a differentiable function. But the absolute value is not differentiable at $0$. Therefore it is impossible to express the absolute value only in terms of add, sub and mult. – Reinhard Meier Jun 8 '17 at 11:37