# Computing the differental of an orthogonal projection

I am having trouble computing the differental of a map. This is the context:

Let $S\subset \mathbb R^3$ be a regular surface, and fix a point $p\in S$.

Let $\pi:\mathbb R^3\to T_pS$ be the orthogonal projection onto $T_pS\subset \mathbb R^3$, and let $h=\pi|_S$ be the restriction of $\pi$ to $S$. Why is $h$ differentiable? Carefully show that $dh_p$ is injective.

I said that $h$ is differentaible, because it is the restriction of a differentiable function.

Next I assume that near $p$ the surface $S$ is parametrized by some parametrization, say $X(u,v)$. Then I choose $\{X_u,X_v,n\}$ as a basis for $\mathbb R^3$. Now we see that $h(x,y,z)=(x,y)$ which would mean that $$dh_p=\begin{pmatrix}1&0&0\\0&1&0\end{pmatrix}.$$ This doesn't seem right to me, because the zero-culumn suggests tha $dh_p$ isn't injective.

Where exactly am I slipping up?

We have $h:S\rightarrow T_pS,$ or, to state it more explicitly, $h$ is defined on $S,$ and $S$ is 2-dimensional. If you want to express $dh_p$ as a matrix, you have to work with a coordinate chart for $S$ around $p.$ In more detail, this works as follows.
By applying translations in $\mathbb R^3$ and parameter space $(u,v),$ we can assume that $p = 0$ in $\mathbb R^3$ and $X(0,0) = 0.$ Denote the standard orthogonal basis in $\mathbb R^3$ by $e_1,e_2,e_3.$ By using the inverse function theorem, or the implicit function theorem, we can find a new parametrization $Y = Y(\xi,\eta)$ of $S$ given by $$Y(\xi,\eta) = \xi e_1 + \eta e_2 + f(\xi,\eta) e_3,$$ where $f$ is a real-valued, smooth function with $f(0,0) = 0.$ This is a standard construction from differential geometry. Note that $Y(0,0) = 0 \in \mathbb R^3,$ $T_0S = \mathbb R e_1 + \mathbb R e_2,$ and $e_3$ is the normal at $S$ in $0.$ In the coordinates $(\xi,\eta),$ we have $$h:(\xi,\eta)\mapsto Y(\xi,\eta) = \xi e_1 + \eta e_2 + f(\xi,\eta) e_3 \mapsto \xi e_1 + \eta e_2.$$ In these coordinates, it's "obvious" that $$dh_0 = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix},$$ which is very well injective, even invertible.