Ticket #3794: eigenfunctions-doc.patch

File eigenfunctions-doc.patch, 4.2 kB (added by jason, 5 months ago)
  • a/const/const.tex

    old new  
    14871487 
    14881488How do you compute eigenvalues and eigenvectors using \sage? 
    14891489 
    1490 \sage included both in the \code{eigenspaces} command, the output of which has 
    1491 several components, corresponding to the different eigenvalues. 
    1492  
    1493 \begin{verbatim} 
    1494 sage: MS = MatrixSpace(QQ, 3, 3) 
    1495 sage: A = MS([[1,1,0],[0,2,0],[0,0,3]]) 
     1490\sage has a full range of functions for computing eigenvalues and both 
     1491left and right eigenvectors and eigenspaces.  If our matrix is $A$, then 
     1492\code{eigenmatrix_right} (\code{eigenmatrix_left}) command also 
     1493gives matrices $D$ and $P$ such that $AP=PD$ ($PA=DP$). 
     1494 
     1495\begin{verbatim} 
     1496sage: A = matrix(QQ, [[1,1,0],[0,2,0],[0,0,3]]) 
    14961497sage: A 
    14971498[1 1 0] 
    14981499[0 2 0] 
    14991500[0 0 3] 
    1500 sage: A.eigenspaces() 
     1501sage: A.eigenvalues() 
     1502[3, 2, 1] 
     1503sage: A.eigenvectors_right() 
     1504[(3, [ 
     1505(0, 0, 1) 
     1506], 1), (2, [ 
     1507(1, 1, 0) 
     1508], 1), (1, [ 
     1509(1, 0, 0) 
     1510], 1)] 
     1511sage: A.eigenspaces_right() 
    15011512[ 
    15021513(3, Vector space of degree 3 and dimension 1 over Rational Field 
    15031514User basis matrix: 
    15041515[0 0 1]), 
    15051516(2, Vector space of degree 3 and dimension 1 over Rational Field 
    15061517User basis matrix: 
    1507 [0 1 0]), 
     1518[1 1 0]), 
    15081519(1, Vector space of degree 3 and dimension 1 over Rational Field 
    15091520User basis matrix: 
    1510 [ 1 -1 0]) 
     1521[1 0 0]) 
    15111522] 
    1512 sage: A = MS([[1,1,0],[0,1,0],[0,0, 2]]) 
    1513 sage: A 
    1514 [1 1 0] 
     1523sage: D, P = A.eigenmatrix_right() 
     1524sage: D 
     1525[3 0 0] 
     1526[0 2 0] 
     1527[0 0 1] 
     1528sage: P 
     1529[0 1 1] 
    15151530[0 1 0] 
    1516 [0 0 2] 
    1517 sage: A.eigenspaces() 
    1518 
    1519 (2, Vector space of degree 3 and dimension 1 over Rational Field 
    1520 User basis matrix: 
    1521 [0 0 1]), 
    1522 (1, Vector space of degree 3 and dimension 1 over Rational Field 
    1523 User basis matrix: 
    1524 [0 1 0]) 
    1525 
    1526 \end{verbatim} 
    1527  
    1528 A word of caution - if the eigenvalues are not in the base ring of the matrix 
    1529 space (the eigenvalues below are $\pm \sqrt{3}$) then  
    1530 the output is incomplete: 
     1531[1 0 0] 
     1532sage: A*P == P*D 
     1533True 
     1534\end{verbatim} 
     1535 
     1536A word of caution - if the eigenvalues are not in the fraction field 
     1537of the base ring of the matrix space (the eigenvalues below are $\pm 
     1538\sqrt{3}$) then the output of \code{eigenspaces_right} and 
     1539\code{eigenspaces_left} only lists a single eigenspace for each 
     1540irreducible factor of the characteristic polynomial. 
     1541 
     1542Also, currently \sage does not implement multiprecision numerical 
     1543eigenvalues/eigenvectors, so calling the eigen functions on a matrix 
     1544from \code{CC} or \code{RR} will probably give inaccurate and 
     1545nonsensical results (a warning is also printed).  Matrices over 
     1546\code{CDF} and \code{RDF} should work, though. 
    15311547 
    15321548\begin{verbatim} 
    15331549sage: MS = MatrixSpace(QQ, 2, 2) 
    15341550sage: A = MS([1,-4,1, -1]) 
    1535 sage: A.eigenspaces() 
     1551sage: A.eigenspaces_left() 
    15361552[ 
    15371553(a0, Vector space of degree 2 and dimension 1 over Number Field in a0 with defining polynomial x^2 + 3 
    15381554User basis matrix: 
     
    15401556] 
    15411557sage: MS = MatrixSpace(CC, 2, 2) 
    15421558sage: A = MS([1,-4,1, -1]) 
    1543 sage: A.eigenspaces(even_if_inexact=True) # random output 
     1559sage: A.eigenspaces() # random output 
    15441560[                               
    15451561(1.73205080756888*I, [                 
    15461562]), 
  • a/tut/tut.tex

    old new  
    18241824\index{matrix!eigenvectors} 
    18251825 
    18261826\begin{verbatim} 
    1827 sage: MS = MatrixSpace(GF(7),2,2) 
    1828 sage: g = MS([[5, 1], [4, 1]]) 
    1829 sage: eigvals = [g.eigenspaces()[0][0], g.eigenspaces()[1][0]]; eigvals 
     1827sage: g = matrix(GF(7), [[5, 1], [4, 1]]) 
     1828sage: g.eigenvalues() 
    18301829[4, 2] 
    1831 sage: g.eigenspaces() 
    1832 
    1833 (4, Vector space of degree 2 and dimension 1 over Finite Field of size 7 
    1834 User basis matrix: 
    1835 [1 5]), 
    1836 (2, Vector space of degree 2 and dimension 1 over Finite Field of size 7 
    1837 User basis matrix: 
    1838 [1 1]) 
    1839 
     1830sage: g.eigenvectors_right() # returns (eigenvalue, [eigenvectors], algebraic multiplicity) 
     1831[(4, [ 
     1832(1, 6) 
     1833], 1), (2, [ 
     1834(1, 4) 
     1835], 1)] 
    18401836\end{verbatim} 
    18411837 
    18421838%\subsection{Numerical Linear Algebra}