Assuming that we're talking about lines in the 2D space:

now using the fact that the slope of the line equals the tangent of the angle between the line and the positive x axis:

using the following well known trigonometric identity:

we get:

now let's look at the following diagram:

thus:

combined with the previous identity this proves the equality.