This post will deal with utility, an important concept in economics, and a few optimization problems.

**Utility** is a measurement of the worth, usefulness, or value of a resource to an individual or organization. Utility is sometimes measured in dollars, but in this post it will be measured in "utils," an arbitrary and non-standardized unit of measurement, for reasons that will be explained in a moment. As one’s supply of a resource increases, the utility of the most recently obtained unit of the resource is called its **marginal utility**.

Suppose that you have a certain amount of a resource - donuts, for instance. Let’s say that having one donut is worth $10 \space\text{util}$ of happiness to you. But if you get a second donut, will you now have $20\space\text{util}$ of happiness from your donuts? The answer is no, because donuts, like any other resource, possess “value” relative to the wealth of a buyer. This becomes more apparent if we suppose instead that you already own $1,000,000$ donuts and gain one more - the next donut will be negligible and insignificant, while the first is probably the most significant.

This reasoning leads to **the law of diminishing marginal utility**, which states that as one stocks up on a resource, the marginal utility of each unit decreases as the number of units increases. In other words, as one continues to purchase quantities of a resource, one’s total utility will increase at a decreasing rate. This phenomenon, as well as describing an individual’s decreasing appetite for donuts, explains the well-known thought experiment in which a pauper scrounges for pennies on the street while a wealthy businessman strides past a $100$-dollar bill on the sidewalk without bothering to pick it up.

Of course, one typically aspires to *maximize* one’s utility, so let’s consider the following utility-maximization problem. The numbers in the chart below indicate the *total* utility that would result from buying a certain amount of either good. For example, buying four donuts and five bagels would result in a total utility gain of $28 + 16=44$ utils.

Since the total utility derived from buying donuts and bagels follows the law of diminishing marginal utility - that is, it is increasing at a decreasing rate for both donuts and bagels - we may use a *greedy* strategy to maximize our utility. By a *greedy strategy*, I mean one in which we systematically opt for whatever choice will benefit us the most. To make this easier to see, here is a table of the *marginal utility* of each quantity of donuts and bagels, rather than the *total utility.*

Suppose both donuts and bagels cost one dollar apiece, and we have a fixed budget of (say) five dollars. First, we buy a donut because the first donut is worth $10$ utils while the first bagel is only worth $4$ utils. By similar reasoning, we buy a second donut, and then a third. At this point, a fourth donut and a first bagel are equally valuable, and our choice does not matter - so we make a random choice, and pick a bagel. At this point, we have spent four dollars on three donuts and one bagel. We are faced with the same decision again since the second bagel is worth the same amount as the first, so we make another arbitrary choice - a donut, this time. Now we have bought four donuts, one bagel, and gained $32$ utils in all. Not bad!

Now let’s consider a slightly different scenario. This time, suppose that bagels cost one dollar apiece, but donuts cost *two dollars each.* It would be unwise to use the same strategy as before, since donuts now have a higher cost. Instead of comparing the marginal utility of the next donut to the marginal utility of the next bagel, we should compare their marginal utilities *divided by their respective costs.* This is like comparing the marginal utility per dollar spent on donuts against the marginal utility per dollar spent on bagels.

Suppose we have a budget of seven dollars this time. Our first choice is between a two-dollar donut offering $5$ utils per dollar and a one-dollar bagel worth $4$ utils per dollar, and we choose the donut. Next, both the donut and the bagel offer $4$ utils per dollar, so we may buy both. At this point, we have bought $2$ donuts and $1$ bagel, and $2$ dollars remain unspent. Now we may buy either one more donut at a rate of $3$ utils per dollar, or two more bagels at the same rate. Either way, we have maximized our utility with $28$ utils.

Why does the greedy method work? To explain this, first notice that after employing the greedy strategy, the marginal utility per cost of each good is equal or as close as possible. Written mathematically, the greedy strategy ensures that Conversely, it is the only strategy ensuring that this occurs. We may prove that the greedy strategy is optimal by demonstrating that all others fare worse. If we used a strategy causing the final marginal utilities per cost of each good to be unequal, then it would follow that one would be greater than the other: If this were the case, then forgoing more units of good $2$ and buying more units of good $1$ would result in an increase in utility, demonstrating that the strategy would be sub-optimal. The greedy strategy is also optimal when more than two goods are present; in the presence of $n$ goods, it ensures that and it can be shown to be optimal by reasoning similar to the above.

This problem, of course, is oversimplified. To accurately model utility in the real-world, one would have to use a bivariate function $U(x,y)$ to represent the utility gained from buying $x$ units of one good and $y$ units of the other good. In the above problem, we have assumed that
which is not the case in many situations. For example, since donuts and bagels are so similar, I might have less of a desire for donuts after eating lots of bagels, and vice versa. This suggests that for two goods that are similar or alternatives for each other, called **substitute goods**,
Examples of substitute goods might include hot dogs and hamburgers, blue jeans and khakis, or pencils and pens. On the other hand, some goods go together well, like peanut butter and jelly or hammers and nails. These are called **complementary goods**, and ”bonus utility” can be derived from possessing both of them together:
Some goods can even violate the law of increasing opportunity cost. Consider sneakers, for example - the marginal utility of each odd-numbered sneaker will be smaller than the marginal utilities of the even-numbered sneakers, since shoes are worn in pairs.

