# Shortest Vector for which Dot Product = x + 2y = 5. (Strang P21 1.2.26)

If $\vec{v} = (1,2)$ draw all vectors $\vec{w} = (x,y)$ in the plane $x,y$ with $\vec{v}\cdotp\vec{w} = x + 2y = 5$. Which is the shortest $\vec{w}$?

I draw the graphic. I believe is about (1,2) by looking and testing some values. However math isn't about believing. What is the proper way to think about this exercise. I'm just starting with linear algebra (self-study) so any algebraic method is great.

Source: Ex 1.2.26, P21, An Introduction to Linear Algebra, 4th Ed, by Gilbert Strang

-

Well since your vector $\vec{w}$ is only defined by it's coordinates $x$ and $y$ and since those variables are defined by $x+2y=5$ you have:

$x=5-2y$ and thus $\|\vec{w}\|^2=x^2+y^2=(5-2y)^2+y^2=25+4y^2-20y+y^2$

So:

$$\|\vec{w}\|^2=5(y^2-4y+5)=f(y)$$

Derive $f$ and you get $f'(y)=5(2y-4)=10(y-2)$. Clearly this equals $0$ when $y=2$. So your minimum norm $\vec{w}$ vector is for $y=2$ which gives you $x=5-2\times 2=1$.

So it's indeed as you thought $\vec{w}=\left(\begin{array}{cc} 1 \\ 2 \end{array}\right)$

-
(+1) Of course, there's no real need to take the derivative. Simply rewrite in vertex form as $$f(y)=5(y-2)^2+5.$$ –  Cameron Buie Apr 17 '13 at 15:26
@CameronBuie Yes, I like yours better ! –  Dolma Apr 17 '13 at 15:29
Thanks. Although I didn't derive since college this is a great and simple way to solve the problem (more than the calculus-free approach that @user12477 proposed). +1 –  Randolf R-F Apr 17 '13 at 15:36
You're welcome. And well yes this is a pretty straightforward way of looking at the problem. But I find @user12477's solution quite nice (elegant). –  Dolma Apr 17 '13 at 15:39

A calculus-free approach: the dot product formula tells us that $$\vec{v}\cdot\vec{w}=|\vec{v}| |\vec{w}|\cos\theta,$$ where $|\vec{v}|$ is the length (norm) of $\vec{v}$, $|\vec{w}|$ is the length of $\vec{w}$ and $\theta$ is the angle between the two vectors. Noting that $|\vec{v}|=\sqrt{5}$ and using $\vec{v}\cdot\vec{w}=5$ gives $$|\vec{w}| = \frac{\sqrt{5}}{\cos\theta}.$$ Can you see what value of $\theta$ will make this smallest? From there, you can figure out $\vec{w}$.

-
(+1) Well, clearly $\theta=\pi$ makes it the smallest, but that's nonsense. ;-) –  Cameron Buie Apr 17 '13 at 15:37
Although I can see your point and thank you for that (+1) these seem like a long workaround. But thanks. –  Randolf R-F Apr 17 '13 at 15:39

We minimize the square of the norm of $w$: $x^2+y^2$ with the constraint $x+2y=5$ $$f(y)=x^2+y^2=(5-2y)^2+y^2=5y^2-20y+25$$ so $$f'(y)=10y-20=0\iff y=2$$ hence $w=(1,2)$

-
It's actually $5y^2-20y+25$ not $-10y$ ;) –  Dolma Apr 17 '13 at 15:17
@Dolma thanks for your comment. –  Sami Ben Romdhane Apr 17 '13 at 15:18
And $\left(\begin{array}{cc} 3 \\ 2 \end{array}\right)$ doesn't have the property $x+2y=5$ ;) –  Dolma Apr 17 '13 at 15:20
@Dolma You're right I corrected the typo thanks again –  Sami Ben Romdhane Apr 17 '13 at 15:21
Yes sorry I've seen it after my comment was posted. You're welcome –  Dolma Apr 17 '13 at 15:22
The simplest way to find the shortest vector $(x,y)$ that satisfies $x+2y=5$ is to substitute, say, $x=5-2y$, and observe that you actually want to minimize $\sqrt{x^2+y^2}$, which is the same as minimizing $x^2+y^2=(5-2y)^2+y^2=25-20y+5y^2=5(y^2-4y+5)$.
Minimizing this is simple: $f(y) = y^2-4y+5$ is a parabola in $y$ facing up, so it has a minimum where the derivative is $0$.
$$f^\prime(y)=0$$ $$2y-4=0$$ $$y=2$$
Which you can substitute back to get $x=1$.
Same for you, the coefficient of $y$ is $-20$ and not $-10$. –  Dolma Apr 17 '13 at 15:20