I would like your help to rewrite the quadratic function below in matrix form. Could you help me to understand which is the best approach to take? Is there any method to go with or I should go "brute force" and keep trying till I find the correct representation?
The unknown vector is $x$ with size $225\times 1$.
$x_i$ denotes the $ith$ component of $x$.
$\{a_k,b_k\}_{k=1}^6$ are known parameters.
Here is my objective function
$$ f(x)\equiv \Big[a_1 - (x_{11}-x_{24}-x_{206})*b_1\Big]^2+ \Big[a_2 - (x_{27}-x_{39}-x_{207})*b_2\Big]^2 + \Big[a_3 - (x_{43}-x_{54}-x_{208})*b_3\Big]^2 + \Big[a_4 - (x_{107}-x_{114}-x_{212})*b_4\Big]^2 + \Big[a_5 - (x_{123}-x_{129}-x_{213})*b_5\Big]^2 + \Big[a_6- (x_{139}-x_{144}-x_{214})*b_6\Big]^2 $$
Here is the form I would like to get $$ Q+\frac{1}{2}x^{T}H x+2R^{T}x $$ where $H$ is a $225\times 225$ matrix.
Any suggestion? Let me clarify: my issue is that I have no idea on how I should construct $H$ (i.e., which elements of $H$ are non-zero and how I should fill them).
Let me clarify one point (kindly noticed in a comment below): you may wonder why, if only $18$ components of $x$ are involved, $x$ is not defined as an $18\times 1$ vector; the reason is that the remaining components of $x$ are involved in the constraints (which have been omitted here) of an optimisation problem where $f$ is the objective function.
Consider the matrix $P\in{\mathbb R}^{6\times 225}\,\,$ whose elements $P_{ij}$ are
$\,\,+1\,$ when $\,(i,j) = (1,24), (1,206), (2,39), (2,207),\,$ etc.
$\,\,-1\,$ when $\,(i,j) = (1,11), (2,27), (3,43),\,$ etc.
$\,\,\,\,\,\,\,0\,$ otherwise
From this, construct the matrix $B={\rm Diag}(b)P,\,$ i.e. with components $$B_{ij} = b_i P_{ij}$$
Now the objective function can be written $$\eqalign{ f &= (a+Bx)^T(a+Bx) \cr &= a^Ta + 2a^TBx + x^TB^TBx \cr }$$ from which you can identify the quantities $$\eqalign{ Q=a^Ta,\,\,\,\,\,R=B^Ta,\,\,\,\,\,\,H=2B^TB \cr }$$