2

How can I represent this in a matrix form:

$\sum_{ijl}(F_{il}-F_{jl})^2W_{ij}$

where all the entries are real and $W$ is a known(constant) matrix and $F$ is a rectangular matrix. When I say matrix form, the matrix trace function can be used as well as part of the simplification. Essentially, the index $l$ is choosing a column in $F$ and then the summation is being done and so-forth.

user75402
  • 315

3 Answers3

1

Let $E$ be a matrix with the same size as $F$, and with all elements $E_{jl}=1$.

Then there are several different ways to write the expression using the Hadamard ($A\!\circ\!B$), Matrix ($AB$), and Frobenius ($A\!:\!B$) products. $$\eqalign{ S &= (F\circ F):WE + (F\circ F):W^TE - 2\,FF^T:W \cr &= (F\circ F):(W+W^T)E - 2\,FF^T:W \cr &= (\,(F\circ F)E^T-FF^T):(W+W^T) \cr &= (\,(F\circ F)E^T-FF^T):K \cr }$$ where $K = W+W^T$

We can also find the differential of that final expression as $$\eqalign{ dS &= (\,(dF\circ F)E^T+(F\circ dF)E^T-dFF^T-FdF^T):K \cr &= 2\,(dF\circ F):KE-2\,dF:KF \cr &= 2\,dF:F\circ(KE)-2\,dF:KF \cr &= (2\,F\circ(KE)-2\,KF):dF \cr }$$ And since $dS=\frac{\partial S}{\partial F}:dF\,\,$ the derivative must be $$\eqalign{ \frac{\partial S}{\partial F} &= 2\,F\circ(KE)-2\,KF \cr }$$

lynn
  • 1,746
1

Let $e_i$ denotes the $i$-th vector in the canonical basis and $u=\sum_ie_i=(1,1,\ldots,1)^\top$. Then your sum is equal to $$ u^\top \left[\left(\sum_i e_ie_i^\top FF^\top e_iu^\top + \sum_j ue_j^\top FF^\top e_je_j^\top - 2FF^\top\right) \circ W\right] u,\tag{1} $$ where the symbol "$\circ$" denotes a Hadamard product. Since $$ u^\top (A\circ B)u = \operatorname{trace}(B^\top A) = \operatorname{vec}(B)^\top\operatorname{vec}(A), $$ you may also express your sum as $$ \operatorname{trace}\left(W^\top \left(\sum_i e_ie_i^\top FF^\top e_iu^\top + \sum_j ue_j^\top FF^\top e_je_j^\top - 2FF^\top\right) \right)\tag{2} $$ or $$ \operatorname{vec}(W)^\top \left[\sum_i (ue_i^\top)\otimes(e_ie_i^\top) + \sum_j(e_je_j^\top)\otimes(ue_j^\top) - 2I\otimes I\right] \operatorname{vec}(FF^\top),\tag{3} $$ where "$\otimes$" denotes Kronecker product (tensor product). Either way, I think $\sum_{ijl}(F_{il}-F_{jl})^2W_{ij}$ is a much simpler expression.

user1551
  • 139,064
0

Consider a matrix with components given by $$D_{ij} = \sum_\ell (F_{i\ell}-F_{j\ell})^2$$ This is the Euclidean distance matrix for the rows of the matrix $F$ (or equivalently the columns of $F^T$). There are many different expressions for this matrix. My personal favorite is $$D = (F\odot F)J^T+J(F\odot F)^T - 2FF^T$$ where $J$ is the all-ones matrix the same size as $F$, and $\odot$ denotes the elementwise/Hadamard product.

So by choosing to sum over the $\ell$-index first, the current problem can be greatly simplified $$ \sum_{ij}W_{ij}\sum_{\ell}(F_{i\ell}-F_{j\ell})^2 = \sum_{ij} W_{ij} D_{ij} = {\rm Tr}(WD) $$


UPDATE

If the repeated $(i,j)$ indexes were not meant to imply summation (i.e the Einstein convention), then the expression in question is equal to the Hadamard product $(W\circ D)$ since $$ W_{ij}\sum_{\ell}(F_{i\ell}-F_{j\ell})^2 \;=\; W_{ij} D_{ij} \;=\; (W\circ D)_{ij} $$

greg
  • 35,825