# Construction of symmetric function / matching function argument patterns

[Edited for clarification after comment]

Suppose that the function f is defined as the linear combination of several translated/reflected functions starting from the primitive f0[x,y,z]

f[x_, y_, z_] := f0[x,y,z-z1]+f0[x,y,z-z3]+f0[x,y,z-3z2+z1]


wherein z1,z2,z3,... are real positive numbers. The actual composition of f is not known, but it follows the above pattern.

I would like then to construct the function g obtained from f by considering the negative value of the third argument. The required output in this example would be

g[x_, y_, z_] := f0[x,y,-(z-z1)]+f0[x,y,-(z-z3)]+f0[x,y,-(z-3z2+z1)]


I cannot simply do

g[x_, y_, z_] := f[x, y, -z]


since this would yield

f0[x, y, -z - z1] + f0[x, y, -z + z1 - 3 z2] + f0[x, y, -z - z3]


How would is that possible to find and isolate in general the third argument of f0 so that the proper substitution can be applied? Or what would be the cleanest way of define the functions f and g?

• Could do something like f[x,y,-z]/.z1->-z1 but a prior question: why is f defined in terms of a "global" variable z1? In other words, why is it not f[x_,y_,z_,z1_]:=...? May 31, 2019 at 18:43
• Thank you very much for your comment. This is a simplified minimal example taken out of context. I have a combination of translated / reflected functions in which I could find f0[x,y,z-z1] or something else like f0[x,y,z-3z2+z1], f0[x,y,z-z3], wherein z1,z2,z3 are real positive numbers. I do not know in advance what would be my third argument of f0 and so I was looking for a more general way to do the substitution and cannot do it directly. May 31, 2019 at 18:52
• You will need to give a clear description of the actual problem, by editing the original post. May 31, 2019 at 18:57

A simple solution is as follows. If your f stores a combination of the f0's and if the g is intended to be f with negated third argument in all contained f0, then consider doing:

f[x_, y_, z_] := f0[x,y,z-z1]+f0[x,y,z-z3]+f0[x,y,z-3z2+z1]
g[x_, y_, z_] := f[x,y,z]/.f0[a_,b_,c_]->f0[a,b,-c]


then for example

f[q, w, r]


f0[q, w, r - z1] + f0[q, w, r + z1 - 3 z2] + f0[q, w, r - z3]

and

g[q, w, r]


f0[q, w, -r + z1] + f0[q, w, -r - z1 + 3 z2] + f0[q, w, -r + z3]

• Thank you very much - it was indeed what I was looking for - it is much appreciated :) Jun 1, 2019 at 8:59