Let line be defined by the equation , and be defined by the equation . So long as these lines are not parallel lines (in which case the "angle bisector" does not exist), these two lines intersect at some point .
Note that this defines two separate angles (but not four, as two pairs of vertical angles are equal): and . Let be the angle bisector of , and be the angle bisector of . Then,
(the angle bisector which lies on the side of the origin) can be defined by the equation
(the angle bisector which doesn't lie on the side of the origin) can be defined as
Notice that these equations are practically identical; one is simply the "negative" of the other. This is not surprising, since the two angle bisectors are necessarily perpendicular lines.
Let be the angle bisector of , and let be a point on this bisector. Let and be the feet of the two perpendiculars from to and , respectively. Then triangles and are congruent and equal in all respects. Hence, .
By the distance between point and line formula,
WLOG, suppose that lies on the same side of as the origin does else, swap and . Note that this implies and will have same sign as and will have, respectively. Assume that and have the same sign else, again swap and , so that and both have the same sign. Thus
for all . It is much easier to show that all satisfying the above lie on by reversing the steps, so the equation of is precisely the above, as desired.
In the alternative cases, the sign of and would be different, so
which gives the equation of , as desired.
Suppose we have a pair of lines
which can be written in form of , where and . We denote the angles between and , and the -axis, respectively, by and . The two angle bisectors, one external and one internal, are perpendicular to each other. So the angles between the internal and external angle bisectors and the -axis can be expressed by and , respectively.
Now, recall the following trigonometric identity:
Using this relation,
Suppose there is a point on one of the angle bisector in red below, and call the angle of the bisector with respect to the -axis
Again, using the above trigonometric relation,
Equating and gives
But what if the two angle bisectors don't intercept at the origin? This is a simple matter by using only the secondary equation of lines. First, relocate the origin at , with respect to new origin, then the coordinates of a point are now , which is . On substituting, we get
Expanding it is left as an exercise for you. Remember that its expansion is in form of . Check whether
is zero to confirm that the equation given is a pair of lines.