Suppose I have two systems of coordinates:{x1,x2} and {y1,y2}. I want to transform an expression containing $\frac{\partial yi}{\partial xj}$'s to those in terms of $\frac{\partial xj}{\partial yi}$'s. I wrote the following code:
expr = D[y2[x1, x2], {x1, 2}, {x2, 0}] + D[y1[x1, x2], {x1, 0}, {x2, 2}];
expr /. Derivative[n_, m_][y : y1 | y2][x1, x2] -> Nest[(1/D[x2[y1, y2],
y1])*D[#1, y1] + (1/D[x2[y1, y2], y2])* D[#1, y2] &, Nest[(1/D[x1[y1, y2],
y1])*D[#1, y1] + (1/D[x1[y1, y2], y2])* D[#1, y2] &, 1/D[x1[y1, y2], y], n], m]
Why is this not working? It seems n,m and y are not recognized in the RHS of my replacement rule.
Edit 1:(Special case of expr where Nest is not evaluated)
The above was a snippet of a bigger problem I have been working on. There expr is a pure function. And then the above rule doesn't evaluate the Nest functions:
expr=Derivative[0, 1][y1][x1, x2]*D[#1, {y1, 1}, {y2, 0}] &
expr/.Derivative[n_, m_][y : y1 | y2][x1, x2] :>
Nest[(1/D[x2[y1, y2], y1])*D[#1, y1] + (1/D[x2[y1, y2], y2])*
D[#1, y2] &,
Nest[(1/D[x1[y1, y2], y1])*D[#1, y1] + (1/D[x1[y1, y2], y2])*
D[#1, y2] &, 1/D[x1[y1, y2], y], n], m]
How to force evaluation here?