TITLE: Understanding the concept behind the Lagrangian multiplier
QUESTION [17 upvotes]: I've been trying to understand the principles behind the Lagrangian multipliers and I think I've got a rough understanding of it. Would appreciate it if you guys could help me answer a few questions!
I've pretty much self-studied this from here and here.
As far as I understand it, the Lagrangian multiplier essentially works by ensuring the gradient of the function is equal to the gradient of the restraint. Assuming that $g(x,y) = c$ is the restraint, it also ensures the point satisfies the restraint.
However, I don't understand the reasoning behind some of the statements in the ideashop link:
1) "The most important thing to know about gradients is that they always point in the direction of a function's steepest slope at a given point." . Apparently a gradient is a collection of partial first derivatives but I don't understand how one gets from a collection of partial first derivatives to 'Always pointing in the direction of the steepest slope'. Wouldn't it be changing direction as one went around a 3D surface?
2) Why is the gradient always perpendicular to the level curve?
3) How does one get from $$\nabla L=\begin{bmatrix}\frac{\partial f}{\partial x_1}-\lambda\frac{\partial g}{\partial x_1}\\\frac{\partial f}{\partial x_2}-\lambda\frac{\partial g}{\partial x_2}\\g(x_1,x_2)-c\end{bmatrix}=0$$ to $$L(x_1,x_2,\lambda)=f(x_1,x_2)-\lambda(g(x_1,x_2)-c)$$ (Both sourced from ideashop) ?
Thank you for your help in advance!

REPLY [6 votes]: I'll explain it in a three-dimensional setting. This means a priori you are given a "temperature" function $f:\,{\mathbb R}^3\to{\mathbb R}$. 
Consider a fixed point ${\bf p}\in{\mathbb R}^3$ and a  point $t\mapsto{\bf x}(t)$ $\ (t\geq0)$ moving away from ${\bf p}$ in direction ${\bf u}\,$; so ${\bf x}(0)={\bf p}$, $\,{\bf x}'(0)={\bf u}$. The temperature at the moving point is a function of $t$ and is given by $\phi(t):=f\bigl({\bf x}(t)\bigr)$. According to the chain rule we have
$$\phi'(0)=\nabla f\bigl({\bf x}(0)\bigr)\cdot{\bf x}'(0)=\nabla f({\bf p})\cdot{\bf u}\ .\qquad(1)$$
If $\nabla f({\bf p})\ne{\bf 0}$ then there will always be direction vectors ${\bf u}$ such that the scalar product on the right is positive and other such vectors where it is negative. In this case the temperature $f$ can neither be locally minimal nor locally maximal at ${\bf p}$. In particular, for $|{\bf u}|=1$ the increase $\phi'(0)$ is maximal ($=|\nabla f({\bf p})|$) if ${\bf u}$ points in the direction of $\nabla f({\bf p})$, the temperature remains stationary, i.e.,  $\phi'(0)=0$, for directions ${\bf u}\perp\nabla f({\bf p})$, and decreases fastest in the direction $-\nabla f({\bf p})$. 
When the moving point stays on the isothermal surface $S_f$ through ${\bf p}$ then $\phi'(0)=0$. Looking at $(1)$ we see that all "$f$-isothermal tangent directions" are orthogonal to $\nabla f({\bf p})$. This implies that $\nabla f({\bf p})$ spans the orthogonal complement of the tangent plane $T_{f,{\bf p}}$ of $S_f$.
Assume now that in addition to $f$ we have a constraint $g({\bf x})=0$ defining an  "admissible" surface $S_g\subset{\mathbb R}^3$, and assume that our point ${\bf p}$ satisfies the constraint. In this case only "$g$-isothermal tangent directions" ${\bf u}$ are allowed for the moving point. 
If ${\bf p}$ aspires to be a conditionally extremal point, whence a conditionally stationary point, of $f$ then we should have $\phi'(0)=0$ for all allowed directions. This means by $(1)$ that $\nabla f({\bf p})$ should be orthogonal to all "$g$-isothermal tangent directions", or that $\nabla f({\bf p})$ is in the orthogonal complement of the tangent plane $T_{g,{\bf p}}$. As the latter is spanned by $\nabla g({\bf p})$ (assumed $\ne{\bf 0}$) we would have an equality of the form $\nabla f({\bf p})=\lambda\, \nabla g({\bf p})$ for some $\lambda\in{\mathbb R}$. This in term implies that the point ${\bf p}$ will come to the fore when we solve the equations
$$\nabla f({\bf x})=\lambda\, \nabla g({\bf x}),\quad g({\bf x})=0\qquad(2)$$
for ${\bf x}$ (and $\lambda$).
Applying the "Lagrange method" means no more and no less than solving the equations $(2)$.