My lecture notes mention the following:
For $f : U \to \mathbb{R}$ differentiable, consider the level set
$N_y=\{x \in U : f(x)=y\}$.
Suppose that $c : I \to N_y \subset U$ is a differentiable curve. Then $f \circ c = y$ and so
$0=\frac{d}{dt}(f \circ c)=\langle grad f(c(t)), c'(t)\rangle \iff grad f(c(t) \perp c'(t)$ where the first equality follows by the chain rule.
Since this holds for any differentiable curve running through $N_y$, we can say that the gradient vector of $f$ is perpendicular to the level sets $N_y$.
The definition of the gradient used is:
Definition:
The gradient of $f : U \to \mathbb{R}$ is the uniquely determined map
$grad f : U \to \mathbb{R}^n$ with $\langle grad f(x),v=df_x(v)$ for all $v \in \mathbb{R}^n$ where $df$ denotes the differential of $f$.
If we let $\langle \cdot \rangle$ be the standar scalar product, then $grad f(x) = J_f(x)$ where $J_f(x)$ denotes the Jacobian.
Now my question is the following: I can follow all the steps in the proof, but I cannot understand the conclusion. Why does it follow that $grad f(x)$ is perpendicular to the level set $N_y$ for any $x$ and any $y$? What does it even mean to be perpendicular to a set? Does it mean perpendicular to any vector in that set?
The notes also give an example:
For $f(x)=\|x\|^2$ each vector $grad f(x)=(2x_1,...,2x_n)^T$ is perpendicular to the sphere
$N_{\|x\|^2}=\{p \in \mathbb{R}^n : \|p\|^2 = \|x\|^2 \}$.
I have tried the following to see if my interpretation of perpendicular to a set is correct:
Let $x=(1,...,1)^T$, then $\|x\|^2=n$. Now consider a vector $y$ in $N_{\|x\|^2}$, say $y=(\sqrt{n},0,...0)^T$, then $\|y\|^2=n$ (x and y have the same length). But $\langle x,y \rangle = \sqrt{n} \neq 0$. So $x$ and $y$ are not perpendicular. So I think my interpretation of perpendicularity to a set must be wrong.
Please tell me what I am missing here. How does the conclusion follow and how to interpret it? I know there are a lot of questions on this topic, but none of them could clarify this point in a satisfactory way for me.
Thank you very much!
Edit:
Maybe I should add another thought. The proof shows that $grad f(c(t)$ is perpendicular to $c'(t)$ which is the tangent vector of $c$ at $t$. So we need to show that the tangent vector points in the same direction as the vectors in the level set.