I would like to define some function $f$ that is odd, $f(-x)=-f(x)$, and can be used in symbolic computations. I am a bit more ambitious than this question and its answers. One way of achieving my goal is to use Mathematica's function OrderedQ to define
f[0] = 0;
f[x_] /; OrderedQ @ {x,-x} := -f[-x]
This does the job, giving e.g.
f /@ {-x, x-y, -x+y}
(* Out: {-f[x], -f[-x+y], f[-x+y]} *)
What I would really like, though, is to define an odd function $g$ that produces the aesthetically more pleasing
(* Out: {-g[x], g[x-y], -g[x-y]} *)
The reason for the mismatch must have to do with the internal ordering that Mathematica uses. How do I get a function yielding my preferred result?
NB. The above is adapted from Section 5.6 of Grozin's Introduction to Mathematica for Physicists, who instead sets
h[0] = 0;
h[x_] /; Not @ OrderedQ @ {-x,x} := -h[-x]
Like $f$ this yields
(* Out: {-h[x], -h[-x+y], h[-x+y]} *)