Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 7ebd25ac536d248d499a3ce2acda963a > files > 3760

Macaulay2-1.3.1-8.fc15.i686.rpm

<?xml version="1.0" encoding="utf-8" ?>  <!-- for emacs: -*- coding: utf-8 -*- -->
<!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"	 "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><title>SVD -- singular value decomposition of a matrix</title>
<link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/>
</head>
<body>
<table class="buttons">
  <tr>
    <td><div><a href="___S__V__D_lp..._cm_sp__Divide__Conquer_sp_eq_gt_sp..._rp.html">next</a> | <a href="_support_lp__Ideal_rp.html">previous</a> | <a href="___S__V__D_lp..._cm_sp__Divide__Conquer_sp_eq_gt_sp..._rp.html">forward</a> | <a href="_support_lp__Ideal_rp.html">backward</a> | up | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div>

    </td>
  </tr>
</table>
<hr/>
<div><h1>SVD -- singular value decomposition of a matrix</h1>
<div class="single"><h2>Synopsis</h2>
<ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>(S,U,Vt) = SVD M</tt></div>
</dd></dl>
</div>
</li>
<li><div class="single">Inputs:<ul><li><span><tt>M</tt>, <span>a <a href="___Matrix.html">matrix</a></span>,  over <a href="___R__R.html" title="the class of all real numbers">RR</a> or <a href="___C__C.html" title="the class of all complex numbers">CC</a>, of size <tt>m</tt> by <tt>n</tt></span></li>
</ul>
</div>
</li>
<li><div class="single">Outputs:<ul><li><span><tt>S</tt>, <span>a <a href="___Vertical__List.html">vertical list</a></span>, the list of singular values</span></li>
<li><span><tt>U</tt>, <span>a <a href="___Matrix.html">matrix</a></span>, an orthogonal (unitary) matrix of size <tt>m</tt> by <tt>m</tt></span></li>
<li><span><tt>Vt</tt>, <span>a <a href="___Matrix.html">matrix</a></span>, an orthogonal (unitary) matrix of size <tt>n</tt> by <tt>n</tt></span></li>
</ul>
</div>
</li>
<li><div class="single"><a href="_using_spfunctions_spwith_spoptional_spinputs.html">Optional inputs</a>:<ul><li><span><a href="___S__V__D_lp..._cm_sp__Divide__Conquer_sp_eq_gt_sp..._rp.html">DivideConquer => ...</a>,  -- Use the lapack divide and conquer SVD algorithm</span></li>
</ul>
</div>
</li>
</ul>
</div>
<div class="single"><h2>Description</h2>
<div>If <tt>Sigma</tt> is the diagonal <tt>m</tt> by <tt>n</tt> matrix whose <tt>(i,i)</tt> entry is the <tt>i</tt>-th element of <tt>S</tt>, then <tt>M = U Sigma Vt</tt>.  This is the singular value decomposition of <tt>M</tt>.  The entries of <tt>S</tt> are (up to roundoff error) the eigenvalues of the Hermitian matrix <tt>M * (conjugate transpose M)</tt><p/>
M may also be a <a href="___Mutable__Matrix.html" title="the class of all mutable matrices">MutableMatrix</a> in which case the returned values <tt>U</tt> and <tt>Vt</tt> are also <a href="___Mutable__Matrix.html">mutable matrices</a>.<p/>
If <tt>M</tt> is over <a href="___C__C.html" title="the class of all complex numbers">CC</a>, then <tt>U</tt> and <tt>Vt</tt> are unitary matrices over <a href="___C__C.html" title="the class of all complex numbers">CC</a>.  If <tt>M</tt> is over <a href="___R__R.html" title="the class of all real numbers">RR</a>, <tt>U</tt> and <tt>Vt</tt> are orthogonal over <tt>RR</tt>.<table class="examples"><tr><td><pre>i1 : printingPrecision=2;</pre>
</td></tr>
<tr><td><pre>i2 : M = map(RR^3, RR^5, (i,j) -> (i+1)^j * 1.0)

o2 = | 1 1 1 1  1  |
     | 1 2 4 8  16 |
     | 1 3 9 27 81 |

                3          5
o2 : Matrix RR    &lt;--- RR
              53         53</pre>
</td></tr>
<tr><td><pre>i3 : (S,U,V) = SVD(M)

