08.02.2015 Views

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Sage</strong> <strong>Reference</strong> <strong>Manual</strong>: <strong>Matrices</strong> <strong>and</strong> <strong>Spaces</strong> <strong>of</strong> <strong>Matrices</strong>, Release 6.1.1<br />

[ 3.0 4.0 5.0]<br />

sage: A.norm()<br />

doctest:...: DeprecationWarning: The default norm will be changing from p=’frob’ to p=2.<br />

See http://trac.sagemath.org/13643 for details.<br />

8.30662386...<br />

sage: A.norm(p=’frob’)<br />

8.30662386...<br />

sage: A.norm(p=Infinity)<br />

12.0<br />

sage: A.norm(p=-Infinity)<br />

3.0<br />

sage: A.norm(p=1)<br />

8.0<br />

sage: A.norm(p=-1)<br />

6.0<br />

sage: A.norm(p=2)<br />

7.99575670...<br />

sage: A.norm(p=-2) < 10^-15<br />

True<br />

Us<br />

And over the complex numbers.<br />

sage: B = matrix(CDF, 2, [[1+I, 2+3*I],[3+4*I,3*I]]); B<br />

[1.0 + 1.0*I 2.0 + 3.0*I]<br />

[3.0 + 4.0*I 3.0*I]<br />

sage: B.norm()<br />

7.0<br />

sage: B.norm(p=’frob’)<br />

7.0<br />

sage: B.norm(p=Infinity)<br />

8.0<br />

sage: B.norm(p=-Infinity)<br />

5.01976483...<br />

sage: B.norm(p=1)<br />

6.60555127...<br />

sage: B.norm(p=-1)<br />

6.41421356...<br />

sage: B.norm(p=2)<br />

6.66189877...<br />

sage: B.norm(p=-2)<br />

2.14921023...<br />

Since it is invariant under unitary multiplication, the Frobenius norm is equal to the square root <strong>of</strong> the sum<br />

<strong>of</strong> squares <strong>of</strong> the singular values.<br />

sage: A = matrix(RDF, 5, range(1,26))<br />

sage: f = A.norm(p=’frob’)<br />

sage: U, S, V = A.SVD()<br />

sage: s = sqrt(sum([S[i,i]^2 for i in range(5)]))<br />

sage: abs(f-s) < 1.0e-12<br />

True<br />

Return values are in RDF .<br />

sage: A = matrix(CDF, 2, range(4))<br />

sage: A.norm() in RDF<br />

True<br />

Improper values <strong>of</strong> p are caught.<br />

379

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!