The aim is the optimization either by maximizing total return (or minimizing risk), in keeping with the constraints of normalization for a given risk (or return).
Thus Lagrange method is perfectly suited for the job.
For minimizing risk, respect to a desired total return , one must consider the function of total risk
and minimize the lagrangian with constrain over the desired return and sum to one of weights.
Thus, provided that the constraints have non-zero derivatives,
by the fact that
is a non--degenerate constant vector (otherwise fixing the Total Risk is given), the Lagrangian is given by
the vector of lagrange multipliers.
Thus the minimization (maximization) is given by finding the extremant of the Lagrangian,
That is solved by considering the following linear system, that considering a symmetric covariance matrix is given by
in the definition of the matrix are linear vectors of equal dimension.
Finally considering the Hessian for operator to find the convexity.
Analogously could be done for a maximum return portfolio or relaxing the attribute for the desired best compromise.