o3 = ({88 }, | -.016 -.4  -.92  |, | -.014 -.038 -.11 -.32 -.94  |)
      {3.9}  | -.21  -.89 .4    |  | -.28  -.41  -.57 -.59 .29   |
      {.8 }  | -.98  .2   -.068 |  | -.74  -.41  .066 .51  -.15  |
                                   | .084  .33   -.81 .47  -.081 |
                                   | -.61  .74   .077 -.27 .062  |

o3 : Sequence</pre>
</td></tr>
<tr><td><pre>i4 : M' = (transpose U) * M * (transpose V)

o4 = | 88       1.1e-14  2.4e-15  -9.4e-16 9.3e-15  |
     | -6.1e-15 3.9      -9.3e-15 -7.2e-16 -1.8e-15 |
     | -7e-15   -6.1e-15 .8       4.1e-16  4.4e-16  |

                3          5
o4 : Matrix RR    &lt;--- RR
              53         53</pre>
</td></tr>
</table>
We can clean the small entries from the result above with <a href="_clean.html" title="Set to zero elements that are approximately zero">clean</a>.<table class="examples"><tr><td><pre>i5 : e = 1e-10;</pre>
</td></tr>
<tr><td><pre>i6 : clean_e M'

o6 = | 88 0   0  0 0 |
     | 0  3.9 0  0 0 |
     | 0  0   .8 0 0 |

                3          5
o6 : Matrix RR    &lt;--- RR
              53         53</pre>
</td></tr>
<tr><td><pre>i7 : clean_e norm (1 - U * transpose U)

o7 = 0

o7 : RR (of precision 53)</pre>
</td></tr>
</table>
Alternatively, if the only issue is display of the matrix, we may set the printing accuracy.<table class="examples"><tr><td><pre>i8 : printingAccuracy = 2

o8 = 2</pre>
</td></tr>
<tr><td><pre>i9 : M'

o9 = | 88 0   0  0 0 |
     | 0  3.9 0  0 0 |
     | 0  0   .8 0 0 |

                3          5
o9 : Matrix RR    &lt;--- RR
              53         53</pre>
</td></tr>
</table>
Now let's try the divide and conquer algorithm and compare answers.<table class="examples"><tr><td><pre>i10 : (S', U', V') = SVD(M, DivideConquer => true)

o10 = ({88 }, | -.02 -.4  -.92 |, | -.01 -.04 -.11 -.32 -.94 |)
       {3.9}  | -.21 -.89 .4   |  | -.28 -.41 -.57 -.59 .29  |
       {.8 }  | -.98 .2   -.07 |  | -.74 -.41 .07  .51  -.15 |
                                  | .08  .33  -.81 .47  -.08 |
                                  | -.61 .74  .08  -.27 .06  |

o10 : Sequence</pre>
</td></tr>
<tr><td><pre>i11 : norm \ ({S', U', V'}-{S, U, V})

o11 = {0, 0, 0}

o11 : List</pre>
</td></tr>
</table>
The SVD routine calls on the SVD algorithms in the lapack library.</div>
</div>
<div class="single"><h2>See also</h2>
<ul><li><span><a href="_eigenvalues.html" title="find eigenvalues of a matrix">eigenvalues</a> -- find eigenvalues of a matrix</span></li>
<li><span><a href="_eigenvectors.html" title="find eigenvectors of a matrix over RR or CC">eigenvectors</a> -- find eigenvectors of a matrix over RR or CC</span></li>
<li><span><a href="_norm.html" title="">norm</a></span></li>
<li><span><a href="_clean.html" title="Set to zero elements that are approximately zero">clean</a> -- Set to zero elements that are approximately zero</span></li>
<li><span><a href="_printing__Accuracy.html" title="current accuracy for printing numbers">printingAccuracy</a> -- current accuracy for printing numbers</span></li>
<li><span><a href="_printing__Precision.html" title="current precision for printing numbers">printingPrecision</a> -- current precision for printing numbers</span></li>
</ul>
</div>
<div class="waystouse"><h2>Ways to use <tt>SVD</tt> :</h2>
<ul><li>SVD(Matrix)</li>
<li>SVD(MutableMatrix)</li>
</ul>
</div>
</div>
</body>
</html>