Consider the problem for some vectors $v, m \in \mathbb{R}^n:$
$$f(v) = (v^T m)^2$$ w.r.t $\|v\|^2 =1$
I want to maximize $f$
If I consider the lagrangian, I get:
$$L(v)=(v^T m)^2 + \lambda(1 - \|v\|^2)$$
Taking derivative, I get: $2 mm^Tv - \lambda2 v =0 $ Therefore $mm^Tv = \lambda v (*)$
Multiplying by v^T from left, I end up with $$(v^Tm)^2 = \lambda $$
If I put that in(*), I do cannot simplfy that.
Is there a trick I can apply?
You do not need much optimization here. Just note that $(v^Tm)^2=v^Tmm^Tv$ and that $mm^T$ is symmetric positive semidefinite with rank 1. The only nonnezero eigenvalue is given by $m^Tm$. Therefore, we have that
$$0\le v^Tmm^Tv\le m^Tm$$ for all $v\in\mathbb{R}^n$. The maximum is attained for $v=m/||m||$ which is normalized eigenvector associated with the unique positive eigenvalue. Note that it is also attained for $v=-m/||m||$.
The difficulty here with using Lagrange multipliers is that $mm^T$ is not invertible and one has to restrict $v$ to the subspace where $mm^Tv\ne0$. That is you can solve for the problem where $v=\alpha m$ and pick $\alpha$ such that the norm of $v$ is one.