Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Suppose I have 2 vectors $\vec{a}= (5,1)$ and $\vec{b}= (2,4)$. I want to compute the angle between them.

See my calculations below. Supposedly the answer is $35.18^{\circ}$ degree but my answer as seen below is not.

I use my calculations using C# .Net

 double scalarProduct = a1 * b1 + a2 * b2;
 double sqrA = Math.Pow(a1,2) + Math.Pow(a2,2);
 double sqrb = Math.Pow(b1, 2) + Math.Pow(b2, 2);
 double v = Math.Cos(scalarProduct/(Math.Sqrt(sqrA*sqrb)));

What went wrong?

share|improve this question
2  
$v$ should be the inverse cosine of that number, not the cosine. –  Gerry Myerson May 8 '12 at 3:47
4  
There are numerous issues here. First, you state originally that $$a=\binom 5 2 \text{ and } b=\binom 1 4$$ but that is not what you have in your image. Also, in the last line you should have taken the inverse of the cosine rather than the cosine. This returns the answer in radians in most implementations, which you would then need to convert to degrees. –  Alex Becker May 8 '12 at 3:48
    
@Alex: That comment is of answer quality! –  The Chaz 2.0 May 8 '12 at 4:16
    
My mistake it should be a = 5,1 b = 2,4. I'll edit. –  mcxiand May 8 '12 at 4:18
    
I did calculate it using inverse of the cosine and the answer to degrees however my answer is 52.125... What is really the answer to this? Thanks. –  mcxiand May 8 '12 at 4:24
show 3 more comments

1 Answer

up vote 3 down vote accepted

In the last line, you should take the inverse cosine of both sides rather than the cosine, which gives $$v=\cos^{-1}(\cos(v))=\cos^{-1}\left(\frac{14}{\sqrt{26}\cdot \sqrt{20}}\right)=.90975$$ which can be converted to degrees by multiplying by $\frac{180^\circ}{\pi}$, giving $52.13^\circ$.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.