Given the function
$$
E(M) = \sum\_{i=1}^N \sum\_{a=1}^K \left( M\_{ia} \cdot \left\lVert\sum\_{i=1}^N M\_{ia}\cdot x\_i\right\rVert\_2^2 \right)
$$
$x$ is a given constant matrix, $x\_i$ is a the $n\_\text{th}$ column of that.
$M\_{ia} \in \{0,1\}$ and $\sum\_{i=1}^N M\_{ia}=\frac{N}{K} $, and we also have $\sum\_{a=1}^N M\_{ia}=1 \\\\$.


The question is, can $E$ of $M$ be further simplified to a form using only quadratic and linear terms of $M$?


Again, thank you so much.



Can this function be simplified to use only quadratic, linear terms of M with given conditions?
Yes, $$E(M) = \frac{N}{K} \lVert X M \rVert\_F^2$$
writing $X$ for the matrix $\begin{bmatrix} x\_1 & \dots & x\_N \end{bmatrix}$.
Note $\sum\_{i=1}^N M\_{ia}x\_i = X M e\_a$ where $e\_a$ is the $a$th standard basis vector. The constraints imply $M$ is a binary $N \times K$ matrix with a single nonzero per row and each column having the same number $m = N/K$ of nonzeros. Let the single nonzero in row $i$ be in column $j\_i$. Only the term with $a=j\_i$ is nonzero in the sum over $a$ so that $E(M) = \sum\_{i=1}^N \lVert X M e\_{j\_i} \rVert\_2^2$. Finally note that each column index $j$ will be visited exactly $m$ times in the sum over $i$, so that $E(M) = m \sum\_{j=1}^K \lVert X M e\_j \rVert\_2^2 = m \lVert X M \rVert\_F^2$.


