How to denote element-wise difference of two matrices Ok so this may seem like a basic question but I'm getting confused by the mathematical notation.
I am calculating the MSE (mean squared error) between two matrices. I know how to compute this, but do not know how to denote it.
For calculating the MSE, you have to subtract every element of matrix 2 from every element of matrix 1. It's how to denote "subtract element [i,j] of matrix 2 from element [i,j] of matrix 1" that I can't figure out ...
 A: Assume your matrices are called $A$ and $B$, then it is usual to notate their elements with $a_{ij}$ respectively $b_{ij}$. So you could denote the sum of the squared errors as
$$
\text{SSE} = \sum_{i,j} (a_{ij}-b_{ij})^2.
$$
You would get your MSE in the usual way, by taking the average. Does this answer your question? It sorts of seems to sample. You could also first define a new matrix $C$, via
$$c_{ij} = a_{ij}-b_{ij}$$
and work with that. As per the comment above, for the whole matrix you can also just write $$
C=A-B
$$
which works out elementwise as given above.
A: Standard notation for addition/subtraction of matrices refers to elementwise addition/subtraction, so with standard notation you have:
$$\mathbf{A}-\mathbf{B} = \begin{bmatrix} 
a_{11} - b_{11} & a_{12} - b_{12} & \cdots & a_{1m} - b_{1m} \\
a_{21} - b_{21} & a_{22} - b_{22} & \cdots & a_{2m} - b_{2m} \\
\vdots & \vdots & \ddots & \vdots \\
a_{n1} - b_{n1} & a_{n2} - b_{n2} & \cdots & a_{nm} - b_{nm} \\
\end{bmatrix}.$$
The quantity of interest to you (if I understand your description correctly) can be written in matrix form as:
$$\begin{align}
\text{SSE} 
&\equiv \sum_{i=1}^n \sum_{j=1}^m (a_{ij} - b_{ij})^2 \\[6pt]
&= \sum_{i=1}^n \sum_{j=1}^m ([\mathbf{A}-\mathbf{B}]_{ij} )^2 \\[6pt]
&= \sum_{i=1}^n \sum_{j=1}^m [\mathbf{A}-\mathbf{B}]_{ij} [\mathbf{A}-\mathbf{B}]_{ij} \\[6pt]
&= \sum_{i=1}^n \sum_{j=1}^m [(\mathbf{A}-\mathbf{B})^\text{T}]_{ji} [(\mathbf{A}-\mathbf{B})]_{ij} \\[6pt]
&= \sum_{j=1}^m \sum_{i=1}^n [(\mathbf{A}-\mathbf{B})^\text{T}]_{ji} [(\mathbf{A}-\mathbf{B})]_{ij} \\[6pt]
&= \sum_{j=1}^m [(\mathbf{A}-\mathbf{B})^\text{T} (\mathbf{A}-\mathbf{B})]_{jj} \\[10pt]
&= \text{tr}((\mathbf{A}-\mathbf{B})^\text{T} (\mathbf{A}-\mathbf{B})). \\[6pt]
\end{align}$$
