derivation of surface gradient Suppose the surface S is parameterized as $\textbf{x}=(x_1(u_1,u_2),x_2(u_1, u_2), x_3(u_1,u_2))$,  then the surface gradient $\nabla_{S}$ of a scalar function $p(x_1,x_2,x_3)$ on $S$ is defined as,
$$\tag{1} \nabla_S p = \sum_{i,j=1}^{2}g^{ij}\frac{\partial p}{\partial u_i}\frac{\partial \textbf{x}}{\partial u_j}\hspace{2cm} $$
where $g^{ij}$ is the (i,j)th entry of the inverse of the matrix $G$ given by
$$G_{ij}=\frac{\partial\textbf{x}}{\partial u_i}\cdot\frac{\partial\textbf{x}}{\partial u_j},i,j=1,2$$
From this definition, we have the following formula,
\begin{equation}
\tag{2} \nabla_{S}p=\textbf{n}\times\nabla p\times \textbf{n}\hspace{2cm}
\end{equation}
where $\nabla p$ is the standard gradient in 3D, $\textbf{n}$ is the unit normal vector on $S$.
I have no idea how the surface gradient $\nabla_S p $ $(1)$ is defined. I try to understand this  by deriving $(1)$ from equation $(2)$, but this seems rather tedious. Can anyone  give a detailed derivation of $(1)$? Thanks!
 A: (2) is just another way to say that $\nabla_S p$ is the projection of $\nabla p$ to the plane perpendicular to $\textbf{n}$ (that is, the tangent plane). To see this, for each vector $X$, write
$$X = X^\perp + X^\top, $$
where $X^\perp = (X\cdot \textbf n) \textbf n$ and $X^\top \in \textbf n ^\perp$. Then
$$ \textbf n \times X \times \textbf n =  \textbf n \times X^\top \times \textbf n = X^\top$$
(the second equality can be checked using the right hand rule).
Now the question is why (1) implies that $\nabla_S p$ is the projection of $\nabla p$ to the tangent plane. First of all, it is clear that $\nabla_Sp$ is tangential, since it is a linear combination of $\frac{\partial \textbf{x}}{\partial u_1}$ and $\frac{\partial \textbf{x}}{\partial u_2}$. Thus it suffices to check
$$\tag{3} \nabla_S p\cdot  X = \nabla p \cdot X$$
for all tangent vector $X$. Write
$$ X =\sum_{k=1}^2 a^k \frac{\partial \textbf{x}}{\partial u_k} = a^1 \frac{\partial \textbf{x}}{\partial u_1} + a^2 \frac{\partial \textbf{x}}{\partial u_2}.$$
Then
\begin{align}
 \nabla_S p \cdot X  &= \left( \sum_{i,j=1}^{2}g^{ij}\frac{\partial p}{\partial u_i}\frac{\partial \textbf{x}}{\partial u_j}\right) \cdot \left(\sum_{k=1}^2 a^k \frac{\partial \textbf{x}}{\partial u_k}\right) \\
&= \sum_{i,j,k=1}^2 g^{ij} \frac{\partial p}{\partial u_i} a^k G_{jk} \\
&= \sum_{i,k=1}^2 \delta_{ik} \frac{\partial p}{\partial u_i} a^k \\
&= \sum_{i=1}^2 a^i \frac{\partial p}{\partial u_i}. 
\end{align}
(To be precise, $p$ should be $p\circ \textbf x$). Now let $\gamma(t) = (u_1^0 + ta^1, u_2^0+ ta^2)$, then
$$\tag{4}\sum_{i=1}^2 a^i \frac{\partial p}{\partial u_i} = ((p\circ \textbf x) \circ \gamma)'(0)$$
by chain rule. On the other hand, write $(p\circ \textbf x) \circ \gamma= p\circ (\textbf x \circ \gamma)$, then
$$((p\circ \textbf x) \circ \gamma)'(0) =  \nabla p \cdot (\textbf x \circ \gamma)'(0) = \nabla p \cdot X. $$
Thus (3) is shown and we are done.
