# Transform a field with derivatives

Given a function of Cartesian coordinates $$(x, y)$$ in $$g(x, y) = \frac{d}{dx}f(x, y)-y\frac{d}{dy}f(x, y)$$, I want to transform this expression to polar coordinates $$(r,\phi)$$. I saw a solution using built-in chain rule here: Change variables in differential expressions and a possible solution using replacement here: Transformation of Derivatives under change of coordinates. I also came across TransformedField , which seems very succinct but it would only tranform $$(x, y)$$ in the expression but not the derivatives, i.e. it gives me the following:

TransformedField["Cartesian" -> "Polar",
D[f[x, y], x] - x*D[f[x, y], y], {x, y} -> {r, \[Phi]}
]


output

$$f^{(1,0)}(r \cos (\phi ),r \sin (\phi ))-r \cos (\phi ) f^{(0,1)}(r \cos (\phi ),r \sin (\phi ))$$.

I wonder why this is the case? Or if there is any trick to make it work with TransformedField?

Edit 1

Kuba pointed out an existing function in "MoreCalculus," which works well for simple expression. But when I use it for a more complicated expression, I'm not sure if it outputs correct result:

Input expression with $$dx = \frac{d}{dx}$$ and $$dy = \frac{d}{dy}$$

Output is very long but contains an expression with prime as shown here: $$i e \left(-\frac{1}{2} B r \sin (\phi )\right)'$$

And I'm not sure what that prime denotes or why it doesn't simplify (I already used FullSimplify). Any help would be appreciated.

• DChange[ D[f[x, y], x] - x*D[f[x, y], y], "Cartesian" -> "Polar", {x, y}, {r, \[Phi]}, f[x, y] ] seems to do the trick. Is that the answer: change of variables in differential expressions? – Kuba Jan 11 at 23:11
• Thanks for the link Kuba! So I applied it to my more complicated expression , and one of the outputs has a prime on it (shown in the edits). Do you know what the prime means? – Histoscienology Jan 12 at 2:53
• Please provide a copyable code for input and output. After I created that function I used it maybe twice, and it has around four unit tests so I am not surprised fails for more complicated cases ;) – Kuba Jan 12 at 20:38