One of the most common conditions in consumer choice theory is

MUXPX=MUYPY.\frac{MU_X}{P_X}=\frac{MU_Y}{P_Y}.

This condition means that utility is maximized when the marginal utility per unit of money spent is equal across goods. I understood the intuition, but when I tried to derive it directly, I got stuck on how to differentiate the utility expression. So I rewrote the problem using the budget constraint and total utility as the integral of marginal utility.

Assume that a consumer only consumes two goods, XX and YY. Their prices are PXP_X and PYP_Y, and the consumed quantities are QXQ_X and QYQ_Y. The consumer's income is fixed at I0I_0. The budget constraint is

PXQX+PYQY=I0.P_XQ_X+P_YQ_Y=I_0.

Solving for QYQ_Y gives

QY=I0PXQXPY.Q_Y=\frac{I_0-P_XQ_X}{P_Y}.

Since the budget is fixed, consuming more of XX requires consuming less of YY. Differentiating this with respect to QXQ_X gives

dQYdQX=PXPY.\frac{dQ_Y}{dQ_X}=-\frac{P_X}{P_Y}.

This is the slope of the budget line. It represents how much YY must be given up in order to consume one more unit of XX.

Now express total utility as the accumulated marginal utility. Since marginal utility measures how much total utility increases when consumption increases by a small amount, total utility can be written as

U(QX,QY)=0QXMUX(q)dq+0QYMUY(q)dq.U(Q_X,Q_Y) = \int_0^{Q_X} MU_X(q)\,dq + \int_0^{Q_Y} MU_Y(q)\,dq.

The important point is that, on the budget line, QYQ_Y is not an independent variable. It is determined by QXQ_X. So total utility can be treated as a function of QXQ_X alone:

U(QX)=0QXMUX(q)dq+0QY(QX)MUY(q)dq.U(Q_X) = \int_0^{Q_X} MU_X(q)\,dq + \int_0^{Q_Y(Q_X)} MU_Y(q)\,dq.

Now differentiate this expression with respect to QXQ_X.

The first term is straightforward. By the fundamental theorem of calculus,

ddQX0QXMUX(q)dq=MUX(QX).\frac{d}{dQ_X} \int_0^{Q_X} MU_X(q)\,dq = MU_X(Q_X).

The second term requires a little more care. The integration variable is qq, but the upper limit QYQ_Y is a function of QXQ_X. Therefore, we need to apply the chain rule.

In general,

ddx0g(x)f(t)dt=f(g(x))g(x).\frac{d}{dx} \int_0^{g(x)} f(t)\,dt = f(g(x))g'(x).

Applying this to the second term gives

ddQX0QY(QX)MUY(q)dq=MUY(QY)dQYdQX.\frac{d}{dQ_X} \int_0^{Q_Y(Q_X)} MU_Y(q)\,dq = MU_Y(Q_Y)\frac{dQ_Y}{dQ_X}.

From the budget constraint, we already have

dQYdQX=PXPY.\frac{dQ_Y}{dQ_X}=-\frac{P_X}{P_Y}.

Therefore,

ddQX0QY(QX)MUY(q)dq=MUY(QY)(PXPY).\frac{d}{dQ_X} \int_0^{Q_Y(Q_X)} MU_Y(q)\,dq = MU_Y(Q_Y)\left(-\frac{P_X}{P_Y}\right).

So the derivative of total utility with respect to QXQ_X is

dUdQX=MUX(QX)+MUY(QY)(PXPY).\frac{dU}{dQ_X} = MU_X(Q_X) + MU_Y(Q_Y)\left(-\frac{P_X}{P_Y}\right).

Simplifying,

dUdQX=MUX(QX)MUY(QY)PXPY.\frac{dU}{dQ_X} = MU_X(Q_X) - MU_Y(Q_Y)\frac{P_X}{P_Y}.

At an interior optimum, slightly increasing or decreasing QXQ_X should no longer increase total utility. Therefore,

dUdQX=0.\frac{dU}{dQ_X}=0.

So

MUX(QX)MUY(QY)PXPY=0.MU_X(Q_X) - MU_Y(Q_Y)\frac{P_X}{P_Y} =0.

Rearranging gives

MUX(QX)=MUY(QY)PXPY.MU_X(Q_X) = MU_Y(Q_Y)\frac{P_X}{P_Y}.

Dividing both sides by PXP_X gives

MUX(QX)PX=MUY(QY)PY.\frac{MU_X(Q_X)}{P_X} = \frac{MU_Y(Q_Y)}{P_Y}.

Therefore, the utility maximization condition in consumer choice theory is

MUXPX=MUYPY.\boxed{ \frac{MU_X}{P_X} = \frac{MU_Y}{P_Y} }.

The meaning of this condition is simple. The consumer allocates a limited budget across goods. The additional utility gained from spending one more unit of money on XX is MUXPX\frac{MU_X}{P_X}, while the additional utility gained from spending one more unit of money on YY is MUYPY\frac{MU_Y}{P_Y}.

If

MUXPX>MUYPY,\frac{MU_X}{P_X}>\frac{MU_Y}{P_Y},

then spending money on XX is more efficient than spending money on YY. The consumer should reduce consumption of YY and increase consumption of XX.

If

MUXPX<MUYPY,\frac{MU_X}{P_X}<\frac{MU_Y}{P_Y},

then spending money on YY is more efficient. The consumer should reduce consumption of XX and increase consumption of YY.

Eventually, the consumer has no reason to change the allocation when the two values become equal:

MUXPX=MUYPY.\frac{MU_X}{P_X} = \frac{MU_Y}{P_Y}.

In other words, utility maximization does not mean simply consuming more of the good with higher marginal utility. It means allocating the budget until the marginal utility per unit of money is equal across goods.