Some elementary calculus and trigonometry are required here and some perseverance. You should expect the final answer to be an expression symmetric in a and b.