This question about differential manifolds has 2 parts, I managed to do the first but not the second.
A. Let $M\subset \mathbb{R}^n$ be a $k$-dimentional manifold ($k<n$) and let $f:\mathbb{R}^n\rightarrow \mathbb{R}$ be a smooth function.
Let $x_0\in M$ be a local extremum of $f$. Show that for every $h\in T_{x_0}M$, $$D_{x_0}f(h)=0$$
That's actually quite easy: we can take a smooth path $\gamma(t)$ with $\gamma(0)=x_0, \dot{\gamma}(0)=h$, and then $f\circ \gamma: I\rightarrow \mathbb{R}$ has local extremum in $0$, so it's derivative is $0$ there, and then the chain rule gives us the desired equality.
The second part is:
B. Prove that given these $M, x_0$, we can always choose a function $f$ that satisfies the conditions of the first part, and also $D_{x_0}f\neq 0$.
I have a geometric intuition about what I need to prove buy I still have no idea how to prove it. Any ideas?
Since $M$ is a $k$-dimensional submanifold of $\mathbb{R}^n$, we can choose a chart $(U, \phi) = (U, x^1,...,x^n)$ of $\mathbb{R}^n$ which is adapted to $M$, in the sense that $U \cap M = \{x^{k+1}= \cdots = x^n = 0\}$. Since $\phi$ defines a coordinate system about $x_0 \in U$ we have, $f = f \circ \phi$. Now apply the chain rule and you'll have your result.
$$Df \underbrace{(v^1,...,v^k,...,0)^T}_{h} = Df \cdot \begin{pmatrix} 0 \\ \vdots \\ x^k=0 \\ 1 \\ \vdots \\ 1\end{pmatrix}(v^1,...,v^k,...,0)^T $$
$\textbf{Edit}$
$$Df|_{x_0} = \begin{pmatrix} \frac{\partial f}{\partial x^1}(x_0) = 0 & \cdots & \frac{\partial f}{\partial x^k}(x_0) = 0 & \frac{\partial f}{\partial x^{k+1}}(x_0)& \cdots &\frac{\partial f}{\partial x^{n}}(x_0)\end{pmatrix}$$
How the idea works is we have to assume $f$ is not a constant function, otherwise this result is incorrect. With this assumption, we can choose a chart $(U, \phi)$ as above. Plus, since $f$ is not constant, for some $x^j$ we have $\partial f/\partial x^j (x_0) \not = 0$. Can you finish now?