Explain briefly the application of calculus to economic models, especially in the context of maximizing contribution and minimizing costs.