Optimization in Function Spaces