Can you find a real function g(x) such that g(g(x))=-x? Note that if we allowed complex numbers, g(x)=ix would do the job.
Can you find another real function h(x) so for x≠0, h(h(x))=1/x?
In all cases, if you cannot find a solution that works for all x, a function valid for some ranges is better than nothing!