Below is an operator

$\hat{D}=\sum_{i,j}^2 \frac{\partial}{\partial u^i}\sqrt{g}g^{ij}\frac{\partial}{\partial u^j}$

where $g_{ij}=\begin{pmatrix}p(x,y) & q(x,y)\\\ q(x,y) & r(x,y)\end{pmatrix}$ and $u^1,u^2$ are respectively $x$ and $y$.

In mathematica, how do I make it act on a function $F(x,y)$? Im having trouble understanding how to do the summation part. The functions $p,q,\& \, r$ will all be specified but $F$ is to remain arbitrary. What I actually then want to get is an equation


This is easy to work out by hand if $i,j$ only run from 1 to 2, but I want to learn if there is a way to make it work in Mathematica if I replace 2 with 3 or more.


1 Answer 1



Do you mean something like this? (I did not know what you meant with the root of the matrix $g$, so I left it out)

g[x_, y_] := {{p[x, y], q[x, y]}, {q[x, y], r[x, y]}};
op[u1_, u2_] = (
   D[g[u1, u2][[1, 1]]*D[#, {u1, 1}], {u1, 1}]
    + D[g[u1, u2][[1, 2]]*D[#, {u2, 1}], {u1, 1}]
    + D[g[u1, u2][[2, 1]]*D[#, {u1, 1}], {u2, 1}]
    + D[g[u1, u2][[2, 2]]*D[#, {u2, 1}], {u2, 1}]
   ) &

enter image description here

Application on function

op[x, y][F[x, y]]

enter image description here

Update: Summation

op2[u_] = Sum[
   D[(g @@ u)[[i1, i2]]*D[#, {u[[i2]], 1}], {u[[i1]], 1}]
   , {i1, Length@u}
   , {i2, Length@u}
   ] &

op2[{x, y}][F[x, y]] == op[x, y][F[x, y]]


  • $\begingroup$ g was actually just the determinant of the matrix g_{ij}. Is there a way to write op[u1_,u2_] without explicitly writing code for all the terms? $\endgroup$
    – jboy
    Sep 20, 2020 at 8:11
  • $\begingroup$ See update at the bottom $\endgroup$ Sep 20, 2020 at 8:19

Your Answer

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

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