Say I have $f(x,y) + \partial_x f(x,y)$ e.g.
fun = f[x,y] + D[f[x,y],x]
I would like to use the substitution $f(x,y) \rightarrow \delta^2g(\delta x, \delta y)$ to get a new function. I have tried various things such as
fun /. {f[x, y] -> \[Delta]^2 g[\[Delta] x, \[Delta]y]}
fun /. {f -> \[Delta]^2 g}
fun /. {{f -> \[Delta]^2 g}, {x -> \[Delta] x}, {y -> \[Delta] y}}
fun /. {{f[x, y] -> \[Delta]^2 g[\[Delta] x, \[Delta]y]}, {D[f[x, y],
x] -> D[\[Delta]^2 g[\[Delta] x, \[Delta] y], x]}}
none of which produce the desired output of $\delta^2g(\delta x, \delta y) + \delta^3\partial_xg(\delta x, \delta y)$. The last(4th) attempt seems to be the closest, but the output is a two element list, with each element having a correct and incorrect term.