I'm confused with the following problem when doing my research.
Given $g_i,i=1,2,..,n-1$ and $q_i,i=1,2,..,n$, find the minimum of: $$\sum_{i=1}^n a_i^2+\sum_{1\leq i<j\leq n}g_{j-i}a_i a_j+\sum_{i=1}^n q_i a_i$$
subject to $$\sum_{i=1}^{n} a_i=1,a_i \geq 0$$
If necessary, we can assume the sign of $g_i$ and $q_i$(such as $g_i<0,q_i>0$ for all i) and the value of $|g_i|$ and $|q_i|$ can be sufficiently small for all i. Is there a way to find the closed-form solution of $a_1,a_2,...,a_n$ when the target is minimized? Some approximate methods and some solutions with specific $q_i$ and $g_i$ are also of great help. I would be grateful if there is any hint.
*Please see the discussion under the actual question. There, a closed-form solution for the question without nonnegativity restrictions on the $\{a_i\}$ was asked for, which is given here. *
I would go with a Discrete Fourier Transformation. Let a matrix $U$ with $u_{ j k} =\exp (i (j-1) (k-1) 2 \pi / n)$, then $U^\dagger U = n I$ where $I$ is the identity matrix.
The given problem is to minimize, where $a$ and $q$ are vectors and $G$ is a matrix given by the problem definition $$ a^T G a + a^T q $$
Let vectors $b = U a$ and $r = U q$, and the matrix $H = \frac{1}{n} U G U^\dagger$. $G$ is of Toeplitz structure, so $H$ will not be diagonal (which would be the case for a circulant matrix $G$). Then equivalently minimize
$$ b^T H b + b^T r $$
Now since $b_1 = \sum_i a_i = 1$, this can be written explicitely
$$h_{11} + b_1 r_ 1+ \sum_{j=2}^n (h_{1 j} + h_{j 1} + r_j) b_j + \sum_{j, k=2}^n h_{j k } b_j b_k$$
and the condition $\sum_{i=1}^{n} a_i=1$ is already included. Now minimizing w.r.t. the $b_j$ gives $n-1$ linear equations (where $j = 2 \dots n$)
$$ (h_{1 j} + h_{j 1} + r_j) + \sum_{k=2}^n (h_{k j} + h_{j k}) b_k = 0 $$
Writing this in compact form, with $(n-1)$-dimensional vectors and an $(n-1)\times (n-1)$-dimensional matrix, where the first index is missing, denoted by bars $$ \bar c + \bar F \bar b = \bar 0$$ or
$$a = \frac1n U^\dagger \left(1 \atop \bar b \right) = \frac1n U^\dagger \left(1 \atop - {\bar F}^{-1} \bar c \right) $$
as a closed solution for an extremal point, where it has to be checked whether this is a minimum.