Projecting functions onto planes

1.8k Views Asked by At

I understand the concept of projecting vectors onto the span of a vector but I'm having trouble projecting functions i.e How would I project the function cos(x) onto the vector that spans (1,1)?

1

There are 1 best solutions below

2
On BEST ANSWER

You have a function $y=f(x)$ and want to rotate the graph by angle $\theta$ use a rotation matrix. For your example, you want to rotate by $-\pi/4$.

Start with a point on your graph $\mathbf{x}=(x,f(x))$ and use the rotation matrix: $$ R(\theta)=\left[\begin{array}{cc} \cos\theta & -\sin\theta\\ \sin\theta & \cos\theta \end{array}\right]. $$ You desired "projection" is multiplication of the matrix and vector $R(\theta)\mathbf{x}$.

For example, if $f(x)=x+1$ and we want to project onto the 45 degree diagonal line:

$$ \frac{\sqrt{2}}{2}\left[\begin{array}{cc} 1 & 1\\ -1 & 1 \end{array}\right]\cdot \left[\begin{array}{cc} x\\ x+1 \end{array}\right] =\frac{\sqrt{2}}{2} \left[\begin{array}{cc} 2x+1\\ 1 \end{array}\right]. $$ These are the new coordinates. For example the point $(0,1)$ gets projected onto $(\frac{\sqrt{2}}{2},\frac{\sqrt{2}}{2})$.

Note that this isn't really a true "projection". For example, rotating the graph of $\cos(x)$ by $90^\circ$ is very different from projecting it onto the $y-$axis!

Now if you want to do a "true orthogonal projection", here is a method that should work. We are going to use the above method to rotate, then we'll take only the first coordinate of the rotation. This will be the distance from the origin along the line that we want to project on.

Let's say that $(x,f(x))$ gets rotated to $(m(x),n(x))$ using the method above. We only need the $m(x)$ coordinate as that is the location along the line in the perpendicular direction from the graph of the function $f$. We know the coordinates of the point on the line is given by $(c,\frac{b}{a}c)$ for some $c$ (so long as $a\neq0$). We can use the Pythagorean theorem to solve for $c$:

$$ c=\frac{a}{\sqrt{a^2+b^2}}m(x) $$ so long as $a\neq0$.

For example, $f(x)=\cos(x)$, if we want to project it onto the $y-$axis, then we can rotate it $-90^\circ$:

$$ \left[\begin{array}{cc} 0 & 1\\ -1 & 0 \end{array}\right]\cdot \left[\begin{array}{cc} x\\ \cos(x) \end{array}\right] =\left[\begin{array}{cc} \cos(x)\\ -x \end{array}\right]. $$

We only want the $\cos(x)$ part (the new "horizontal" coordinate relative to the line's orientation. But this is an easy case since we are done as this is just our new $y$ coordinate and the $x$ coordinates are all zero. We are on the $y-$axis! So this is a bit trivial when $a=0$. The point $(x,\cos(x))$ gets projected onto $(0,\cos(x))$.

Let's project $f(x)=x^2$ onto the line given by $-30^\circ$. So we want to rotate our graph by $30^\circ$. This gives us $m(x)=(x\sqrt{3}-x^2)/2$ as the position along our oriented line. Converting that into standard Euclidean coordinates gives the mapping:

$$ (x,f(x)) \longrightarrow (c,\frac{b}{a}c) \\ (x,x^2) \longrightarrow \frac{1}{4}\left( x-\sqrt{3}x^2, -\sqrt{3}x+x^2 \right) $$

Note that starting at the origin and going along the curve $f(x)=x^2$, the projection initially moves along the line into the IV$^{th}$ quadrant but then turns around and goes towards infinity in the II$^{nd}$ quadrant.

There is probably an easier way to do this, but this seems to work. You can plot a graph of the function and the line and rotate it to convince yourself it seems right.