Write your solutions to the following problems either by writing them on a piece of paper or on a tablet and scanning your answers as a PDF. Note that you are not allowed to use LaTeX, Google Docs, or any other digital document creation software to type your answers. Homeworks are due to Pensive by 11:59PM on the due date. See the syllabus for details on the slip day policy.
Homework will be evaluated not only on the correctness of your answers, but on your ability to present your ideas clearly and logically. You should always explain and justify your conclusions, using sound reasoning. Your goal should be to convince the reader of your assertions. If a question does not require explanation, it will be explicitly stated.
Note: While working on the homework, have Chapters 1.4, 1.5, and 1.6 of the course notes open! They contain lots of relevant examples and explanations.
Problem 1: Homework 1 Solutions Review (8 pts)
Review the solutions to Homework 1. Pick two problem parts (for example, Problem 3a and Problem 5b) from Homework 1 in which your solutions have the most room for improvement, i.e., where they have unsound reasoning, could be significantly more efficient or clearer, etc. Include a screenshot of your solution to each problem part, and in a few sentences, explain what was deficient and how it could be fixed.
Alternatively, if you think one of your solutions is significantly better than the posted one, copy it here and explain why you think it is better. If you didn’t do Homework 1, choose two problem parts from it that look challenging to you, and in a few sentences, explain the key ideas behind their solutions in your own words.
Solution
Responses will vary. Look for specific comparisons with the posted solutions and clear explanations of how to improve the selected work.
Problem 2: Setting Ourselves Up (10 pts)
Given the following sets, translate the set notation into plain English and sketch a picture of what each set looks like in \(\mathbb{R}^2\) or \(\mathbb{R}^3\).
a)
(3 pts) \(\lbrace{}\begin{bmatrix} x\\y \end{bmatrix} \in \mathbb{R}^2 : x > 0, y < 0\rbrace{}\)
Solution
This is the set of all vectors in \(\mathbb{R}^2\) with a positive first coordinate and negative second coordinate. Shade the fourth quadrant, excluding both axes; draw the boundary rays dashed.
b)
(3 pts) \(\lbrace{}\begin{bmatrix} x\\y \end{bmatrix} \in \mathbb{R}^2 : x < 0, y \geq 3\rbrace{}\)
Solution
This is the set of vectors in \(\mathbb{R}^2\) with a negative first coordinate and a second coordinate at least \(3\). Shade the region to the left of the \(y\)-axis and on or above the line \(y=3\). Include the boundary \(y=3\) for \(x<0\) and exclude the boundary \(x=0\), including \((0,3)\); draw the horizontal boundary solid and the vertical boundary dashed.
c)
(4 pts) \(\lbrace{}\begin{bmatrix} x\\y\\z \end{bmatrix} \in \mathbb{R}^3 : x, z \in \mathbb{R}, y = -5\rbrace{}\)
Solution
This is the plane \(y=-5\) in \(\mathbb{R}^3\): the first and third coordinates can be any real numbers, and the second coordinate is always \(-5\). Sketch a plane parallel to the \(xz\)-plane passing through the point \((0,-5,0)\).
Problem 3: Add All Ingredients to the Bowl and Combine (8 pts)
A cake recipe uses three ingredients: sugar, flour, and milk. We represent the ingredients in one batch by a vector in \(\mathbb{R}^3\), using the order
$$ \begin{bmatrix} \text{sugar in tbsp}\\ \text{flour in cups}\\ \text{milk in tbsp} \end{bmatrix}. $$
Consider the following four recipe batches:
Recipe 1 uses \(2\) tbsp of sugar, \(1\) cup of flour, and \(3\) tbsp of milk.
Recipe 2 uses \(3\) tbsp of sugar, \(2\) cups of flour, and \(4\) tbsp of milk.
Recipe 3 uses \(4\) tbsp of sugar, \(2\) cups of flour, and \(6\) tbsp of milk.
Recipe 4 uses \(1\) tbsp of sugar, \(1\) cup of flour, and \(2\) tbsp of milk.
a)
(4 pts) Write vectors \(\vec{v}_1,\vec{v}_2,\vec{v}_3,\vec{v}_4\) representing the four recipes. Identify a relationship between two of the vectors and explain what that relationship means in the context of the recipes.
Since \(\vec{v}_3=2\vec{v}_1\), Recipe 3 is a double batch of Recipe 1, with the same ingredient proportions.
b)
(4 pts) Suppose you make two batches of Recipe 1, no batches of Recipe 2, three batches of Recipe 3, and two batches of Recipe 4. Write a linear combination representing the total ingredients used. Then determine the total amount of sugar, flour, and milk used.
(6 pts) Suppose the drone continues to travel another 10 meters in the same direction. What are its coordinates?
Solution
We divide the displacement by its length \(12\) to obtain the unit vector in the direction of \(\vec d\). Scale this unit vector by \(10\) and add the additional displacement to \(Q\), where the drone starts this part of its flight:
This ratio is called their cosine similarity: the dot product divided by the product of their lengths. To find the angle itself, take the inverse cosine of this ratio.
a)
(9 pts) For each pair below, draw the vectors, compute their dot product, and find their cosine similarity (i.e. the cosine of the angle between them). In which case are the vectors orthogonal?
Draw each vector as an arrow from the origin to its coordinates.
The dot products are \(0\), \(15\), and \(12\), respectively. The corresponding cosine similarities are \(0\), \(15/17\), and \(1\). Only the first pair is orthogonal.
b)
(6 pts) For each pair below, find all values of \(k\) that make \(\vec{u}\) and \(\vec{v}\) orthogonal.
Explain why equality holds exactly when the vectors point in the same or opposite directions. Finally, explain why the inequality also holds if either vector is zero. This inequality is called the Cauchy–Schwarz inequality.
Solution
Let \(\theta\) denote the angle between the vectors \(\vec u\) and \(\vec v\). Then since \(|\cos\theta|\leq1\),
For nonzero vectors, equality holds exactly when \(|\cos\theta|=1\), so \(\theta=0^\circ\) or \(180^\circ\): the vectors point in the same or opposite directions. If either vector is zero, both sides of the inequality are zero.
Lengths are nonnegative. A negative scalar reverses direction, but scales length by its absolute value.
c)
(4 pts) Find the cosine similarity of \(\vec{u}\) and \(\vec{v}\). Then find the cosine similarity of \(-2\vec{u}\) and \(3\vec{v}\). If the two cosine similarities are different, why are they different?
The cosine similarities differ because multiplying \(\vec{u}\) by \(-2\) reverses its direction, while multiplying \(\vec{v}\) by \(3\) preserves its direction. Reversing exactly one vector changes the sign of the cosine similarity; the positive scaling factors cancel between the numerator and denominator.
d)
(2 pts) Find \(\vec{u}\cdot\vec{u}\) and \(\vec{v}\cdot\vec{v}\).
Solution
A vector’s dot product with itself is its squared length, so
(5 pts) Find \(\lVert \vec{u}+\vec{v} \rVert\). Is it equal to \(\sqrt{\lVert \vec{u} \rVert^2+\lVert \vec{v} \rVert^2}\)? Explain what condition would make these quantities equal.
Hint: Start by writing \(\lVert\vec{u}+\vec{v}\rVert^2\) as \((\vec{u}+\vec{v})\cdot(\vec{u}+\vec{v})\). Then, expand this as we did in Chapter 1.6.
Thus \(\lVert \vec{u}+\vec{v} \rVert=\sqrt{17}\), whereas \(\sqrt{\lVert \vec{u} \rVert^2+\lVert \vec{v} \rVert^2}=\sqrt{13}\). The quantities are equal exactly when \(\vec{u}\cdot\vec{v}=0\), meaning the vectors are orthogonal.
Problem 8: Triangle Inequality (6 pts)
In Chapter 1.5, we stated the triangle inequality without proof. Intuitively, the triangle inequality says that for any triangle (even in \(\mathbb{R}^n\)), the length of any side of the triangle is less than or equal to the sum of the lengths of the other two sides. Here, we’ll prove the triangle inequality using the Cauchy–Schwarz inequality, established in Problem 6c.
a)
(4 pts) Let \(\vec{u},\vec{v}\) be any two vectors in \(\mathbb{R}^n\). Show that
Both \(\lVert \vec{u}+\vec{v} \rVert\) and \(\lVert \vec{u} \rVert+\lVert \vec{v} \rVert\) are nonnegative. Taking square roots preserves the inequality from part (a), giving \(\lVert \vec{u}+\vec{v} \rVert\leq\lVert \vec{u} \rVert+\lVert \vec{v} \rVert\).
Problem 9: Programming Activity (15 pts)
Most homeworks and some labs will have a Jupyter Notebook, containing Python code that supplements our understanding of the relevant mathematical ideas of the week.
You won’t need to submit the notebook anywhere. To get credit for the work you did in this notebook, include the following in your PDF submission to Homework 2 on Pensive, specifically under Problem 9:
1.
Task 1: A screenshot of your three word-count arrays and their output.
2.
Task 2: A screenshot of your completed cosine similarity function and the outputs of the three example calls.
3.
Task 3: A screenshot of the three document comparisons and your written answer identifying the most similar pair.
4.
Task 4: Your written responses to all three prompts.