Solving for cotangent using trigonometric identities