Lagrange multipliers are fine but you don't actually need that to get a decent intuitive picture of why eigenvectors maximize the variance (the projected lengths).
So we want to find the unit length $w$ such that $\|Aw\|$ is maximal, where $A$ is the centered data matrix and $\frac{A^TA}{n} = C$ is our covariance matrix.
Since squaring is monotonically increasing over non-negative real numbers, maximizing $\|Aw\|$ is equivalent to maximizing $\|Aw\|^2 = (Aw)^TAw = w^TA^TAw = n (w^TCw)$. And we can also ignore that $n$ since we're choosing the $w$ that maximizes that and $n$ is constant, so it won't affect which $w$ maximizes the expression.
But we don't actually need to enforce the unit length constraint with a Lagrange multiplier because we can turn any non-zero vector into a unit vector by dividing by its length. So, for any $w$ of non-zero length, the vector $\frac{w}{\|w\|}$ is always unit length.
So now we just need to maximize
$$
\frac{w^T}{\|w\|}C\frac{w}{\|w\|} = \frac{w^TCw}{\|w\|^2} = \left(\frac{1}{n}\right)\frac{\|Aw\|^2}{\|w\|^2}
$$
That last expression shows that this is equivalent to maximizing the ratio of the squared length of $Aw$ to the squared length of $w$, where we let $w$ be of any length. Instead of forcing $w$ to be unit-length and maximizing the numerator of that ratio (the denomitator will be 1 if $w$ is forced to be unit length), we can let $w$ be whatever length it wants and then maximize that ratio. As someone else pointed out, this ratio is called the Rayleigh Quotient.
As with lots of maximization problems, we need to find where the gradient vanishes (where the derivative is equal to zero). Before we do that with our particular multivariate case, let's derive something general about where derivatives equal zero for quotients in one dimension.
Consider the quotient $\frac{f(x)}{g(x)}$. The derivative with respect to x of this, using the product rule and chain rule (or "quotient" rule) from basic calc, we get:
$$
\frac{f'(x)}{g(x)} - \frac{f(x)g'(x)}{g(x)^2}
$$
If we set this equal to zero (to find maxima and minima) and then rearrange a bit, we get
$$
\frac{f'(x)}{g'(x)} = \frac{f(x)}{g(x)}
$$
So when the ratio of the rates of change equals the ratio of the current values, the derivative is zero and you're at a minimum or maximum.
Which actually makes a lot of sense when you think about it. Think informally about small changes in $f$ and $g$ that happen when you take a small step in $x$, then you'll go
$$
\frac{f(x)}{g(x)} \xrightarrow{\text{small step in x}} \frac{f(x) + \Delta f}{g(x) + \Delta g}
$$
Since we're interested in the case where there's no net change, we want to know when
$$
\frac{f(x)}{g(x)} \approx \frac{f(x) + \Delta f}{g(x) + \Delta g}
$$
$\approx$ because this is all informal with finite small changes instead of limits. The above is satisfied when
$$
\frac{\Delta f}{\Delta g} \approx \frac{f(x)}{g(x)}
$$
If you currently have 100 oranges and 20 apples, you have 5 oranges per apple. Now you're going to add some oranges and apples. In what case will the ratio (quotient) of oranges to apples be preserved? It would be preserved when, say, you added 5 oranges and 1 apple because $\frac{100}{20} = \frac{105}{21}$. When you went from (100, 20) to (105, 21), the ratio didn't change because the ratio of the changes in quantity was equal to the ratio of the current quantities.
What we'll use is (after one more rearrangement), now using formal symbols again, the following condition:
$$
f'(x) = \frac{f(x)}{g(x)}g'(x)
$$
"The instantaneous rate of change in the numerator must be equal to the rate of change in the denominator scaled by the ratio of the current values".
In our multivariate case, we want the whole gradient to be zero. That is, we want every partial derivative to be zero. Let's give a name to our numerator:
$$
f(w) = \|Aw\|^2
$$
$f$ is a multivariate function. It's a function from a vector $w$ to a scalar, $\|Aw\|^2$.
Let's make $A$ and $w$ explicit to illustrate.
$$
A = \begin{bmatrix}
a & e & i \\
b & f & j \\
c & g & k \\
d & h & l \\
\end{bmatrix}
$$
and
$$
w = \begin{bmatrix}
x \\
y \\
z \\
\end{bmatrix}
$$
If you write out $\|Aw\|^2$ explicitly and take the partial derivative with respect to $y$ for instance (notated as $f_y$), you will get
$$
\begin{align}
f_y & = \frac{d}{dy}(\|Aw\|^2) \\
& = \frac{d}{dy}((ax + ey + iz)^2 + (bx + fy + jz)^2 + \dots) \\
& = 2e(ax + ey + iz) + 2f(bx + fy + jz) + \dots \\
& = 2\left<\begin{bmatrix}e & f & g & h\end{bmatrix}, Aw\right>
\end{align}
$$
So that's 2 times the inner product of the 2nd column of $A$ (corresponding to $y$ being in the 2nd row of $w$) with the vector $Aw$. This makes sense because, e.g., if the 2nd column is pointing in the same direction as $Aw$'s current position, you'll increase its squared length the most. If it's orthogonal, your rate will be 0 because you'll be (instantaneously) rotating $Aw$ instead of moving forward.
And let's give a name to the denominator in our quotient: $g(w) = \|w\|^2$. It's easier to get
$$
g_y = 2y
$$
And we know what condition we want on each of our partial derivatives simulatenously to have the gradient vector equal to the zero vector. In the case of the partial w.r.t. $y$, that will become
$$
f_y = \frac{f(w)}{g(w)}g_y
$$
Keep in mind every term there is a scalar. Plugging in $f_y$ and $g_y$, we get the condition:
$$
2\left<\begin{bmatrix}e & f & g & h\end{bmatrix}, Aw\right> = \frac{\|Aw\|^2}{\|w\|^2} 2y
$$
If we go ahead and derive partial derivatives $f_x$ and $f_z$ too, and arrange them into a column vector, the gradient, we get
$$
\nabla f =
\begin{bmatrix}
f_x \\
f_y \\
f_z
\end{bmatrix} =
\begin{bmatrix}
2\left<\begin{bmatrix}a & b & c & d\end{bmatrix}, Aw\right> \\
2\left<\begin{bmatrix}e & f & g & h\end{bmatrix}, Aw\right> \\
2\left<\begin{bmatrix}i & j & k & l\end{bmatrix}, Aw\right>
\end{bmatrix} =
2A^TAw
$$
The three partial derivatives of $f$ turn out to be equal to something we can write as a matrix product, $2A^TAw$.
Doing the same for $g$, we get
$$
\nabla g = 2w
$$
Now we just need to simultaneously plug in our quotient derivative condition for all three partial derivatives, producting three simultaneous equations:
$$
2A^TAw = \frac{\|Aw\|^2}{\|w\|^2} 2w
$$
Cancelling the 2's, subbing in $C$ for $A^TA$ and letting the $n$'s cancel, we get
$$
Cw = \left(\frac{w^TCw}{w^Tw}\right)w
$$
So the 3 simultaneous conditions we got from our derivative of ratios thing, one for each of the 3 partial derivatives of the expression (one for each component of $w$), produces a condition on the whole of $w$, namely that it's an eigenvector of $C$. We have a fixed ratio (the eigenvalue) scaling each partial derivative of $g$ (each component of an eigenvector) by the same amount, producing the partials of $f$ (the components of the output of the linear transformation done by $C$).
optimization problem
Yes PCA problem could be solved via (iterative, convergent) optimization approaches, I believe. But since it has closed form solution via maths why not use that simpler, efficient solution? $\endgroup$provide an intuitive explanation
. I wonder why intuitive and clear answer by amoeba, where I've linked to, won't suit you. You ask_why_ eigenvectors come out to be the principal components...
Why? By definition! Eigenvectors are the principal directions of a data cloud. $\endgroup$