Solving equations with cosine function