<s>[INST] How to find a vector component from another vector and the angle between the two vectors? I have two vectors, $(-2, 3, 1)$, and $(-1, 2, a)$. I know that the angle between these two vectors is $40^\circ$. How do I find a?
When I try to algebraically solve for a, I run into problems with the magnitudes. I understand that $X \cdot Y = |X| |Y| cos(Z)$. The problem is the magnitude of $Y$ in this case turns out to be $\sqrt{5 + a^2}$, and the dot product of $X$ and $Y$ is a + 8, so I can't figure out how to resolve the two to find a.
$a + 8 = \sqrt{14} \cdot \sqrt{5 + a^2} \cdot \cos(40^\circ)$
 [/INST] We know that the scalar product is defined as:
$$\mathbf{v}\bullet \mathbf{u}=vu\cos \theta\equiv v_xu_x+v_yu_y+v_zu_z$$
i.e.
$$\sqrt{14}\cdot \sqrt{5+a^2}=\frac{8+a}{\cos(40^{\circ})} \iff \sqrt{14\cdot (5+a^2)}=\frac{8+a}{\cos(40^{\circ})}$$
Hence, squaring LHS and RHS,
$$70\cos ^2\left(40^{\circ}\right)+14\cos ^2\left(40^{\circ }\right)a^2=64+16a+a^2$$
and the solution are (equation of second degree or quadratic formula), being the $70+14a^2>0, \, \forall a\in \Bbb R$,
$$a_1=\frac{-16+\sqrt{-3920\cos ^4\left(40^{\circ}\right)+3864\cos ^2\left(40^{\circ}\right)}}{2\left(1-14\cos ^2\left(40^{\circ}\right)\right)}, $$ $$a_2=-\frac{\sqrt{-3920\cos ^4\left(40^{\circ}\right)+3864\cos ^2\left(40^{\circ}\right)}+16}{2\left(1-14\cos ^2\left(40^{\circ }\right)\right)}$$
</s>