Finding a formula for a trigonometric function