\documentclass{article}
\usepackage{a4wide}
\title{Bla}
\newcommand{\sign}{\mathop{\mathrm{sign}}}
\begin{document}
%\begin{abstract}
%We set out to find an efficient way to compute the angle bisector of two vectors.
%\end{abstract}
Let $\displaystyle\mathbf{a} = {a_x \choose a_y}$ and $\displaystyle\mathbf{b} = {b_x \choose b_y}$.
Define the inner product of two vectors
\[
\mathbf{a}\cdot \mathbf{b} \equiv a_x\cdot b_x + a_y\cdot b_y
\]
and the cross product of two vectors
\[
\mathbf{a}\times \mathbf{b} \equiv a_x\cdot b_y - a_y\cdot b_x.
\]
Now we can define the length of a vector
\[
\|\mathbf{a}\| \equiv \sqrt{\mathbf{a}\cdot \mathbf{a}}.
\]
If $\|\mathbf{a}\| \not= 0$ then we define
\[
\mathbf{\hat a} \equiv \frac{\mathbf{a}}{\|\mathbf{a}\|}.
\]
Finally we define
\[
\mathbf{a_\perp} \equiv {-a_y \choose a_x}.
\]
Also note that
\[
\|\mathbf{a}\|\cdot\|\mathbf{b}\| = \sqrt{(\mathbf{a}\cdot\mathbf{b})^2+(\mathbf{a}\times\mathbf{b})^2}.
\]

Assume that
$\|\mathbf{a}\| \not= 0$ and $\|\mathbf{b}\| \not= 0$. Angle $\theta$ is the angle between
$\mathbf{a}$ and $\mathbf{b}$, to be precise the angle to rotate $\mathbf{a}$ to get in the (positive) direction of $\mathbf{b}$ in a right-handed co\"ordinate system. The range of $\theta$ is thusly $0^\circ \le \theta < 360^\circ$.

%It is widely known that
%\[
%\cos(\theta) = \mathbf{\hat a}\cdot \mathbf{\hat b},
%\]
%and
%\[
%\sin(\theta) = \mathbf{\hat a} \times \mathbf{\hat b}.
%\]

Given the range of $\theta$ and the half angle formulas, we have $\cos(\theta) = \mathbf{\hat a}\cdot \mathbf{\hat b}$,
\[
\cos\left(\frac12\theta\right) =\sign(\sin(\theta)) \sqrt{\frac{1+\cos(\theta)}2} = \frac12\sqrt{2}\sign(\mathbf{a} \times \mathbf{b})\sqrt{1+\mathbf{\hat a}\cdot \mathbf{\hat b}},
\]
and
\[
\sin\left(\frac12\theta\right) = \sqrt{\frac{1-\cos(\theta)}2} = \frac12\sqrt{2}\sqrt{1-\mathbf{\hat a}\cdot \mathbf{\hat b}}.
\]
An angle bisector, $\mathbf{c}$, of $\mathbf{a}$ and $\mathbf{b}$ is therefore
\[
\mathbf{c} = \frac12\sqrt{2}\left(\sign(\mathbf{a} \times \mathbf{b})\sqrt{1+\mathbf{\hat a}\cdot \mathbf{\hat b}}\cdot\mathbf{a} + \sqrt{1-\mathbf{\hat a}\cdot \mathbf{\hat b}}\cdot\mathbf{a_\perp}\right).
\]
It is easy to show that $\|\mathbf{c}\| = \|\mathbf{a}\|$. Since we do not care
about the length of $\mathbf{c}$ we drop the factor $\frac12\sqrt{2}$ and
multiply with $\|\mathbf{a}\|\cdot\|\mathbf{b}\|\cdot\sqrt{1\pm\mathbf{\hat a}\cdot \mathbf{\hat b}}$. This results in $\mathbf{c}_\pm$. We get two very different answers
\[
\mathbf{c_-} = (\mathbf{a} \times \mathbf{b})\cdot\mathbf{a}+\left(\sqrt{(\mathbf{a}\cdot\mathbf{b})^2+(\mathbf{a}\times\mathbf{b})^2}-\mathbf{a}\cdot \mathbf{b}\right)\cdot\mathbf{a_\perp}
\]
and
\[
\mathbf{c_+} =
\sign(\mathbf{a} \times \mathbf{b})\left(\left(\sqrt{(\mathbf{a}\cdot\mathbf{b})^2+(\mathbf{a}\times\mathbf{b})^2}+\mathbf{a}\cdot \mathbf{b}\right)\cdot\mathbf{a}+(\mathbf{a} \times \mathbf{b})\cdot\mathbf{a_\perp}\right).
\]

If $\mathbf{b}=\pm\mathbf{a}$, we have $\mathbf{a}\times\mathbf{b} = \mathbf{0}$ and therefore $\mathbf{c_\mp} = \mathbf{0}$.
To be sure this does not lead to problems (also in the case  $\mathbf{b}\approx\pm\mathbf{a}$), use $\mathbf{c_+}$ if $\mathbf{a}\cdot\mathbf{b} \ge 0$ and $\mathbf{c_-}$ if $\mathbf{a}\cdot\mathbf{b} < 0$.

We can also calculate the length of $\mathbf{c}_\pm$
\[
\|\mathbf{c}_\pm\|=\sqrt{2(\mathbf{a}\cdot\mathbf{a})\sqrt{(\mathbf{a}\cdot\mathbf{b})^2+(\mathbf{a}\times\mathbf{b})^2}\left(\sqrt{(\mathbf{a}\cdot\mathbf{b})^2+(\mathbf{a}\times\mathbf{b})^2}\pm\mathbf{a}\cdot \mathbf{b}\right)}.
\]

%Another way to calculate $\mathbf{c}$. If $\mathbf{c}$ is an angular bisector then $\mathbf{\hat{a}}\cdot\mathbf{\hat{c}} = \mathbf{\hat{b}}\cdot\mathbf{\hat{c}}$ or
%$(\mathbf{\hat{a}}-\mathbf{\hat{b}})\cdot\mathbf{\hat{c}} = 0$. Let
%\[
%\mathbf{\hat{c}} = {{\hat{c}_x} \choose {\hat{c}_y}} =  {{\hat{c}_x} \choose \pm\sqrt{1-{\hat{c}_x^2}}}
%\]
%so we have
%\[
%(\hat{a}_x - \hat{b}_x)\cdot \hat{c}_x = \mp{(\hat{a}_y - \hat{b}_y})\cdot \sqrt{1-{\hat{c}_x^2}}.
%\]
%Then compute the square and solve for $\hat{c}_x^2$


\end{document}
