# Linear Algebra: Least Squares and vectors

1. Nov 27, 2005

### kamui8899

Hi, I was working on a problem and I can't figure out what I'm supposed to do.

It reads, find the vector in subspace S that is closest to v; write v as the sum of a vector in S and a vector in S^a; and find the distance from v to S.

S spanned by {(1,3,4)} v = (2,-5,1)

Ok, what I did was I used some equation to find a least squares solution to Ax = b, where b is v and A is S.

So I took S and multiplied it by (1,3,4) and obtained 26.

And I then multiplied v by (1,3,4) and obtained -17

So the equation became:

26x = -17

x = -17/26

So when I multiply what I obtained for x and the vector that spans S together, I should get the point closest to v in/on S right?

Now, to find v as a sum of a vector in S and a vector in S^a, I just did the gram schmidt process.

Its long so instead of writing it out I'll just give you my answer:
(1/156)(414,-474,-252)

This vector is orthogonal to the vector that spans S, the dot product is 0.

So, assuming all of that is correct, I reached the point where I have to tell how far v is from S. I know where they're closest, when the vector in S is multiplied by the constant we obtained for x (-17/26). I have an orthogonal vector to S, but what am I supposed to do now? How do I write v as a sum of vectors in S and S^a , and how do I find the distance?

Last edited: Nov 27, 2005
2. Nov 28, 2005

### HallsofIvy

Staff Emeritus
S is a subspace. How do you multiply a vector times a subspace??

?? The dot product of (1,3,4) and (2,-5,1) is 2- 15+ 4= -9.
I can't make heads or tails out of what you are doing. Since S is spanned by a single vector, it is a straight line in R3. What you are really doing is projecting v onto that straight line.
I suspect that when you say "So I took S and multiplied it by (1,3,4) and obtained 26" what you really did was take the dot product of (1,3,4) (I'm going to call that "u") with itself, getting 26 as the square of its length. Okay, you want that because the length of the projection of v onto S is the dot product of u with v divided by the length of v:
$$\frac{-9}{\sqrt{26}}$$.

The projection vector is a unit vector in the direction of (1,3,4), which is just (1,3,4) divided by $\sqrt{26}$ times that: That is
$$\frac{-9}{26}(1,3,4)= \left(\frac{-9}{26},\frac{-27}{26},\frac{-36}{26}\right)$$
I'm going to call that "w".
Since w is the orthogonal projection of v in S, v- w is orthogonal to S.
v-w=[itex]\left(2+\frac{9}{26},-5+\frac{27}{26},1+\frac{36}{26}\right)= \left(\frac{61}{26},-\frac{103}{26},\frac{62}{26}\right)[/tex]

The length of that vector is the "distance" from v to its orthogonal projection on S, w.