Solving equations involving trigonometric functions