# Prove that these two formulas to calculate the angle between two 2D lines are equivalent

I've been working on an algorithm that includes a step in which it has to calculate the angle between two 2D lines.

I've done some research and I've found this formula:

$\tan \theta = \pm \frac{m_2 - m_1}{1 + m_1m_2}$,

in which $m_1$ and $m_2$ are the slopes of the lines written in the form $y = mx + b$.

I also found this formula:

$\tan \theta = \pm \frac{A_2 B_1 - A_1 B_2}{A_1 A_2 + B_1 B_2}$,

in which $A_1, A_2, B_1, B_2$ are the parameters of the lines written in the form $Ax + By + C = 0$.

According to one book I've found, both formulas are equivalent. I've tried to prove that they're equivalent, but haven't managed to get it right so far.

Can someone please point me in the right direction so I can prove that both formulas are equivalent?

Put the equations $A_1 x + B_1 y + C_1 = 0$ and $A_2 x + B_2 y + C_2 = 0$ into the form $y = mx + b$ to find $m_1$ and $m_2$ in terms of $A_1$, $B_1$, $A_2$, and $B_2$, then put those into $\tan \theta = \pm \frac{m_2 - m_1}{1 + m_1m_2}$.