# Inverse Functions: Arctangent and Angle Between Two Lines (Part 25)

The smallest angle between the non-perpendicular lines $y = m_1 x + b_1$ and $y = m_1 x + b_2$ can be found using the formula

$\theta = \displaystyle \tan^{-1} \left( \left| \frac{m_1 - m_2}{1 + m_1 m_2} \right| \right)$.

A generation ago, this formula used to be taught in a typical Precalculus class (or, as it was called back then, analytical geometry). However, I find that analytic geometry has fallen out of favor in modern Precalculus courses.

Why does this formula work? Consider the graphs of $y = m_1 x$ and $y = m_1 x + b_1$, and let’s measure the angle that the line makes with the positive $x-$axis.

The lines $y = m_1 x + b_1$ and $y = m_1 x$ are parallel, and the $x-$axis is a transversal intersecting these two parallel lines. Therefore, the angles that both lines make with the positive $x-$axis are congruent. In other words, the $+ b_1$ is entirely superfluous to finding the angle $\theta_1$. The important thing that matters is the slope of the line, not where the line intersects the $y-$axis.

The point $(1, m_1)$ lies on the line $y = m_1 x$, which also passes through the origin. By definition of tangent, $\tan \theta_1$ can be found by dividing the $y-$ and $x-$coordinates:

$\tan \theta_1 = \displaystyle \frac{m}{1} = m_1$.

We now turn to the problem of finding the angle between two lines. As noted above, the $y-$intercepts do not matter, and so we only need to find the smallest angle between the lines $y = m_1 x$ and $y = m_2 x$.

The angle $\theta$ will either be equal to $\theta_1 - \theta_2$ or $\theta_2 - \theta_1$, depending on the values of $m_1$ and $m_2$. Let’s now compute both $\tan (\theta_1 - \theta_2)$ and $\tan (\theta_2 - \theta_1)$ using the formula for the difference of two angles:

$\tan (\theta_1 - \theta_2) = \displaystyle \frac{\tan \theta_1 - \tan \theta_2}{1 + \tan \theta_1 \tan \theta_2}$

$\tan (\theta_2 - \theta_1) = \displaystyle \frac{\tan \theta_2 - \tan \theta_1}{1 + \tan \theta_2 \tan \theta_1}$

Since the smallest angle $\theta$ must lie between $0$ and $\pi/2$, the value of $\tan \theta$ must be positive (or undefined if $\theta = \pi/2$… for now, we’ll ignore this special case). Therefore, whichever of the above two lines holds, it must be that

$\tan \theta = \displaystyle \left| \frac{\tan \theta_1 - \tan \theta_2}{1 + \tan \theta_1 \tan \theta_2} \right|$

We now use the fact that $m_1 = \tan \theta_1$ and $m_2 = \tan \theta_2$:

$\tan \theta = \displaystyle \left| \frac{m_1 - m_2}{1 + m_1 m_2} \right|$

$\theta = \tan^{-1} \left( \displaystyle \left| \frac{m_1 - m_2}{1 + m_1 m_2} \right| \right)$

The above formula only applies to non-perpendicular lines. However, the perpendicular case may be remembered as almost a special case of the above formula. After all, $\tan \theta$ is undefined at $\theta = \pi/2 = 90^\circ$, and the right hand side is also undefined if $1 + m_1 m_2 = 0$. This matches the theorem that the two lines are perpendicular if and only if $m_1 m_2 = -1$, or that the slopes of the two lines are negative reciprocals.