I'm looking for a function that gives
f(1)=-1; f(2)=0; f(3)=1; f(4)=0.
The other values are undefined and I don't pay any attention on them. The prefered functions are +, -, *, %, div and abs. (the shorter function - the better).
It could be kind of sinus with period of 4, but sinus is not amonght the functions I asked above. Needed for the programming to unite 4 cases into one (the first case we substract 1, the second and fourth we do nothing, for the third one we add one).
Thank you.
Try the following: $$-|x-3|+1$$
An easy sine function should also work:$$-\sin(\frac{5x}{\pi})$$