How to calculate Frobenius norm efficiently? Let's say matrix $X$ with shape $(m,n)$, the Frobenius norm of $X$ is defined as
$||X||_F=\sqrt{\mathrm{Tr}(XX^T)}=\sqrt{\mathrm{Tr}(X^TX)}=\sqrt{\sum_i\sum_j a_{ij}^2}$
Since $XX^T$ needs $m^2n$ times multiplication, and $X^TX$ needs $n^2m$ times.
So if $m>n$, compute $X^TX$ is faster, but if $m<n$, compute $XX^T$ is faster.
By the way, sum of all the squared elements, then compute the square root could also to do this.
I wonder if there is a more efficient way to compute $||X||_F$ ?

Why you don't think just square every components?

Then we have to calculate $ 2nm $ times only.


$ mn $ : Square every components.

$ mn-1 $ : Add the answer above.

$1$ : Find the square root of above answer.
