Homework 3
Table of Contents
The following assignment is due Thursday 9/26 by 11:59 PM. You should submit all your written solutions to Gradescope as a single pdf. Follow the instructions in the programming problem for code solutions.
- Your solutions must be exceptionally neat and the final answer in your solution to each problem must be abundantly clear, e.g., surrounded in a very visible box. The graders have license to dock points for illegible or unclear solutions.
- For the written part, choose the correct pages corresponding to each problem in Gradescope. Note that Gradescope registers your submission as soon as you submit it, so you don't need to rush to choose the pages. You will receive no credit if you do not choose the correct pages, no exceptions.
1. Plane Intersection and RREFs
(10 points) Suppose you are given a system of linear equations with three variables and two equations, and that \((4, 1, 0)\) and \((2, 4, 1)\) are solutions to this system. You are also given that the two equations define distinct planes in \(\mathbb R^3\). Write down the reduced echelon form of the augmented matrix for this system.
2. Linear Combinations
Determine if the given vector \(\mathbf v\) in each part is in the span of the following vectors.
\begin{align*} \mathbf v_1 = \begin{bmatrix}10 \\ -33 \\ -5 \\ -30 \\ -3\end{bmatrix} \qquad \mathbf v_2 = \begin{bmatrix}-47 \\ -1 \\ -2 \\ -25 \\ 24\end{bmatrix} \qquad \mathbf v_3 = \begin{bmatrix}31 \\ -34\\ 11 \\ 39 \\ 25\end{bmatrix} \qquad \mathbf v_4 =\begin{bmatrix}-14 \\ 22 \\ 12 \\ 42 \\ 3\end{bmatrix} \end{align*}If it isn't, write not in the span. If it is, write \(\mathbf v\) as a linear combination of the above vectors. In each case, you must also write the augmented matrix of the linear system you solved, but otherwise, you do not need to show your work.
2.1. (5 points)
2.2. (5 points)
3. Spans and Linear Equations
3.1. (5 points)
Find a linear equation in three variables whose point set is exactly1
\begin{align*} \mathsf{span} \left\{ \begin{bmatrix} 1 \\ 0 \\ -2 \end{bmatrix}, \begin{bmatrix} 1 \\ 1 \\ 1 \end{bmatrix} \right\} \end{align*}You must show your work.
3.2. (5 points)
Find a linear equation in three variables whose point set is exactly
\begin{align*} \left\{ \mathbf v + \begin{bmatrix} 2 \\ -3 \\ 2 \end{bmatrix} \ \text{where} \ \mathbf v \in \mathsf{span} \left\{ \begin{bmatrix} 1 \\ 1 \\ -5 \end{bmatrix}, \begin{bmatrix} 0 \\ 1 \\ -1 \end{bmatrix} \right\} \right\} \end{align*}In other words, every point in the point set of the equation can be expressed as the sum of \([2 \ \ (-3) \ \ 2]^T\) and a vector in the span of \([1 \ \ 1 \ \ (-5)]^T\) and \([0 \ \ 1 \ \ (-1)]^T\). You must show your work.
4. Solving Matrix-Vector Equations
(5 points) Write down the general form solution to the following matrix-vector equation. You do not need to show your work.
\begin{align*} \begin{bmatrix} 1 & 1 & 3 & 1 & -7 & 1 \\ -5 & -4 & -14 & -3 & 24 & -8\\ 0 & -2 & -2 & -3 & 21 & 3 \\ -6 & -3 & -15 & -2 & 11 & -8 \end{bmatrix} \mathbf x = \begin{bmatrix} 7 \\ -16 \\ -20 \\ -27 \end{bmatrix} \end{align*}5. Quadratic Interpolation
It is well known2 that any three distinct points in the plane define a unique quadratic equation. Given three points \((x_1, y_1)\), \((x_2, y_2)\) and \((x_3, y_3)\), the equation \(y = ax^2 + bx + c\) which passes through these three points is given by the solution to the following matrix equation.
\begin{align*} \begin{bmatrix} x_1^2 & x_1 & 1 \\ x_2^2 & x_2 & 1 \\ x_3^2 & x_3 & 1 \end{bmatrix} \begin{bmatrix} a \\ b \\ c \end{bmatrix} = \begin{bmatrix} y_1 \\ y_2 \\ y_3 \end{bmatrix} \end{align*}5.1. (5 points)
Convince yourself of the above fact. Then use it to determine the unique quadratic equation which passes through the points \((2, 13)\), \((3, 25)\) and \((-2, 5)\). You must also write down the augmented matrix of the linear system you solved.
5.2. (10 points)
Write down the RREF of the matrix
\begin{bmatrix} x^2 & x & 1 & y \\ 1 & 1 & 1 & 1 \\ \left(\frac{x + 1}{2}\right)^2 & \frac{x + 1}{2} & 1 & \frac{y + 1}{2} \end{bmatrix}in terms of \(x\) and \(y\), assuming \(x \not = 1\). Explain your answer. Hint: Don't try to row reduce it. It's not worth it.
6. A Small Interface (Programming)
We've mentioned in passing several times at this point that we could
implement everything in this course on our own. We won't generally do
this, but for the practice we're going to do it once. You're given
an interface for vectors and matrices in a file called matlib.py
.
Please read through this file carefully and make sure you understand
how these objects work. You're not allowed to change anything in this
file.
You're given starter code in the file hw03.py
. Please do not change
the name of this file when you submit it, nor the names of functions
included in the starter code. You may add your own functions, but you
are not expected to. You're only required to fill in the TODO items
in the starter code.
You're required to implement the following functions:
vec_scale(val, vec)
returns the result of scaling the vectorvec
by the floatval
vec_add(v1, v2)
returns the sum of the vectorsv1
andv2
. This function must raise an exception with message"DIMENSION MISMATCH"
if its inputs do not have the same number of entriesvec_inner(v1, v2)
returns the inner product of the vectorsv1
andv2
. This function must raise an exception with then message"DIMENSION MISMATCH"
if its inputs do not have the same number of entriesmat_vec_mul(a, v)
returns the product of the matrixa
times the vectorv
. This function must raise an exception with message"DIMENSION MISMATCH"
ifa
does not have the same number of columns asv
has entries
You'll upload the single python file hw03.py
to Gradescope with your
implementations of TODO items in the code. You won't have access to
the tests on Gradescope, but we'll provide a subset of the unit tests
which you can run yourself in a file called tests.py
. You can run
python -m unittest
to run these tests.