Computing orthogonal projection

82 Views Asked by At

The question asks:

A vector u and a line L in R^2 are given, compute the orthogonal projection w of u on L.

u=[3,4] and y=-x

In one example i was given two vectors u and v but in another i was only given u. I know the equation to find w is

(dot product(u and v)/||v||^2) * v

But how do i find v when it is not provided?

2

There are 2 best solutions below

0
On

Given the line $L$ defined by some equation $y=f(x)$, we can find a vector which is parallel to it by considering two points, ${\bf a}$ and ${\bf b}$, which are on the line, and taking ${\bf v}={\bf b}-{\bf a}$. We can take any two points, but let's for simplicity consider the points ${\bf a}=(0,0)$ and ${\bf b}=(1,-1)$. Note that both points satisfy the equation $y=-x$, since $0=-0$ and $1=-1$, and thus must be on the line $L$.

Now, the vector ${\bf v}=(1,-1)-(0,0)=(1,-1)$ is parallel to $L$, so we can apply your formula with ${\bf u}=(3,4)$ and ${\bf v}$, yielding \begin{align} \frac{{\bf u}\cdot {\bf v}}{||{\bf v}||^2}{\bf v}=\frac{{\bf u}\cdot {\bf v}}{{\bf v}\cdot{\bf v}}{\bf v} = \frac{(3,4)\cdot (1,-1)}{(1,-1)\cdot(1,-1)}(1,-1) = -\frac{1}{2}(1,-1). \end{align}

Note that it doesn't matter which vector we use as ${\bf v}$, as long as it is parallel to $L$. In fact, any vector parallel to $L$ will just be some multiple of ${\bf v}$, so we can take ${\bf v}'=\alpha{\bf v}$ for any $\alpha\in\mathbb{R}$, and we will find that \begin{align} \frac{{\bf u}\cdot {\bf v}'}{||{\bf v}'||^2}{\bf v}'=\frac{{\bf u}\cdot {\bf v}'}{{\bf v}'\cdot{\bf v}'}{\bf v}' = \frac{(3,4)\cdot\alpha(1,-1)}{\alpha(1,-1)\cdot\alpha(1,-1)}\alpha(1,-1) = -\frac{\alpha^2}{2\alpha^2}(1,-1)=-\frac{1}{2}(1,-1). \end{align}

0
On

The line is described by $\{ t[1,-1] : t \in \mathbb{R} \}$. You need to find a point on the line $t[1,-1]$ so that $[3,4]-t[1,-1]$ is perpendicular to the line. Equivalently, $$ [3-t,4+t]\cdot[1,-1]=0 \\ (3-t)-(4+t)=0 \\ t=-1/2. $$ So the orthogonal projection of $[3,4]$ onto the line is $(-1/2)[1,-1]=[-1/2,1/2]$.