sage: a = vector([1, 2]) sage: b = vector([3, 4]) sage: a.dot_product(b) 11 sage: norm(a) sqrt(5) sage: latex(norm(a)) # if you ever need LaTeX code \sqrt{5} sage: A = matrix([[0,0,1,1/2],[1/3,0,0,0],[1/3,1/2,0,1/2],[1/3,1/2,0,0]]) # one way of writing down a matrix sage: v = vector([1/4,1/4,1/4,1/4]) sage: A^34*v (1150464574049/2972033482752, 287616143213/2229025112064, 5177090584417/17832200896512, 3451393722097/17832200896512) sage: N(A^34*v) # returns numerical values (0.387096774220629, 0.129032257939291, 0.290322580732569, 0.193548387107510) sage: A = matrix(3, 3, [0, -1, -1, 1, 2, 1, 1, 1, 2]) # another way of writing down a matrix sage: b = vector([1, 2, 3]) sage: A.solve_right(b) # solves Ax = b (4, -1, 0) sage: A.inverse() [ 3/2 1/2 1/2] [-1/2 1/2 -1/2] [-1/2 -1/2 1/2] sage: A.gram_schmidt() # returns a matrix B whose rows are an orthogonal basis and the transition matrix C, i.e., C*B = A ( [ 0 -1 -1] [ 1 0 0] [ 1 1/2 -1/2] [-3/2 1 0] [ 2/3 -2/3 2/3], [-3/2 1/3 1] ) sage: I = identity_matrix(3) sage: I [1 0 0] [0 1 0] [0 0 1] sage: A = matrix(2, 2, [1, 3, 2, 6]) sage: A [1 3] [2 6] sage: A.right_kernel() # careful: A.kernel() returns the left kernel... Free module of degree 2 and rank 1 over Integer Ring Echelon basis matrix: [ 3 -1] sage: A.column_space() # image of A Free module of degree 2 and rank 1 over Integer Ring Echelon basis matrix: [1 2] sage: det(A) 0 sage: A.eigenvalues() [7, 0] sage: A.eigenvectors_right() # returns a basis for each eigenspace [(7, [ (1, 2) ], 1), (0, [ (1, -1/3) ] sage: A.charpoly() x^2 - 7*x sage: A.fcp() # attempts to factor the characteristic polynomial (x - 7) * x sage: A.rref() # row-reduced echelon form [1 3] [0 0] sage: A.pivots() # indices of columns spanning the image; note that Sage starts indexing at 0 (0,) sage: A.LU() # factors A into permutation, lower-triangular, and upper-triangular matrix ( [0 1] [ 1 0] [2 6] [1 0], [1/2 1], [0 0] ) sage: A.eigenmatrix_right() # if possible, returns the diagonal matrix with eigenvalues and a matrix whose columns are a basis of eigenvectors ( [7 0] [ 1 1] [0 0], [ 2 -1/3] )