# Optimization

Many economic problems are concerned with **optimizing** something. This can mean *maximizing* something desirable like utility, or social welfare, or *minimizing* something undesirable like expense or risk. It can also mean *balancing* costs and benefits. In this Appendix we’ll quickly review the mathematics of finding the maxima and minima of a function using calculus.

For the purpose of this analysis, we will constrain ourselves to think about functions which take either a real number $x$ or a vector $\vec x = (x_1,x_2,…)$ and return a real number $y$ as an outputWe will therefore be interested with finding the value of $x$ or $\vec x$ that maximizes or minimizes $y$.

If $y$ is a function of a single variable $x$, we can plot the relationship between $x$ and $y$ as a curve in a two-dimensional plane. For example, if we plot the function \(y = f(x) = 24x-6x^{2}-8x^{3}+3x^{4}\) we get the following graph:

As you can see, there are two *local minima*, at $x = -1$ and $x = 2$. Of these, the one at $x = -1$ is also a *global minimum*, because there is no value of $x$ for which $f(x) < f(-1)$. There is no global maximum, because the function increases as $x$ becomes very large or very small.

If $y$ is a function of two variables, we can plot the relationship between $x_1$, $x_2$, and $y$ as a surface in a three-dimensional plot. For example, if we plot the function \(y = f(x_1,x_2) = 8x_1 - 2x_1^2 + 8x_2 - x_2^2\) we get the following surface:

This has a global maximum at $\vec x = (2,4)$, at which point $y = f(2,4) = 24$.

The process of finding maxima or minima is optimization: maximization when you’re trying to maximize something good like utility, and minimization when you’re trying to minimize something bad like cost.

There are are two key kinds of optimization we’re be interested in: unconstrained optimization and constrained optimization.