Solving Recurrence Relations using Machine Learning, with Application to Cost Analysis