Book Image

Sage Beginner's Guide

By : Craig Finch
1 (1)
Book Image

Sage Beginner's Guide

1 (1)
By: Craig Finch

Overview of this book

Table of Contents (17 chapters)
Sage Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – computing the singular value decomposition


The singular value decomposition, or SVD, has numerous applications in statistics, signal processing, and numerical analysis. An m x n matrix A is decomposed into three matrices: an m x m unitary matrix U, an m x n diagonal matrix sigma, and an n x n real unitary matrix V. These matrices satisfy the relation:

Here, V* denotes the transpose of the complex conjugate of V.

It's also easy to compute the SVD with Sage:

A = Matrix(RDF, [[1,1], [1,1], [0,0]])
print("Matrix A:")
show(A)
    
print "SVD:"
U, Sigma, V = A.SVD()
print("U:")
show(U)
print("Sigma:")
show(Sigma)
print("V:")
show(V)
print("U.Sigma.V* recovers A:")
show(U*Sigma*(V.conjugate().transpose()))

The result should look like this:

What just happened?

As in the previous example, we defined a 4 by 3 matrix called A over the field called RDF. The SVD method returns a tuple containing the matrices U, Sigma, and V. We displayed these matrices, and verified that they satisfy the...