Creating the required matrices
Now that we have expanded the equations, we can look at how each of the expanded terms relates to a portion of the final matrix.
Equation A. 3 does not need expansion. We can create our first matrix Mv from equation A. 3:
Here, we can use C to control the effect of the value of each item if needed.
We will represent the next matrix Myc from equation A. 10 as follows:
Note that basically, this matrix has -1 on the diagonal terms and 2 on the upper right. This matrix implements the constraint that there is only one weight in the solution. We will use the multiplier A to control the effect of this matrix, which will be to penalize any solutions with more than one weight and ensure the constraint is being applied. The constant A in equation A. 10 is going to be ignored since it cannot be implemented in the matrix and becomes an offset to add to the final energy value.
The next three matrices...