Divergence and curl from orthogonal coordinate gradients (source code)

= Divergence and curl from orthogonal coordinate gradients
{title2=$\nabla u_i=\mathbf e_i/h_i$}

For a right-handed regular system of <orthogonal coordinates>, the <gradient in orthogonal coordinates> gives $\nabla u_i=\mathbf e_i/h_i$. Thus $\phi\mathbf e_1=(\phi h_1)\nabla u_1$, and the <curl> product rule gives
$$
\nabla\times(\phi\mathbf e_1)=\nabla(\phi h_1)\times\nabla u_1=\frac{\mathbf e_2}{h_1h_3}\partial_{u_3}(\phi h_1)-\frac{\mathbf e_3}{h_1h_2}\partial_{u_2}(\phi h_1).
$$
Also $\nabla u_2\times\nabla u_3=\mathbf e_1/(h_2h_3)$ and the <divergence> of this cross product is zero, by the divergence-of-a-cross-product identity and the vanishing curl of each gradient. Applying the divergence product rule to $\phi\mathbf e_1=(\phi h_2h_3)(\nabla u_2\times\nabla u_3)$ gives
$$
\nabla\cdot(\phi\mathbf e_1)=\frac{\partial_{u_1}(\phi h_2h_3)}{h_1h_2h_3}.
$$
Cyclic permutation and addition give the full component formulas for any <vector field>. This derivation accounts for the varying coordinate basis without differentiating its unit vectors explicitly. The factors $h_i>0$ are <scale factors of orthogonal coordinates>; the chart must avoid coordinate singularities.