Solution (source code)

= Solution

Write $\Phi\alpha=\sum_i\alpha_i\phi(X_i)$. By the definition of the <kernel matrix>,
$$
\lVert\Phi\alpha\rVert_{\mathcal H}^2=\alpha^TK\alpha
$$
and
$$
\frac1n\sum_{j=1}^n
\langle\Phi\alpha,\phi(X_j)\rangle_{\mathcal H}^2
=\frac1n\alpha^TK^2\alpha.
$$
The irrelevant positive factor $1/n$ gives exactly the stated constrained optimization.

Let $Kv_1=\lambda_1v_1$, where $\lambda_1>0$ is the largest <eigenvalue> and $\lVert v_1\rVert_2=1$. The generalized <Rayleigh quotient> is maximized by
$$
\widehat\alpha=\frac{v_1}{\sqrt{\lambda_1}},
$$
up to sign and addition of a vector in $\ker K$, which does not change $\widehat u=\Phi\widehat\alpha$. Repeated leading eigenvectors give further principal directions.