Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Project: math480-2016
Views: 2158

Math 480: Open Source Mathematical Software

2016-05-02

William Stein

Lectures 16: Linear Algebra

Today:

# You should read this matrix? # and this vector?
#A = matrix(2, 3, [[1,2,3], [sqrt(2),5,pi]]) A = matrix(2, 3, [1,2,3, sqrt(2),5,pi]) A
[ 1 2 3] [sqrt(2) 5 pi]
show(A)
(12325π)\displaystyle \left(\begin{array}{rrr} 1 & 2 & 3 \\ \sqrt{2} & 5 & \pi \end{array}\right)
v = vector([1, sqrt(2), pi^2]); v
(1, sqrt(2), pi^2)
show(v)
(1,2,π2)\displaystyle \left(1,\,\sqrt{2},\,\pi^{2}\right)
A*v
(3*pi^2 + 2*sqrt(2) + 1, pi^3 + 6*sqrt(2))
v * A.transpose()
(3*pi^2 + 2*sqrt(2) + 1, pi^3 + 6*sqrt(2))
show(A.echelon_form())
(102(π32)225+301π32225)\displaystyle \left(\begin{array}{rrr} 1 & 0 & \frac{2 \, {\left(\pi - 3 \, \sqrt{2}\right)}}{2 \, \sqrt{2} - 5} + 3 \\ 0 & 1 & -\frac{\pi - 3 \, \sqrt{2}}{2 \, \sqrt{2} - 5} \end{array}\right)

2. Standard functions:

  • determinant

  • characteristic polynomial

  • echelon form

  • row space

  • column space

  • rows, columns

  • matrix_from_rows, matrix_from_columns

  • solve

set_random_seed(42) # put your age here A = random_matrix(QQ, 5) show(A)
(11122121220001112121111102210)\displaystyle \left(\begin{array}{rrrrr} -1 & -1 & -\frac{1}{2} & 2 & -\frac{1}{2} \\ \frac{1}{2} & -2 & 0 & 0 & 0 \\ 1 & -1 & -1 & 2 & -\frac{1}{2} \\ -1 & 1 & -1 & 1 & 1 \\ 0 & 2 & -2 & -1 & 0 \end{array}\right)
f = A.charpoly() parent(f)
Univariate Polynomial Ring in x over Rational Field
f.base_ring()
Rational Field
f.factor()
x^5 + 3*x^4 + 6*x^3 + 63/4*x^2 + 29*x + 195/8
show(f.change_ring(CC).factor())
(x0.7140039591745892.07933489614716i)(x0.714003959174589+2.07933489614716i)(x+1.285346654498701.03106393820580i)(x+1.28534665449870+1.03106393820580i)(x+1.85731460935178)\displaystyle (x - 0.714003959174589 - 2.07933489614716i) \cdot (x - 0.714003959174589 + 2.07933489614716i) \cdot (x + 1.28534665449870 - 1.03106393820580i) \cdot (x + 1.28534665449870 + 1.03106393820580i) \cdot (x + 1.85731460935178)
E= A.eigenspaces_right()
E[0]
(-1.857314609351780?, Vector space of degree 5 and dimension 1 over Algebraic Field User basis matrix: [ 1 3.504212994256084? -0.10512329983419517? 0.3761439167989345? -3.684097802778675?])
len(E)
5
A.determinant()
-195/8
A.row_space()
Vector space of degree 5 and dimension 5 over Rational Field Basis matrix: [1 0 0 0 0] [0 1 0 0 0] [0 0 1 0 0] [0 0 0 1 0] [0 0 0 0 1]
QQ^3
Vector space of dimension 3 over Rational Field
span(QQ, [vector([1,2,3]), vector([4,5,6]), vector([7,8,9])])
Vector space of degree 3 and dimension 2 over Rational Field Basis matrix: [ 1 0 -1] [ 0 1 2]