CoCalc Public FilesLinear Algebra Fall 2019 / 2019-09-23-examples.sagews
Author: Theron Hitchman
Views : 82
Compute Environment: Ubuntu 18.04 (Deprecated)

# Let's do some Gaussian Elimination!

A = matrix(QQbar, 5,5, [1..25])
A

[ 1 2 3 4 5] [ 6 7 8 9 10] [11 12 13 14 15] [16 17 18 19 20] [21 22 23 24 25]
b = vector([2,3,5,7,11])
b

(2, 3, 5, 7, 11)
A1 = A.augment(b, subdivide=True)

A1

[ 1 2 3 4 5| 2] [ 6 7 8 9 10| 3] [11 12 13 14 15| 5] [16 17 18 19 20| 7] [21 22 23 24 25|11]
A2 = A1.with_added_multiple_of_row(1,0,-6); A2

[ 1 2 3 4 5| 2] [ 0 -5 -10 -15 -20| -9] [ 11 12 13 14 15| 5] [ 16 17 18 19 20| 7] [ 21 22 23 24 25| 11]
A3 = A2.with_added_multiple_of_row(2,0,-11); A3

[ 1 2 3 4 5| 2] [ 0 -5 -10 -15 -20| -9] [ 0 -10 -20 -30 -40|-17] [ 16 17 18 19 20| 7] [ 21 22 23 24 25| 11]
A4 = A3.with_added_multiple_of_row(3,0,-16); A4

[ 1 2 3 4 5| 2] [ 0 -5 -10 -15 -20| -9] [ 0 -10 -20 -30 -40|-17] [ 0 -15 -30 -45 -60|-25] [ 21 22 23 24 25| 11]
A5 = A4.with_added_multiple_of_row(4,0,-21); A5

[ 1 2 3 4 5| 2] [ 0 -5 -10 -15 -20| -9] [ 0 -10 -20 -30 -40|-17] [ 0 -15 -30 -45 -60|-25] [ 0 -20 -40 -60 -80|-31]


A1.rref()

[ 1 0 -1 -2 -3| 0] [ 0 1 2 3 4| 0] [ 0 0 0 0 0| 1] [ 0 0 0 0 0| 0] [ 0 0 0 0 0| 0]
z = vector([0,0,0,0,0])
A.augment(z, subdivide=True).rref()

[ 1 0 -1 -2 -3| 0] [ 0 1 2 3 4| 0] [ 0 0 0 0 0| 0] [ 0 0 0 0 0| 0] [ 0 0 0 0 0| 0]