Just look at the example lines shown in the figure.
Let us say the angle between x axis and the line black line is `alpha` .
Let us say the angle between x axis and the line red line is `beta` .
Let us say the small angle of intersection is `theta` .
Now if you apply the exterior angle theorem between `alpha` ,`beta` and `theta ` you will get;
`theta+alpha = beta`
Or in other words;
`theta = alpha-beta`
Let us say m1 is the gradient of the black line.
Let us say m2 is the gradient of the red line.
tanalpha = m1 --->`alpha = tan^(-1)(m1)`
tanbeta = m2 ---->`beta = tan^(-1)(m2)`
`theta = tan^(-1)(m1)-tan^(-1)(m2) ` ----(1)
Now move on to our question.
The gradients of the P and Q lines are p and q respectively.
`m1 = p`
`m2 = q`
`theta = 60`
so applying this data to (1) yields;
`60 = tan^(-1)(p)-tan^(-1)(q)`
Get the tan in both sides.
`tan60 = tan(tan^(-1)(p)-tan^(-1)(q))`
We know that;
`tan(A-B) = (tanA-tanB)/(1+tanAtanB)`
`tan60 = [tan(tan^(-1)(p))-tan(tan^(-1)(q))]/(1+tan(tan^(-1)(p))*tan(tan^(-1)(q)))`
`sqrt3 = (p-q)/(1+pq)`
`sqrt3*(1+pq) = p-q`