*Warning: Boring technical stuff that’s only here because I needed it for the model in the Helicopter Money paper, and there are no other good references online.*

All the existing resources on the internet that I’ve found are either vague or inconsistent with their *σ*/*ρ* notation (where \(ρ=\frac{σ-1}{σ}\) and *σ* is the elasticity of substitution, which makes the exponents in the utility function look cleaner, though the exponents in the demand function will be correspondingly messier), or don’t derive it with the coefficients. Almost *none* go step by step (with the exception of this video) or carry through the coefficients with exponents, and *literally* none derive a function for more than two goods.

We’re going to do all of these: a fully general derivation of demand functions from an *n*-good CES utility function, carrying through the actual elasticity of substitution as a parameter. I’ll use sum notation throughout, which you can easily expand to a definite number of goods. It’s worth noting though that the elasticity of substitution has to be the same between all pairs of goods, otherwise there’s no fully general form.

We start by writing our CES function this way, raising our coefficient to the 1/*σ* and summing over a set of *n* goods. You might wonder why we’re raising our coefficient to an exponent too. It’ll make our demand function slightly cleaner in the end, and since it’s a parameter, you can just define *α _{n}*

(1) $$U=\left(\sum_n β_n^{1/σ}G_n^\frac{σ-1}{σ} \right)^\frac{σ}{σ-1} $$

A function of this form means that the elasticity of substitution between any pair of goods is *σ*. Our budget constraint, then, is

(2) $$I=\sum_nP_nG_n$$

So we want to maximize (1) subject to (2). So we set up our lagrangian, and derive with respect to each good plus λ, which gives us *n*+1 first-order conditions.

(3) $$\mathcal{L} = \left(\sum_n β_n^{1/σ}G_n^\frac{σ-1}{σ} \right)^\frac{σ}{σ-1} + λ\left(I-\sum_nP_nG_n\right)$$

Since both parts of the Lagrangian are sums, and the parameters of the various goods are all siloed into their own terms, this is actually fairly straightforward to derive with respect to any *G* variable. So we’ll pick any two goods, say *a* and *b*, and derive with respect to *G _{a}* and

To get the derivative of the first part of the Lagrangian, remember the chain rule for deriving *f*(*g*(*x*)): \(\frac{∂ f}{∂ x} = \frac{∂ f}{∂ g}\frac{∂ g}{∂ x}\). Our *f*(*g*) will be \(g^\frac{σ}{σ-1}\), and our *g*(*x*) will be the sum on the inside of the parentheses. Carrying down the \(\frac{σ}{σ-1}\) exponent from \(\frac{∂ f}{∂ g}\) cancels out the \(\frac{σ-1}{σ}\) exponent carried down from the *G _{n}* in \(\frac{∂ g}{∂ x}\). This gives us:

(4) $$\frac{∂\mathcal{L}}{∂G_a} = \left(\frac{β_a}{G_a}\right)^\frac{1}{σ} \left(\sum_n β_n^{1/σ}G_n^\frac{σ-1}{σ}\right)^\frac{1}{σ-1} – \lambda P_a = 0$$

(5) $$\frac{∂\mathcal{L}}{∂ G_b} = \left(\frac{β_b}{G_b}\right)^\frac{1}{σ} \left(\sum_n β_n^{1/σ}G_n^\frac{σ-1}{σ}\right)^\frac{1}{σ-1} – \lambda P_b = 0$$

(6) $$\frac{∂\mathcal{L}}{∂ \lambda} = I-\sum_nP_nG_n = 0$$

We have *β _{a}*/

From here, we want the relative price of *P _{a}* to

(7) $$\frac{P_a}{P_b} = \frac{(β_a/G_a)^\frac{1}{σ}}{(β_b/G_b)^\frac{1}{σ}} = \left(\frac{β_a G_b}{β_b G_a}\right)^\frac{1}{σ}$$

The right hand side is the marginal rate of substitution between *G _{a}* and

Solving for *G _{b}*, we have

(8) $$G_b = \frac{β_bG_a}{β_a}\left(\frac{P_a}{P_b}\right)^σ$$

And similarly for *G _{c}*, etc. What we’re aiming to do here is to replace all the

So, substituting (8) and its brothers back into the budget constraint (2) gives us

(9) $$I=P_aG_a + \sum_{n\neq a}P_n\frac{β_nG_a}{β_a}\left(\frac{P_a}{P_n}\right)^σ$$

$$= G_a \sum_{n}\frac{β_n}{β_a}P_a^σ P_n^{1-σ}$$

We’ve substituted every *G* term of the sum, except the original *G _{a}* term, with an expression in terms of

All that remains is to solve for *G _{a}*.

(10) $$ G_a = \frac{I}{\sum_{n}\frac{β_n}{β_a}P_a^σ P_n^{1-σ}} $$

$$= \frac{I P_a^{-σ}}{\sum_{n}\frac{β_n}{β_a}P_n^{1-σ}}$$

So there’s our demand function for *G _{a}*, and

## mg

Feb 13, 2019 at 19:47 |Thanks this was very helpful to me! But I think you left out a lambda in equations 4 and 5? It would cancel out anyway in the next step so it wouldn’t change the results at all.

## Cameron Harwick

Feb 13, 2019 at 21:52Good catch, thanks – (4) and (5) are updated now.

## Adam

Apr 30, 2019 at 1:47 |Thanks for the post, it is great! One thing that is not quite clear to me is what has happened to the moved down exponent (via the power rule) when taking the derivative of g(x). To be a bit clearer, you end up with (beta/gx)^1/sigma as the derivate of the inside part wrt to gx. Stepping through that, we go from b^(1/sigma)*gx^(sigma/(sigma-1)) taking the derivate wrt gx gives (sigma/(sigma-1))*(b^(1/sigma)*gx^(-1/sgima)) I think I see how we go from here to (b/gx)^(1/sigma) but it is not clear to me what has happened to (sigma/(sigma-1))?

It’s probably something really obvious that I am missing, but would love a little help on understanding that part!

## Cameron Harwick

Apr 30, 2019 at 10:57I don’t 100% follow your question, but I ran through the derivative again, and I did fail to carry down the exponent on the ∂g/∂x portion of the chain rule, which gives a (σ-1)/σ coefficient that cancels out the σ/(σ-1) carried down from ∂f/∂g. It didn’t end up mattering in the end because the σ/(σ-1) canceled itself out when doing the relative price calculation in (7), but even so it shouldn’t have been there. I’ve updated (4) and (5) to correct this.

Does that address your question, or were you getting at something else? Thanks in any case for pointing out the inconsistency.

## Adam

Apr 30, 2019 at 19:42Thanks for getting back to me, this indeed does address my question.

Thanks again for the good work, it’s very helpful! A better treatment than Alpha Chiang’s which is what I’d been working through 😊

## Lewis

Jan 13, 2020 at 23:20 |I think the exponent on the sun term in parens is reversed. Should be 1/(/sigma-1)?

## Cameron Harwick

Jan 13, 2020 at 23:39You’re right, that was flipped by mistake – fixed now.