# How to cast a $2 \times 2$ problem in the standard quadratic programing form?

Let $$C$$ a positive definite matrix, $$\beta$$ and $$\epsilon$$ constant parameters, $$\alpha$$, $$\eta$$, decision variables.

$$J = \textrm{Tr}\left(\begin{bmatrix}\alpha & -2\beta\eta \\ \alpha & (1 - 2\beta \eta)\end{bmatrix}'C \begin{bmatrix}\alpha & -2\beta\eta \\ \alpha & (1 - 2\beta \eta)\end{bmatrix} + \begin{bmatrix}\eta \\ \eta\end{bmatrix}\epsilon^2\begin{bmatrix}\eta & \eta\end{bmatrix} \right)$$

I know $$J\ge0$$ because the trace of the sum of two quadratic forms, how to find the optimal solution?

I was expecting to be able to cast this problem to the standard form

$$\begin{bmatrix}\alpha \\ \eta \end{bmatrix}' A \begin{bmatrix}\alpha \\ \eta \end{bmatrix} + b \begin{bmatrix}\alpha \\ \eta \end{bmatrix} + c$$

## Edit:

I was asked in the comments for what I can get with a CAS. Evaluating $$J$$ then extracting the coefficients I can get a solution:

$$\displaystyle \left[\begin{matrix}\alpha\\\eta\end{matrix}\right]^{T} \left[\begin{matrix}2 {c}_{0,0} & - 4 \beta {c}_{0,1}\\- 4 \beta {c}_{0,1} & 2 \left(4 \beta^{2} {c}_{1,1} + \epsilon^{2}\right)\end{matrix}\right] \left[\begin{matrix}\alpha\\\eta\end{matrix}\right] + \left[\begin{matrix}2 {c}_{0,1} & - 4 \beta {c}_{1,1}\end{matrix}\right] \left[\begin{matrix}\alpha\\\eta\end{matrix}\right] + \left[\begin{matrix}{c}_{1,1}\end{matrix}\right]$$

But I wanted to see if someone could point something less tedious

• I tried sympy, what would you suggest?
– Bob
Sep 29, 2022 at 9:24
• I usually use SymPy. You can append your SymPy code and show what SymPy did output. Sep 29, 2022 at 9:27