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

Math 480 - Homework 5: Due 6pm on May 6, 2016

There are SIX problems. All problems have equal weight except probelem 5 which has twice the weight of the others

Solve each problem using Sage unless otherwise indicated. In particular, if there is some linear algebra question, which you could easily do by hand or in your head, you should still show exactly how to solve it using Sage if possible. Of course, do always think with your brain!

Useful facts:

Problem 1 -- solve a linear system in four variables both symbolically and using matrices

Consider the following system of linear equations

a+3b2c+7d=12a5b2d=3895a2b+3c+d=03a+8bd=4\begin{align*} a + 3b - 2c + 7d &= -12 \\ -a - 5b - 2d &= 389 \\ -5a - 2b + 3c + d &= 0 \\ 3a + 8b - d &= 4 \end{align*}

Solve this equation for rational numbers aa, bb, cc and dd in several ways using Sage:

  • a. Solve symbolically, using the solve command and symbolic variables (created using %var)

  • b. Solve using matrices, in the following three ways:

    • (1) Create a 4x4 matrix AA and a vector vv and use A.solve_right(v). (As a double check, note that det(A)=21\det(A)=-21.)

    • (2) Multiply vv by the inverse of AA,

    • (3) Compute the reduced row echelon form of the augmented matrix [A|v] and read off the solution.

# a
# b
# a
# b
# c

Problem 3 -- how fast is linear algebra over Z\ZZ?

  • a. For n=10,100,500,1000n=10, 100, 500, 1000, how long does it take Sage to compute the determinant of an n×nn\times n random {0,1}\{0,1\}-matrix over Z\ZZ?

  • b. Roughly how many digits does the determinant of a n×nn\times n random {0,1}\{0,1\}-matrix with over Z\ZZ have? Compute some data and make a guess based on your data.

# a
# b
# Computed for part b.

Problem 4 -- Eigenvalues and eigenvectors of matrices Q\QQ

Let MM be the following matrix with rational entries M=(120101121101112121) M = \left(\begin{array}{rrrr} \frac{1}{2} & 0 & -1 & 0 \\ 1 & \frac{1}{2} & 1 & 1 \\ 0 & 1 & -1 & -1 \\ 2 & 1 & -2 & 1 \end{array}\right)

  • a. Use Sage to compute the characteristic polynomial f(x)f(x) of MM.

  • b. Use Sage to verify that f(M)=0f(M)=0. (This is a consequence of the Cayley-Hamilton theorem.)

  • c. Compute the roots of ff symbolically. Display one of them using the show command. You should see a big formula involving radical signs.

  • d. Use A.eigenvalues() to compute the roots of ff.

  • e. Verify that the product of the roots of the characteristic polynomial ff is equal to the determinant of MM.

# a. # ... Your code # Define your function f above here. # Do not change these two lines below. f show(f)
# b.
# c show(root) # You'll need root defined correctly above.
# d
# e

Problem 5 -- Implement the horrible recursive "expansion by cofactors" algorithm to compute determinants

  • a. Implement a function called my_det that calculates the determinant of a matrix using the recursive "expansion by cofactors" algorithm (this is probably the way you learned to compute determinants in a Linear Algebra class). The Matrix methods delete_columns and delete_rows may come in handy. You can assume that your input is a square matrix. (Note: Do not cache intermediate results in your implementation.)

  • b. Count how many times your algorithm computes the determinant of a 1x1 matrix when you give as input...

    • A 1x1 matrix

    • A 2x2 matrix

    • A 3x3 matrix

    • A 4x4 matrix

    • A NxN matrix (Here you should guess based on what you observe above.)

    • (hint: you could make a counter and use the global python keyword)

  • c. What does this tell you about how the algorithm's compute time might scale based on the size of N? (computational complexity)

  • d. Time the computation of determinants of some random matrices using Sage (NOT your function); based on the compute times you observe, do you think Sage is using a version of your algorithm? Give a short (2-3 sentence) explanation.

# Solution - 5 def my_det(M): # do something with M here! pass # Delete this line when you write your solution

Problem 6 -- explore some matrix functions

Let FF be the following matrix over the rational numbers Q\QQ: F=(1112175130001129) F = \left(\begin{array}{rrrr} -1 & -1 & -1 & -2 \\ -1 & -7 & -5 & -1 \\ -3 & 0 & 0 & 0 \\ 1 & -1 & 2 & 9 \end{array}\right)

For each of the following functions: F.gram_schmidt(), F.rref(), F.LU()

  • a. Evaluate the function on FF and see what you get.

  • b. Explain in your own words what the function does (you don't have to say anything about how it is implemented or works). E.g., why do you think it has the name it has?

  • c. How might you use this function to solve some problem in mathematics? I.e., what sort of problem might you solve?

  • d. Would the function "work" (finish in a few seconds) when given a 100×100100\times 100 random {0,1}\{0,1\}-matrix over Z\ZZ? No explanation is necessary for this part.