Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Math 480 - Grading due 6pm on May 13, 2016
HOMEWORK TOTAL: 70 POINTS
Problem 1 -- solve a linear system in four variables both symbolically and using matrices
Consider the following system of linear equations
Solve this equation for rational numbers , , and 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 and a vector and use
A.solve_right(v)
. (As a double check, note that .)(2) Multiply by the inverse of ,
(3) Compute the reduced row echelon form of the augmented matrix
[A|v]
and read off the solution.
10 Points Total
Part A (3 points)
Award:
- 3 points for a correct solution with solve
- 2 points for a nearly correct solution (like a typo)
- 1 point for some incorrect work with the wrong approach
Part B (7 points)
Award:
- 7 points for all parts being correct
- 5 points for one part being incorrect
- 3 points for 2 parts being incorrect
- 1 point for no parts correct but they did some work
Problem 2 -- compute some kernels
Let and be the following two matrices. [ A = \qquad B = ]
a. Use Sage to compute the and .
b. Use Sage to compute and .
c. Create a 3d plot that illustrates each kernel (which should be a plane), and the intersection of the two kernels (which should be a line). Make sure that your range is centered about the origin.
10 Points Total
Parts A and B (3 points each)
Award:
- 3 points for a correct solution
- 2 points for a nearly correct solution (like a typo)
- 1 point for some incorrect work with the wrong approach
Part B (4 points)
Award:
- 1 point for each component of the plot (each plane and the intersection)
- 1 point for completion.
Problem 3 -- how fast is linear algebra over ?
a. For , how long does it take Sage to compute the determinant of an random -matrix over ?
b. Roughly how many digits does the determinant of a random -matrix with over have? Compute some data and make a guess based on your data.
10 Points Total
Part A (7 points)
Award:
- 4 points for correctly generating the matrices.
- 3 points for correclty using %timeit
Part B (3 points)
Award:
- 2 points for some data
- 1 point for an appropriate guess based on their data
For an nxn matrix, the approximate number of digits in the determinant seems to be about N Approximately linear.
Problem 4 -- Eigenvalues and eigenvectors of matrices
Let be the following matrix with rational entries
a. Use Sage to compute the characteristic polynomial of .
b. Use Sage to verify that . (This is a consequence of the Cayley-Hamilton theorem.)
c. Compute the roots of 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 .e. Verify that the product of the roots of the characteristic polynomial is equal to the determinant of .
10 Points Total
All parts (2 points each)
Award points based on correct output.
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 methodsdelete_columns
anddelete_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.
20 Points Total
Part A (12 points)
Award:
- 12 points if their soloution works for N = 1, 2, 3, 4, 5.
- 10 points if they just missed a negative sign in their formula.
- 8 points if their solution seems like it's going towards the given solution.
- 1 - 6 points depending on how much of an attempt they made.
Part B (4 points)
Award:
- 4 points if they correctly count the correct number of timesa 1x1 matrix is computed.
- 2 points if they count the number of times `my_det` is called instead.
Part C (2 points)
Award:
- 2 points for N!
- 1 point for anything else with a reasonable argument
Part D (2 points)
Award:
- 2 points for "no" and and a short explanation.
- 1 point for just a no.
The computational complexity is N!
No; it would be way slower.
Problem 6 -- explore some matrix functions
Let be the following matrix over the rational numbers :
For each of the following functions: F.gram_schmidt()
, F.rref()
, F.LU()
a. Evaluate the function on 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 random -matrix over ? No explanation is necessary for this part.
10 Points Total
For parts A, B, and C, you just need to check that they gave a solution.Part A (3 points)
Award:
- 1 point per call.
Part B (3 points)
Award:
- 1 point per explanation.
Part C (3 points)
Award:
- 1 point per example.
Part D (1 point)
No output is necessary
Award:
- 1 point if they said yes for all of them.
- 0.5 points if they missed one
- 0 otherwise.
Use Gram-Schmidt in projecting vectors onto subspaces
Use rref to find kernels of matrices, and solve systems of equations
Wikipedia says "LU is also a key step when inverting a matrix"... so many students will say that.