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:
now let's look at the following diagram:
combined with the previous identity this proves the equality.