In fact, the intricacies of human emotion suggest that no numerical quantification of human happiness can be well-defined. As a demonstration of this impossibility, consider the following thought experiment. Suppose that $u(x)$ measures the utility that an individual derives from owning $x$ dollars, and that you currently own $x_0$ dollars. If I give you one million dollars and then take it away again, you will probably be less happy than you were initially, if only by contrast with your immense joy before the prize is lost. However, the existence of the function $u(x)$ would imply that your total utility in both scenarios is $u(x_0)$. Perhaps this problem can be fixed by accounting differently for “emotional utility,” but that is a problem of human psychology.

The problems we have done so far have been discrete, since we have assumed that donuts and bagels can only be purchased in integer quantities. But what about goods that can be consumed continuously?

Let’s replace donuts and bagels with coffee and tea. Because these can be consumed continuously, rather than using a table of values to express the utility derived from varying quantities of these goods, we must use continuous functions. Define the utility functions of coffee and tea as follows: where $u_c$ and $u_t$ are measured in utils, and $x$ is measured in gallons. Suppose that coffee costs $10$ dollars for a gallon and tea costs only $4$ dollars for a gallon, and that we have a fixed budget of $20$ dollars. Notice that these utility functions obey the law of diminishing marginal utility because they increase at a decreasing rate for all positive real $x$.

It seems at first like our greedy method is no longer applicable, since “marginal utility” is not so well defined. How do you define the benefit derived from the “most recent” unit of coffee if it is not discrete? Is it the utility of the last sip? The last drop? The last atom?

This issue can be resolved by thinking of marginal utility in a different way. Instead of measuring simple marginal utility, we may consider *average* marginal utility. For instance, if I have one gallon of coffee and I get three more gallons, the *average* marginal utility is
Does this mean that the “marginal utility” of four gallons of coffee is $4/3$? Absolutely not! If I start out with zero gallons and gain four gallons, the average marginal utility is
But this measurement is less than satisfactory, since it requires *two* values - an initial value and a final gained - to complete the calculation. What we *really* want is a continuous analog of marginal utility that is a function only of the final quantity.

So suppose we just define the marginal utility of $x$ gallons of coffee as the average marginal utility of the last gallon of coffee, or the average marginal utility between $x-1$ and $x$ gallons. This would define the marginal utility of the $x$th gallon as
This isn’t really what we want, though. Nobody ever drinks coffee one gallon at at time. So let’s use instead the average marginal utility of, say, the last tenth of a gallon consumed. This would mean that the marginal utility of the $x$th gallon is
But surely we can break it down further. Perhaps if we used $1/100$ of a gallon, we can measure the marginal utility of each sip of coffee. This would give us the formula
If we want to be *really* accurate, we can try to measure the average marginal utility gained after each *molecule* of coffee, and use a formula like this:
Do you see what’s happening here? The smaller we make our interval, the more *accurate* and *continuous* our measurement of marginal utility becomes - and yet, it still seems arbitrary to set a numerical value for the size of the interval over which the average marginal utility should be taken. If only we could make the size arbitrarily small...
Ah-ha! Does this formula look familiar? As $q$, the quantity change, becomes arbitrarily small and approaches zero, the limit of the average marginal utility approaches a finite value that evaluates to $u_c’(x)$, the derivative of the utility function. *This* is a much better way to measure the “marginal utility” of a continuous good.

Now let’s tackle the problem of maximizing our marginal utility by consuming optimal amounts of coffee and tea. It turns out that we *can* use the greedy strategy, by choosing quantities $q_1$ and $q_2$ of coffee and tea respectively that ensure that
Suppose that $m$ is the value of the number above. Then we have that
and
Since spending all $20$ of our budgeted dollars will maximize our utility, we may asume that the sum of the two numbers above is equal to $20$, and we may use this to solve for the value of $m$:
Plugging this into our above formulae for $q_1$ and $q_2$ yields the values
and
Thus, the maximum amount of utility, achieved by purchasing the above quantities of coffee and tea, is given by

Of course, the same method can be used for more than two continuous goods; all one must do is assume that where $n$ is the number of goods, $u_i$ is the utility function of the $i$th good, $c_i$ is the cost per unit of the $i$th good, and $q_i$ is the utility-maximizing quantity of the $i$th good purchased.

I now suggest the following interesting optimization problem for any interested reader. It does not model any situation in economics having to do with utility, since utility functions are not typically sinusoidal; however, reasoning similar to that used previously in this post can be used to solve the following problem.

back to home pageGiven that $x,y,z\gt 0$ and $x+y+z=\pi$, find is the maximum value of