Optimal approximation of functions