Worksheet 8
Compute the reduced row echelon form of in two ways. First by using the row operations in Sage one by one. Next by using the
.rref()
method on .For the same as in 1, compute a LU factorization in two ways: using your list of row operations and using the
.LU()
method.This will acquiant you a bit more with some of the syntax for common types in Python/Sage. One way to declare a list in Python is
L = [1,2,3] # a list consisting of 1,2,3
Suppose you want to print out each element of the list one by one
for x in L: print(x)
If you want second entry out of L you would write
L[1]
since Sage starts counting at 0. An example of a function declaration in Python (and hence Sage) is
def f(x): return x+5
Write a function in Sage that consumes a matrix and returns the sum of all entries in the matrix. Test it out on the matrix from 1. Hint:
A.list()
.