0
$\begingroup$

I would like to gain some knowledge about how to transform differential operators to different coordinate systems using Mathematica. I know that the Laplacian command has an optional parameter chart that does this for various coordinate systems but I would like to gain some insight and possibly intermediate solutions doing this. As a simple test example, I believe the laplacian in polar coordinates will do just fine. So, I would like to transform $$ \Delta u = u_{xx} + u_{yy} $$

using $u(x,y)=w(r,\phi)$ and the transformation $x=r \cos\phi, y=r\sin\phi$ into

$$ \Delta w = \color{red}{\frac{1}{r^2}}w_{rr} + \frac{1}{r}w_{r} + \frac{1}{r^2} w_{\phi\phi} $$

Without incorporating the specific transformation one can of course calculate

D[w[r[x, y], phi[x, y]], x, x] + D[w[r[x, y], phi[x, y]], y, y]

but how would you use the transformation from here? How would you do this in a "step by step" manner, e.g. how would you calculate the derivative(s) of $r$ w.r.t. $x$?

Edit: as was kindly pointed out by Daniel Huber, the red part in the above laplacian shouldn‘t be there.

$\endgroup$
3
  • 3
    $\begingroup$ Is this what you want? $\endgroup$ Nov 25, 2020 at 9:26
  • $\begingroup$ I don't see how Kuba's DChange from his MoreCalculus really helps (unless I'm misusing it). I tried DChange[w = Laplacian[u[x, y], {x, y}], "Cartesian" -> "Polar", {x, y}, {r, \[Theta]}, {}] and the result was uninformative, keeping intact the form Derivative[0, 2][u][r*Cos[\[Theta]], r*Sin[\[Theta]]] + Derivative[2, 0][u][r*Cos[\[Theta]], r*Sin[\[Theta]]] and just stating the forms of r and \[Theta] in terms of x and y (along with the list of obvious restrictions on r and \[Theta]. $\endgroup$
    – murray
    Nov 25, 2020 at 18:11
  • $\begingroup$ I also tried current vector analysis functionality moved to the kernel from the old VectorAnalysis package, but alas TransformedField["Cartesian" -> "Polar", Laplacian[u[x, y], {x, y}], {x, y} -> {r, \[Theta]}] just returns ` \!(*SuperscriptBox[(u), TagBox[ RowBox[{"(", RowBox[{"0", ",", "2"}], ")"}], Derivative], MultilineFunction->None])[r Cos[[Theta]], r Sin[[Theta]]] + \!(*SuperscriptBox[(u), TagBox[ RowBox[{"(", RowBox[{"2", ",", "0"}], ")"}], Derivative], MultilineFunction->None])[r Cos[[Theta]], r Sin[[Theta]]]`. $\endgroup$
    – murray
    Nov 25, 2020 at 18:13

1 Answer 1

2
$\begingroup$

A step by step derivation:

We have:

x[r_, ϕ_] = r Cos[ϕ];
y[r_, ϕ_] = r Sin[ϕ];
ϕ[x_, y_] = ArcTan[x, y];
r[x_, y_] = Sqrt[x^2 + y^2];

Then doing the derivatives formally by hand we have (I use u[x,y] and u[r, ϕ] instad of u and w):

enter image description here

We replace the formal derivatives by MMA syntax:

rep1 = {Subscript[u, r] -> D[u[r, ϕ], r], 
   Subscript[u, rr] -> D[u[r, ϕ], {r, 2}], 
   Subscript[u, rϕ ] -> D[u[r, ϕ], r, ϕ], 
   Subscript[u, ϕ] -> D[u[r, ϕ], ϕ], 
   Subscript[u, ϕϕ] -> D[u[r, ϕ], {ϕ, 2}]};
rep2 = {Subscript[r, x] -> D[r[x, y], x], 
   Subscript[r, xx] -> D[r[x, y], {x, 2}], 
   Subscript[ϕ, x] -> D[ϕ[x, y], x], 
   Subscript[ϕ, xx] -> D[ϕ[x, y], {x, 2}], 
   Subscript[r, xy] -> D[r[x, y], x, y], 
   Subscript[r, y] -> D[r[x, y], y], 
   Subscript[r, yy] -> D[r[x, y], {y, 2}], 
   Subscript[ϕ, y] -> D[ϕ[x, y], y], 
   Subscript[ϕ, yy] -> D[ϕ[x, y], {y, 2}]};
rep3 = {x -> x[r, ϕ], y -> y[r, ϕ]};

Finally we take the expression for Subscript[u, xx]+Subscript[u, yy] from the picture above, evaluate the replacements and simplify:

Subscript[u, rr] Subscript[r, x]^2 + 
     2 Subscript[u, rϕ ] Subscript[r, x] Subscript[ϕ, x] + 
     Subscript[u, r] Subscript[r, xx] + 
     Subscript[u, ϕϕ] Subscript[ϕ, x]^2 + 
     Subscript[u, ϕ] Subscript[ϕ, xx] + 
     Subscript[u, rr] Subscript[r, y]^2 + 
     2 Subscript[u, rϕ ] Subscript[r, y] Subscript[ϕ, y] + 
     Subscript[u, r] Subscript[r, yy] + 
     Subscript[u, ϕϕ] Subscript[ϕ, y]^2 + 
     Subscript[u, ϕ] Subscript[ϕ, yy] /. rep1 /. rep2 /. 
  rep3 // Simplify[#, {r >= 0}] &

This gives the result:

enter image description here

As you can see, your formula above for the Laplacian in spherical coordinates is wrong.

$\endgroup$
1
  • $\begingroup$ Yes you can do it, but it looks ugly and you loose the overview. E.g. uxx== D[u[r[x, y], p[x, y]], {x, 2}] // Simplify . If you really want to do this, then define replacement rules that changes MMA syntax back to the short form. Or at least use //TraditionalForm $\endgroup$ Nov 25, 2020 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.