Maximize sum of N variables squared subject to constraint I have the following problem.
Maximize ${\sum_{x=0}^N \beta_{1,x}v_x + \beta_{2,x}v_x^2}$ subject to $\sum_{x=0}^N v_x = X$ wrt $v_x$.
I am thinking about both Lagrange multipliers and quadratic programming. 
For QP, I am stuck because the $Q$ matrix is not semi-positive definite, so it seems unfeasible. 
For the Lagrange multipliers, I would end up with a bunch of equations $\beta_{1,x} + 2\beta_{2,x}v_x = \lambda$ for all $x$. Solving this seems like a pain.
Any suggestions? Thanks.
 A: Setting the variation of the expression to $0$ gives
$$
\begin{align}
0
&=\delta\sum_{k=0}^n\left(\beta_{1,k}v_k+\beta_{2,k}v_k^2\right)\\
&=\sum_{k=0}^n\left(\beta_{1,k}+2\beta_{2,k}v_k\right)\delta v_k\tag{1}
\end{align}
$$
The variation of the constraint is
$$
\begin{align}
0
&=\delta\sum_{k=0}^nv_k\\
&=\sum_{k=0}^n\delta v_k\tag{2}
\end{align}
$$
To satisfy $(1)$ for every $\delta v_k$ that satisfies $(2)$, we must have some constant $\lambda$ so that
$$
\lambda=\beta_{1,k}+2\beta_{2,k}v_k\tag{3}
$$
The constraint and $(3)$ allow us to compute $\lambda$ from
$$
\lambda\sum_{k=0}^n\frac1{\beta_{2,k}}=\sum_{k=0}^n\frac{\beta_{1,k}}{\beta_{2,k}}+2X\tag{4}
$$
Then, the expression is
$$
\begin{align}
\sum_{k=0}^n\left(\beta_{1,k}v_k+\beta_{2,k}v_k^2\right)
&=\frac12\sum_{k=0}^n\beta_{1,k}v_k+\frac12\sum_{k=0}^n\left(\beta_{1,k}+2\beta_{2,k}v_k\right)v_k\\
&=\frac14\sum_{k=0}^n\frac{\beta_{1,k}}{\beta_{2,k}}(\lambda-\beta_{1,k})+\frac12\sum_{k=0}^n\lambda v_k\\
&=\frac\lambda4\sum_{k=0}^n\frac{\beta_{1,k}}{\beta_{2,k}}-\frac14\sum_{k=0}^n\frac{\beta_{1,k}^2}{\beta_{2,k}}+\frac\lambda2X\\
&=\frac\lambda4\left(2X+\sum_{k=0}^n\frac{\beta_{1,k}}{\beta_{2,k}}\right)-\frac14\sum_{k=0}^n\frac{\beta_{1,k}^2}{\beta_{2,k}}\\
&=\frac{\left(2X+\sum\limits_{k=0}^n\frac{\beta_{1,k}}{\beta_{2,k}}\right)^2}{4\sum\limits_{k=0}^n\frac1{\beta_{2,k}}}-\frac14\sum_{k=0}^n\frac{\beta_{1,k}^2}{\beta_{2,k}}\tag{5}
\end{align}
$$
Formula $(5)$ tells the value of the expression at the only interior critical point. We can determine the $v_k$ that give this value by computing $\lambda$ using $(4)$ and plugging that into $(3)$.  If these are out of range (i.e. negative) or the critical point is a minimum, then we need to check boundary cases.
Here the boundary cases can be tested by simply leaving out a subset of the $b_{1,k}$ and $b_{2,k}$ and seeing if we get a solution that gives all the other $v_k\ge0$. Arduous, but a finite task.
