In this article, there's something saying:
The gradient is everywhere perpendicular to the contour lines of a function
It justifies it by saying:
Since along contour lines the change in height is zero, this means the directional derivative along the contour is zero
But what is exactly a directional derivative along a contour? I only know about directional derivatives in directions of vectors.
I'm asking this because I'm studying Lagrange multipliers, and my book justifies it geometrically only. It seeks to find the max or min of a function $f$ with the restriction on the domain $\{(x,y) | g(x,y) = 0\}$ It says that when $(x_0,y_0)$ is a critical point (either max or min), it means that if we trace the contour lines near this point, we'll observe a contour line of $f$ that is 'tangent' to the restriction $g$. Here's the image:
I can't see why this is true geometrically, could somebody give me a reason? I want a proof but I also want to understand it geometrically.
My book then ends by saying that the gradients of $f$ and $g$ must be perpendicular. But I can't see this.

Say you have a smooth curve $\gamma(t)$. Then the directional derivative along the contour should be $$ (f\circ \gamma)'(t) = \frac{d}{dt} f(\gamma(t)) = \lim_{h\to 0} \frac{f(\gamma(t+h)) - f(\gamma(t))}h.$$
Proposition. For each $t$, $\frac{d}{dt} f(\gamma(t)) $ is equal to the directional derivative of $f$ at $\gamma(t)$ in the direction $\gamma'(t)$.
Proof. Let $t$ be fixed. Recall that the directional derivative of $f$ at $\gamma(t)$ in the direction $\gamma'(t)$ is $$ (D_{\gamma'(t)}f)(\gamma(t)) = \lim_{h\to 0} \frac{f(\gamma(t)+ \gamma'(t)h) - f(\gamma(t))}h = \gamma'(t)\cdot (\nabla f)(\gamma(t)). $$ But by the multivariate chain rule, this is precisely $$(f\circ \gamma)'(t)= \nabla f(\gamma(t))\cdot \gamma'(t) $$ hence the result. $\square$
The claim
then follows: on a contour line, $f\circ \gamma$ is constant. Thus for any $t,h$, $$ f(\gamma(t+h)) - f(\gamma(t)) \equiv 0.$$ Thus $$ \lim_{h\to 0} \frac{f(\gamma(t+h)) - f(\gamma(t))}h = 0.$$ By the proposition: $$ \nabla f(\gamma(t))\cdot \gamma'(t) = 0$$ which is to say that $\nabla f(\gamma(t))$ is perpendicular to the tangent vector $\gamma'(t)$ of the contour, which is the claim.
(In $n>1$ dimensions, you would do this for $n$ curves whose tangent vectors form a basis of the tangent space.)