# Condition number calculation in R

If I understood correctly, the condition number should be a product of Frobenious norms of a matrix and its inverse.

In R if I do the following:

m = matrix(0, nrow=3, ncol=3)
m[col(m) == row(m)] = c(5,3,1)
minv = solve(m)

norm(m, type='F') * norm(minv, type='F')

kappa(m, exact=TRUE, norm='2' )


I get different numbers, can somebody please explain to me why this is so?

• Although asked in the context of R, the nature of the condition number is a statistical question. This should be on topic here. Commented Oct 19, 2016 at 14:05
• Dear gung, Would you be so kind to transfer to the appropriate stack, or answer the question. Best regards. Commented Oct 19, 2016 at 14:09
• Someone voted to close. I'm saying it needn't be closed. Commented Oct 19, 2016 at 14:10

Compare:

norm(m, type='F')

With:

norm(m, type='2')

At first I thought (as you probably did) that with the 2-norm they meant the 2-norm when considering the matrix as a vector. However I found it odd that they used 2 notations in different places ('F' for Frobenius and '2' for 2-norm). Then I saw that the norm function has both as options (see: ?norm). That led me through some googling to the following wikipedia page:
https://en.wikipedia.org/wiki/Matrix_norm#Induced_norm
Here they explain the 2-norm they use on matrices in R.

TL;DR: Frobenius norm isn't the 2-norm on matrices.

• Indeed, the Frobenius norm is the square root of the sum of squares of all of the elements of an $n\times m$ matrix, i.e., it is from a two dimensional object and an $\mathcal{l}^2$ norm is from a single column vector. The two differently defined norms are both called the same things, e.g., Euclidean or vector norms, which one should only know in order to avoid calling either one by those confusing names.
– Carl
Commented Mar 22 at 0:45