Unconstrained optimization

Consider an arbitrary function $f(x,y) = 10x -2x^2 + 20y - 5y^2$. Begin by setting up a worksheet like so:

In cell D6 enter the function as an argument of $x$ (cell B6) and $y$ (cell C6):

Next, go to Tools and select Solver. Then simply enter the cell you want to optimize (the one that contains the function, D6) and enter the cells that contain the function arguments (B6, C6):

Constrained optimization

Now suppose we want to optimize $f(x,y)$ subject to the constraint $x + y \leq 2$. Set up a new sheet in which the constraint is entered as a formula:

Re-run the Solver routine, this time adding the constraint: