# Normalizing a matrix

I came across a step in an numerical algebra algorithm that says "Normalize the rows of matrix A such that they are unit-norm. Call U the normalized matrix."

I do something like this:

for i=1:no_of_rows
U(i,:)= A(i,:)./ norm(A(i,:))
end


My question is what norm should I use? Will $2$ norm as below : $$\|X\|_2=\sqrt{\sum_{k=1}^n|x_k|^2}$$ work here? Do I need to satisfy UU*=I ?

-

Most likely, they mean the Euclidean $2$ norm you mention. But the procedure makes sense for any norm on the row space.

The resulting matrix needs not be unitary if the size of the matrix is $\geq 2$, i.e. you don't get $UU^*=I$ in general. Just start with the matrix whose coefficients are all equal to $35$, for instance. But that's ok. "Normalizing" the rows does not even require to make the matrix "normal", a fortiori not unitary.

-
Isn't the row sum norm more natural here ? – Dominic Michaelis Apr 1 '13 at 11:41

Generally speaking, when the norm is not specified, the Euclidean norm is assumed, yes.

Note that if you are using Matlab, the bsxfun function can eliminate the for loop, which is always good:

U = bsxfun( @rdivide, A, sqrt(sum(abs(A).^2,2)) );


This does not necessarily result in a matrix that satisfies $UU^*=I$. But that is not being requested in the quoted statement.

-

The more natural choice wuold be the row sum norm in my opinion. Because you scale the matrices to get a better condition, so you have to scale it with the norm of the matrix, here you need to know which one you are having. then the algorithm in Mathematica Syntax would be this one:

scale[m_]:=
DiagonalMatrix[
Table[
(1/Sum[
Abs[
m[[pinguin,affe]]
],{affe,1,Dimensions[m][[1]]}
]),{pinguin,1,Dimensions[m][[2]]}]
].m


This algorithm is more for intuition then for efficiency, I just multiply the rows of the matrix with the inverse of the row norms.

As for a unitary matrix you need that the norm induced by the hermitian scalar product is $1$ (and even much more) you will get unitary matrices only by coincidence.

-
@julien The Row sum norm for matrices is for a matrix $\in \mathbb{K}^{m \times n}$ $$\max_{i} \sum_{k=1}^n |a_{ik}|$$ so it's NOT the euclidean norm, so the $\|\cdot\|_1$ norm would be the more natural choice for scaling – Dominic Michaelis Apr 1 '13 at 12:00
Ah, I see, that's what you meant. It is not more natural. It depends on the purpose, the context, etc... If I'm free to choose a norm, I will always pick a Euclidean one. – 1015 Apr 1 '13 at 12:01

Let's $X_j$ the $j$-row of matrix $X$. Then $$XX^\ast=(X_{ij})_{n\times n}(X_{ij})_{n\times n}^\ast=(\langle X_j X_j\rangle)_{n\times n}$$ Note that \begin{align} \| (X_{ij})_{n\times n} \|_F = & \sqrt[2\,]{\mbox{trace}\left[ (X_{ij})_{n\times n} (X_{ij})_{n\times n}^\ast\right]} \\ = & \sqrt[2\,]{\mbox{trace}\left[ (X_{ij})_{n\times n} (\overline{X_{ij}})_{n\times n}\right]} \\ = & \sqrt[2\,]{\mbox{trace}\left[ \left(\sum_{k=1}^nX_{ik}\cdot \overline{X_{ik}}\right)_{n\times n}\,\right]} \\ = & \sqrt[2\,]{\sum_{i=1}^n\sum_{k=1}^nX_{ik}\cdot \overline{X_{ik}}} \\ = & \sqrt[2\,]{\sum_{i=1}^n\sum_{k=1}^n |X_{ik}|^2} \\ = & \sqrt[2\,]{\sum_{i=1}^n\langle X_i,X_i\rangle} \\ = & \sqrt[2\,]{\sum_{i=1}^n\| X_i\|^2} \end{align} Then $XX^\ast=I$ implies $\| X_i\|=1$ for all $i=1,\ldots, n$. But, the reciprocal not true. This is true if, only if, the rows of $X$ is a orthonormal basis of $\mathbb{R}^n$.

-