3
$\begingroup$

While implementing in Matlab the Frobenius norm of a matrix

$$\| A\|_{\text F} := \sqrt{ \sum_{i=1}^m \sum_{j=1}^n a_{ij}^2 },$$

a problem arises when numbers are too big or too small:

  • If a number in the matrix is too big (but within bounds of Matlab), taking its square will result in “infinity”. Adding anything else to it and taking the root will also result in infinity. However, the norm may actually be much smaller, since the root is taken at the end.

  • Similarly, if all numbers in the matrix are sufficiently small, their squares and, thus, the norm will return $0$, while in reality it may be big enough to be represented by Matlab, since the root is taken.

How would we go about dealing with cases like this in the implementation of the function? I am aware that norm(A,'fro') exists in Matlab, but we have been asked to deal with this problem ourselves, and I’m baffled.

$\endgroup$
  • $\begingroup$ Are you interested in the case where a matrix has entries that are too big and also entries that are too small? $\endgroup$ – Rodrigo de Azevedo Oct 16 '17 at 8:09
3
$\begingroup$

You can scale your matrix by, say, the inverse of the largest/smallest(nonzero) entry before you compute the norm and use that $\|aM\|=|a|\|M\|$.

And have a look into Higham's book Accuracy and Stability of Numerical Algorithms to understand how these scalings have an effect on the accuracy.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.