M ATH 150 S AGE M ATH L INEAR A LGEBRA C HEAT S HEET Last Updated July 29, 2017
I�������� Notes M�����/V����� Entries and Components M����� Operations
Indices start at � • v[i] • A*B When specifying rows, columns, or entries of a Entry in position i of vector v Product of matrices A and B, if de�ned matrix, count by starting with �. • A+B • A[i,j] Entry in row i and column j of A Sum of matrices A and B, if de�ned Row vs Column Vectors Sage does not differentiate between row and col- • A.row(m) • A.echelon_form() umn vectors. Vectors are interpreted as needed mth row of A as vector Echelon form of matrix A so operations are de�ned, if possible. • A.column(m) • A.rref() mth column of A as vector Reduced echelon form of matrix A Specify the ring • A.inverse() Sage needs to know which space our matrices • A.rows() List of rows of A as list Inverse of matrix A (if de�ned) and vectors are de�ned in, even when de�ning a particular matrix. The Sage keys for common sets • A.determinant() • A.columns() are Returns determinant of matrix A List of columns of A as list RR = reals, QQ = rationals, ZZ = integers • A.transpose() Specifying the ring is optional but highly recom- • A.submatrix(m,n,nrows,ncols) Returns transpose of matrix A mended. nrows ⇥ ncols submatrix of A beginning at entry A[m, n] • A.rank() Returns rank of matrix A D������� M������� ��� V������ • A.matrix_from_rows(list) • A = Matrix(FF, [[row0],[row1],...]) Forms new matrix from rows of A listed in De�nes speci�c matrix with entries in the V����� Operations list ring F • v.norm() • A.matrix_from_columns(list) Norm of vector v ex: A = Matrix(RR, [[1,2,3],[4,5,6]]) 1 2 3 Forms new matrix from columns of A listed de�nes A = in list • v.norm(1) 4 5 6 Sum of entries of vector v • v = vector(FF, list) S������ Matrices • v.len() De�nes speci�c vector with entries in the Number of entries of v ring F • random_matrix(FF,m,n) ex: v = vector(RR, [1,0,8,6]) Random m ⇥ n in �eld F • v.dot_product(u) ex: A = random_matrix(QQ,2,4) Dot produce of vectors v and u A is random 2 ⇥ 4 matrix with entries in Q • v.cross_product(u) M����� Property Testing • identity_matrix(n) Cross produce of vectors v and u Return boolean value (true or false) n ⇥ n identity matrix: • A.is_invertible() R�� Operations ex: I4 = identity_matrix(4) • A.is_symmetric() I4 is 4 ⇥ 4 identity matrix • A.swap_rows(n,m) • A.is_singular() Interchange rows n and m • Augment matrices A and B: A.augment(B) • A.is_orthogonal() ex: A = Matrix([[1,2],[3,4]]) • A.rescale_row(n, c) • A.is_scalar() N = A.augment(identity_matrix(2)) Multiply entries of row n by c • A.is_one() returns • A.add_multiple_of_row(n,m,c) • A.is_zero() Add c times row m to row n 1 2 1 0 • A.is_diagonalizable() N= 3 4 0 1 M ATH 150 S AGE M ATH L INEAR A LGEBRA C HEAT S HEET Last Updated July 29, 2017
J������ Matrices S������ a System of Equations O���� Useful Functions
• A.augment(B) Example system with solution x = 1, y = 5 • Solve equation Augment matrices A and B solve(x^2-4==0, x) ex: A = Matrix([[1,2],[3,4]]) 3x y=2 solve(x^2-4==0, x) N = A.augment(identity_matrix(2)) x y=6 returns • Roots of polynomial Method �: De�ne augmented matrix and reduce (x^2-3*x).roots(x) 1 2 1 0 A = Matrix([[3,-1,2],[-1,-1,6]]) N= • Factor polynomial 3 4 0 1 S = A.rref() S (x^2+8*x-9).factor() • A.stack(B) Stack matrix A over B prints • Limits ex: A = Matrix([[1,2],[3,4]]) [ 1 0 -1 ] limit(x^2+5*x, x=2) N = A.stack(identity_matrix(2)) [ 0 1 -5 ] • Derivatives returns 2 3 diff(x^2+4*x, x) 1 2 Method �: De�ne coef�cient matrix and vector, 63 47 then solve • Antiderivative N =6 41 05 7 A = Matrix([[3,-1],[-1,-1]]) integral(x^2+4*x, x) 0 1 b = vector([2,6]) • De�nite Integral S = A.solve_right(b) integral(x^2+4*x, x, 0, 4) V����� Spaces and Properties S • VectorSpace(FF, n) prints • Simplify Expressions n dimensional vector space over F (-1, -5) ((x^2-4)/(x+2)).simplify_rational() ex: V = VectorSpace(RR,2) ((x-2)*(x+6)).expand() de�nes V = R2 C�������� and Basic Math • V.dimension() • Sage constants: pi, e, i, oo, log2 P������� Dimension of space V • Products See Sage documentation for a complete list of • V.basis() a = 4*9 plot options, such as titles, colors, line widths, Canonical basis of space V • Powers �lls, and much more. • V.is_subspace(W) a = 8^2 • plot(x^2,(x,-4,20)) Test if W is a subspace of V • Roots • MatrixSpace(FF, m, n) a=sqrt(16) • circle( (3,5), 2 ) Space of m ⇥ n matrices over F • line([(1,5),(3,7)]) ex: V = MatrixSpace(QQ,2,3) S����� • List: [1,2,3] • polygon([(0,0), (1,3), (2,5), (0,4)]) space of 2⇥3 matrices with rational entries • Tuple: (1,2,3) • L = plot(x^2, (x,-2,2), rgbcolor=(1,0,0)) E����������� and Eigenvalues N = plot(x^4, (x,-2,2), rgbcolor=(0,0,1)) • Set: {1,2,3} • A.eigenvalues() show(L+N) List of eigenvalues of A • range(n) List 0, 1, 2, . . . , n 1 • bar_chart([3,5,-1,2,8,4,3,2,5] ) • A.eigenvectors_right() List of triples: • range(m,n) • M = [[1,3,4,2],[2,4,1,0]] (eval, evector, multiplicity) List m, m + 1, . . . , n 1 matrix_plot(M, colorbar=True) • A.characteristic_polynomial() • Comments: Start line with # • L = [[1,3],[2,5],[2,7],[1.8,2.9]] Characteristic polynomial of A • Comparison: ==, <, >, <=, >=, != scatter_plot(L)