This paper combines Calculus and Programming to solve constrained optimization problems common in many areas, notably in Economics. It uses Lagrange multipliers, a well-known technique for maximizing (or minimizing) functions, and the free open-source mathematics software system Sage to compute the maximum (minimum) automatically. Moreover, Sage can be used interactively to work out the solution and to graphically interpret the results, which we find a valuable and practical approach in teaching such techniques to the undergraduate level. In this paper we carry out an exercise describing how these three interdisciplinary areas can work together