# What is the operator for inverting the sign of the argument of a function?

I want an operator that takes as input a function of a real variable e.g. f(x) and returns as output the answer f(-x). How does one define such an operator in Mathematica?

• f[x] /. h_[a_]:>h[-a] but I guess the best solution may be background dependent. So what it the big picture here? What have you tried? – Kuba Sep 12 '17 at 10:08
• Try f @* Minus. – J. M.'s technical difficulties Sep 12 '17 at 16:23
• Thanks for all answers. I am looking for Pure functions only. Some of these will work for me... – Quasar Supernova Sep 13 '17 at 12:04

You can define such a operator like so.

yAxisReflect[f_] := (f[-#] &)


where f is a symbol naming a function or a pure function.

With this definition, you can do things like

Plot[{Sin[x], yAxisReflect[Sin][x]}, {x, -π, π}] Plot[{(1 + x)^2, yAxisReflect[(1 + #)^2 &][x]}, {x, -2, 2}] One approach is to define a "negative" function directly:

g[x_] := f[-x]


So however f[x] is defined, g[x] gives f[-x]. But really, why do this? Wouldn't it be simpler and clearer just to use f[-x] directly whenever needed?

ClearAll[reflectionF1, reflectionF2]
reflectionF1[f_] := Compose[f, Minus, #] &;
reflectionF2[f_] := Composition[f, Minus] (* f @* Minus  in V 10.0+ as suggested by JM *)


Using m_goldberg's example setup:

Row[{Plot[{Sin[x], reflectionF1[Sin][x]}, {x, -\[Pi], \[Pi]},
PlotLabel -> Style["reflectionF1", 16, "Panel"], ImageSize -> 400, PlotStyle -> Thick],
Plot[{Sin[x], reflectionF2[Sin][x]}, {x, -\[Pi], \[Pi]},
PlotLabel -> Style["reflectionF2", 16, "Panel"], ImageSize -> 400, PlotStyle -> Thick]}] 