Let $\bf{x}\in\mathbb{R}^n$ (interesting in $n\in\{2,3\}$) and let $A=A_{n\times n}=\mathrm{diag}(a_1({\bf x}),\dots,a_n({\bf x}))$, that is $$A_{2\times2}=\begin{bmatrix} a_1(\bf{x})&0\\0&a_2(\bf{x}) \end{bmatrix} \quad \text{or}\quad A_{3\times3}=\begin{bmatrix} a_1(\bf{x})&0&0\\0&a_2(\bf{x})&0\\ 0&0& a_3(\bf{x}) \end{bmatrix} $$ Assume that $a_i\ne a_j, \forall 1\le i,j\le n$.
Let $\bf y$ be some curvilinear coordinates, e.g. elliptic, spherical, normal-tangential. I'm interesting to differentiate $$\mathrm{L}u({\bf x}) =\{\mathrm{div }(A\nabla u)\}({\bf x})$$ with respect to $y_i$ , that is to express $$\frac{\partial^m}{\partial y_i^m} \mathrm{L}u({\bf x}),\quad \text{interesting in no more then }0\le m\le4$$ explicitly but compact (by $m=0$ I mean just change of coordinates).
The expression, that I got so far (using scale factors\metrics), become too long and ugly. Say it is become pretty much unmanageable when I need to program it, which make it vulnerable for bugs and may affect numerical stability as well.
Example in 2D
Let $a_1=a, a_2=b$ one translates $$ \mathrm{L} u = \frac{\partial}{\partial x} \left( a u_x \right) + \frac{\partial}{\partial y} \left( b u_y \right) = a_x u_x + a u_{xx} + b_y u_y + b u_{yy} $$ to some (s,t) coordinates to get $$ \alpha u_s + \beta u_t +\gamma u_{st} +\delta u_{tt} +\sigma u_{ss} $$ and differentiate it, for an instant with respect to $s$ it to get $$\begin{align} & \alpha_s u_s +\alpha u_{ss} + \beta_s u_t + \beta u_{ts} +\gamma_s u_{st}+\gamma u_{sst} +\delta_s u_{tt}+\delta u_{tts} +\sigma_s u_{ss}+\sigma u_{sss}\\ =& \alpha_s u_s + \beta_s u_t+ (\alpha +\sigma_s) u_{ss} +\delta_s u_{tt}+ (\beta +\gamma_s) u_{st} +\gamma u_{sst}+\delta u_{tts}+\sigma u_{sss} \end{align}$$
Any help will be appreciated.
It seems to be somewhat far-fetched at first sight, but once you master some first principles, it will become apparent that Tensor Calculus may be indispensable to make these things amenable to systematic treatment. It's not easy to start with, but my personal experience is that it pays off.
Here are some Wikipedia references, but a good textbook may be preferable.
-
Ricci calculus
- Tensors in curvilinear coordinates
Below is a derivation of the gradient & Laplace operator, for spherical coordinates, as found in my old college notes: