Optimal algorithms for integrating convex functions