If tanθ=p2−q22pq, then
tanθ=p2−q22pq⇒2tanθ21−tan2θ2=p2−q22pq⇒4pqtanθ2=(p2−q2)−(p2−q2)tan2θ2⇒(p2−q2)tan2θ2+4pqtanθ2−(p2−q2)⇒tanθ2=−4pq±√16p2q2+4(p2−q2)22(p2−q2)=−4pq±2(p2+q2)(p2−q2)=(p−q)2(p2−q2)−(p+q)2(p2−q2)
=p−qp+q or −(p+q)p−q
And ⇒cotθ2=1tanθ2=p+qp−q or p−q−(p+q)