$$ \newcommand{\RR}{\mathbb{R}} \newcommand{\QQ}{\mathbb{Q}} \newcommand{\CC}{\mathbb{C}} \newcommand{\NN}{\mathbb{N}} \newcommand{\ZZ}{\mathbb{Z}} \newcommand{\EE}{\mathbb{E}} \newcommand{\HH}{\mathbb{H}} \newcommand{\SO}{\operatorname{SO}} \newcommand{\dist}{\operatorname{dist}} \newcommand{\length}{\operatorname{length}} \newcommand{\uppersum}[1]{{\textstyle\sum^+_{#1}}} \newcommand{\lowersum}[1]{{\textstyle\sum^-_{#1}}} \newcommand{\upperint}[1]{{\textstyle\smallint^+_{#1}}} \newcommand{\lowerint}[1]{{\textstyle\smallint^-_{#1}}} \newcommand{\rsum}[1]{{\textstyle\sum_{#1}}} \newcommand{\partitions}[1]{\mathcal{P}_{#1}} \newcommand{\erf}{\operatorname{erf}} \newcommand{\ihat}{\hat{\imath}} \newcommand{\jhat}{\hat{\jmath}} \newcommand{\khat}{\hat{k}} \newcommand{\pmat}[1]{\begin{pmatrix}#1\end{pmatrix}} \newcommand{\smat}[1]{\left(\begin{smallmatrix}#1\end{smallmatrix}\right)} $$

Assignment 2

This assignment concerns the topics covered in Operations and Shapes

Dot Products and Image Processing

You are writing software to deal with images on a smartphone, and hope to automatically sort similar photos into groups to make things more convenient for the user. Internally to the phone, assume that a photo is stored as an ordered array of numbers representing the color of each pixel (as three numbers, one for each of red, green and blue). The picture below shows how a very simple \(2\times 2\) pixel image is represented as a list of 12 numbers, which is a vector in \(\mathbb{R}^{12}\).

Pixels in an image as components of a vector.

While it is very difficult to teach a computer how to understand the content of a photograph from the values of its pixels, it is easy to perform vector operations on a photograph since they are stored as arrays of numbers. In particular, its possible to measure the magnitude of a photograph stored as the vector \(\langle p_1,p_2,p_3,p_4,\ldots,p_n\rangle\) using the \(n\)-dimensional Pythagorean theorem, and the dot product between this image and another \(\langle q_1,q_2,\ldots, q_n\rangle\) is computed as \(\vec{p}\cdot \vec{q}=\sum_{i=1}^np_iq_i\).

Say that your software recieves three new photographs taken by the phone, call them photos \(A=\langle a_1,\ldots a_n\rangle\), \(B=\langle b_i\rangle\) and \(C=\langle c_i\rangle\). The computer immediately computes the following quantities: \[|A|=1050 \hspace{1cm} |B|=2040 \hspace{1cm} |C|=3012\] \[A\cdot B = 1,934,567 \hspace{1cm} B\cdot C = 143 \hspace{1cm} A\cdot C = -192,456\]

Exercise 1 Which two photos do you think are of the same object? Why? (Hint: can you figure out the ‘angle’ between these images in high dimensional space?). When you write your answer, show your work and explain what you are doing in full sentences where necessary so a classmate could easily follow your solution.

Planes and Perpendicularity

Exercise 2 In three dimensions, any two planes that are not parallel intersect each other in a line. If \(3x+2y-z=4\) and \(x-z=16\) are two such planes, find a vector \(\vec{v}\) that is parallel to the line they intersect in.

Hint: can you find a vector that is perpendicular to each plane? How can you use these to find a third vector which is parallel to both planes?

Two planes intersecting along a line in 3 dimensional space.

When you write your answer, show all your work and what you are doing in full sentences where necessary to make it so a classmate could easily follow your solution.

Shapes

Exercise 3 The plane \(y=3\) intersects the sphere \(x^2+y^2+z^2-2x-4y+1=0\) in a circle. What’s the radius of this circle?

When you write your answer, show all your work and what you are doing in full sentences where necessary to make it so a classmate could easily follow your solution. You should not just tell me the number, or give me a few lines of unjustified algebra!

Hint: If all points on the plane have their \(y\) coordinate equal to 3, then every point on the circle we are interested in also has \(y=3\)…can you use this to get an equation only in terms of \(x\) and \(z\)?

A sphere intersects a plane in a circle.

Solutions

Dot Products and Image Processing

Using the relationship of dot products and angles, we can figure out what the angle between each pair of images are. To label them, I’ll write \(\theta_{AB}\) for the angle between \(A\) and \(B\), and so on:

\[\cos\theta_{AB}=\frac{A\cdot B}{\|A\|\|B\|}\] \[\cos\theta_{BC}=\frac{B\cdot C}{\|B\|\|C\|}\] \[\cos\theta_{AC}=\frac{A\cdot C}{\|A\|\|C\|}\]

We know all the quantities on the right hand side here from the problem statement, so finding the inverse cosine of these on a calculator we get the below: I’ve computed them in degrees as that’s a more intutitive unit for some people: \[\theta_{AB}=25.4235^\circ\] \[\theta_{BC}=89.9986^\circ\] \[\theta_{AC}=91.7948^\circ\]

When are two points near each other in space, if all we know is the angle between them? Its easiest to think about real life - if you point at two locations in the distance, are those two places close to eachother if your arms are making a small angle, or a big angle? A small angle! So, the images that are closest to one another in the space of images are those with a small angle between them as viewed from the origin. The vectors \(A\) and \(B\) are only a 25 degree angle apart, whereas the other two pairs are almost orthogonal to one another. Thus, \(A\) and \(B\) must be two images of the same thing, and \(C\) is an image of something very different!

Planes and Perpendicularity

Given the planes \(3x+2y-z=4\) and \(x-z=16\), we can easily find a normal vector to each of them by the vector of coefficients: for the first plane, this is the vector \(n_1=\langle 3, 2, -1\rangle\) and for the second plane, this is \(n_2=\langle 1, 0,-1\rangle\).

This is of course not what we want in the end at all! We want a vector that lies in both planes. But here’s the trick: if you can find a vector \(v\) which is perpendicular to \(n_1\), then its perpendicular to the vector that’s perpendicular to everything in Plane 1: it must be in plane 1! (This is like the vector calculus version of “the enemey of my enemy is my friend: the perpendicular of my perpendicular is my parallel”).

So - any perpendicular to \(n_1\) is parallel to plane 1, and any perpendicular to \(n_2\) is parallel to plane 2. So, if we could find a vector perpendicular to both of these, we would have a vector parallel to both planes! And we have a tool to do exactly this: the cross prodcut

\[n_1\times n_2= \left| \begin{matrix}\ihat &\jhat &\khat\\ 3 & 2 &-1\\ 1 & 0 & -1 \end{matrix}\right|\]

\[=\ihat \left|\begin{matrix}2&-1\\0&-1\end{matrix}\right|-\jhat\left|\begin{matrix}3&-1\\1&-1\end{matrix}\right|+\khat\left|\begin{matrix}3&2\\1&0\end{matrix}\right|\]

\[=-2\ihat +2\jhat -2\khat =\langle -2,2,-2\rangle\]

This is a vector thats parallel to both planes.

Shapes

Every point on the plane \(y=3\) has its \(y\) coordinate…equal to 3! So, to intersect this plane with our sphere we can plug \(y=3\) into the equation for the sphere, to get an equation taking place just in the \(xz\) plane: \(x^2+3^2+z^2-2x-4(3)+1=0\). Simplifying this, we see the circle we are interested in is \[x^2-2x+z^2=2\]

To figure out what the radius of this circle is, we need to write it in standard form: something like \((x-h)^2+(z-k)^2=r^2\): then we could just read off the radius \(r\). Thus - we’ll need to complete the square.

Looking at just the \(x\)’s, we have \(x^2-2x\). We can see that if we had \(x^2-2x+1\) it would factor as \((x-1)^2\), so we can do a little trick of adding zero in a clever way:

\[\begin{align*} x^2+2x&=x^2-2x+(1-1)\\ &=(x^2-2x+1)-1\\ &=(x-1)^2-1 \end{align*}\]

Substituting this back into the main equation, we see \[x^2-2x+z^2=(x-1)^2-1+z^2=2\]

Putting all the constants on one side we have managed to reach standard form \[(x-1)^2+z^2=3\] so the radius is \(r=\sqrt{3}\).