Calculating cotangent from a given trigonometric equation