<p>For reference, an explicit derivation akin to @tdm's, using the calculus of variations, is also given in Heer and Maußner (2024), <em>Dynamic General Equilibrium Modeling: Computational Methods and Applications,</em> 3rd edition, specifically section 4.6 and its appendices.</p>

CC BY-SA 4.0
2024-07-23T07:11:37.253Z
Thank you for the reference '+1'
Jesper Hybel
CC BY-SA 4.0
2024-07-03T09:45:45.920Z
2024-07-03T09:45:45.920Z
chsk
<p>The `heuristic' way of taking first order conditions is indeed a bit 'mathematically' dodgy.</p>
<p>For this type of problems, where you are maximizing over an entire function, the first order conditions are (usually) obtained by applying `calculus of variation' principles. The idea is that you look at small perturbations from the optimal solution and require that any such variation does not improve the optimal solution.</p>
<p>First, I'm going to ignore some details, like corner (boundary) constraints that require for instance that inputs should always be non-negative. Also, I'm skipping quite a lot of details here.</p>
<p>To get started, let <span class="math-container">$C^1[0,1]$</span> be the class of continuous functions <span class="math-container">$g: [0,1] \to \mathbb{R}$</span> that are differentiable on <span class="math-container">$(0,1)$</span>. The following holds:</p>
<p><strong>Lemma [fundamental lemma of the calculus of variation]</strong> If <span class="math-container">$h:[0,1] \to \mathbb{R}$</span> is continuous and if for all <span class="math-container">$g \in C^1[0,1]$</span>, <span class="math-container">$\int_0^1 h(x) g(x) dx = 0$</span> then <span class="math-container">$h(x) = 0$</span> for all <span class="math-container">$x \in [0,1]$</span>.</p>
<p>I'm not going to give the proof, but the idea is that if <span class="math-container">$h(x_0) \ne 0$</span> for some <span class="math-container">$x_0$</span>, then (as <span class="math-container">$h$</span> is continuous) there is an interval containing <span class="math-container">$x_0$</span> on which <span class="math-container">$h$</span> is either strictly positive or negative. Then choosing <span class="math-container">$g$</span> to be also strictly positive or negative only on a sub-interval of this interval guarantees that the integral <span class="math-container">$\int_0^1 h(x) g(x) \ne 0$</span> giving a contradiction.</p>
<p>Now, let <span class="math-container">$Y: [0,1] \to \mathbb{R}$</span> be a function such that <span class="math-container">$Y(x)$</span> represents the  amount chosen for input <span class="math-container">$x \in [0,1]$</span>. We assume that this function is continuous. Consider our profit function, which depends on this function <span class="math-container">$Y$</span>.
<span class="math-container">$$
\pi(Y) = \left[\int_0^1 (Y(x))^{1/\lambda} dx \right]^\lambda - \int_0^1 P(x) Y(x) dx
$$</span>
Here <span class="math-container">$P(x)$</span> is the price of input <span class="math-container">$x$</span>, which we assume to be fixed (and continuous).</p>
<p>We would like to find the function <span class="math-container">$Y^\ast: [0,1] \to \mathbb{R}$</span> that maximizes <span class="math-container">$\pi(Y)$</span>.</p>
<p>In order to get a set of necessary first order conditions, we are going to use the calculus of variation.</p>
<p>First assume that we know the optimal solution <span class="math-container">$Y^\ast: [0,1] \to \mathbb{R}$</span>. We are going to look at small variations (perturbations) to this optimal solution, and require that none of these perturbations improves the profit. To obtain these small variations, let <span class="math-container">$g \in C^1[0,1]$</span> and consider for a small enought <span class="math-container">$\varepsilon \in \mathbb{R}$</span>, a new function:
<span class="math-container">$$
Y_\varepsilon(x) = Y^\ast(x) + \varepsilon g(x).
$$</span>
The function <span class="math-container">$Y_\varepsilon$</span> can be considered as a small perturbation of the optimal function <span class="math-container">$Y^\ast$</span>. Note that for <span class="math-container">$\varepsilon = 0$</span>, <span class="math-container">$Y_0(x) = Y^\ast(x)$</span>. As such, <span class="math-container">$\pi(Y_\varepsilon)$</span> reaches a maximum value for <span class="math-container">$\varepsilon = 0$</span>. Given that <span class="math-container">$\varepsilon$</span> is a real number, we can use the usual first order condition with respect to <span class="math-container">$\varepsilon$</span>.</p>
<p>This gives:
<span class="math-container">$$
\left. \frac{d \pi(Y_\varepsilon)}{d\varepsilon} \right|_{\varepsilon = 0} = 0
$$</span></p>
<p>Note that:
<span class="math-container">$$
\pi(Y_\varepsilon) = \left[\int_0^1 (Y^\ast(x) + \varepsilon g(x))^{1/\lambda} dx\right]^{\lambda} - \int_0^1 P(x)(Y^\ast(x) + \varepsilon g(x)) dx.
$$</span>
Taking the derivative of with respect to <span class="math-container">$\varepsilon$</span> and evaluating at <span class="math-container">$\varepsilon = 0$</span> gives:
<span class="math-container">$$
\begin{align*}
&amp;\left[\int_0^1 (Y^\ast(x))^{1/\lambda} dx\right]^{\lambda-1} \int_0^1 Y^\ast(x)^{\frac{1 - \lambda}{\lambda}} g(x) dx - \int_0^1 P(x) g(x) dx,\\
&amp;=\int_0^1 \underbrace{\left\{  \left[\int_0^1 (Y^\ast(x))^{1/\lambda} dx\right]^{\lambda-1} Y^\ast(x)^{\frac{1 - \lambda}{\lambda}} - P(x) \right\}}_{h(x)} g(x) dx = 0\\
\end{align*}
$$</span>
Given that <span class="math-container">$g \in C^1[0,1]$</span> was arbitrary, we can use the Fundamental lemma of the calculus of variation to obtain that <span class="math-container">$h(x) = 0$</span> for all <span class="math-container">$x$</span>, which gives the collection of first order conditions that you were looking for.</p>

CC BY-SA 4.0
2024-06-30T10:22:55.237Z
Excellent, thank you so much; this really helps. So if I understand correctly, economically speaking, the key insight is that we're not taking the derivative wrt $Y(x)$ for each given $x$ in isolation, but instead for all $x$ at the same time? In other words, we're differentiating wrt. to the entire function $Y(\cdot)$, and obtaining one single functional FOC for $Y^*(\cdot)$. Given that, could we also obtain the result using a suitable notion of functional derivatives (eg Hadamard)?
chsk
CC BY-SA 4.0
2024-06-29T08:17:46.517Z
2024-06-29T08:17:46.517Z
tdm
<p>This is perhaps more of a mathematical than an economic question, but since it's from an economic problem, I'm posing it here.</p>
<p>Suppose I have, in a macro model, a perfectly competitive final goods producer combining a continuum of differentiated intermediate goods using the Dixit-Stiglitz (CES) aggregator</p>
<p><span class="math-container">$$
Y_t = \left[ \int_0^1 (Y_{i,t})^{\frac1\lambda} di \right]^\lambda
$$</span></p>
<p>This producer chooses <span class="math-container">$Y_{i,t}$</span> for all <span class="math-container">$0 \le i \le 1$</span> to maximize profits, taken as given input and output prices,</p>
<p><span class="math-container">$$
\max_{\{Y_{i,t}\}} P_t Y_t - \int_0^1 P_{i,t} Y_{i,t} di
$$</span></p>
<p>The first-order condition (FOC) for this problem is obtained by taking the derivative of profit (let's call it <span class="math-container">$\Pi_t$</span>) w.r.t. <span class="math-container">$Y_{i,t}$</span>, and textbooks invariably give this as</p>
<p><span class="math-container">$$
\frac{\partial}{\partial Y_{i,t}}\Pi_t = P_t \left[ \frac{ Y_t }{ Y_{i,t} } \right]^{\frac{\lambda-1}\lambda} - P_{i,t}
$$</span></p>
<p>But how do you arrive there? Specifically, when taking the derivative of an integral such <span class="math-container">$\int_0^1 P_{j,t} Y_{j,t} dj$</span> (where I've renamed the integration dummy to avoid confusion) w.r.t. some <span class="math-container">$Y_{i,t}$</span> (with <span class="math-container">$i$</span> fixed), how does one proceed, mathematically?</p>
<p>My approach would've been to say that since the integral bounds do not depend on <span class="math-container">$i$</span>, we can switch differentiation and integration by Leibniz rule to get that</p>
<p><span class="math-container">$$
\frac{\partial}{\partial Y_{i,t}} \int_0^1 P_{j,t} Y_{j,t} dj = \int_0^1 \frac{\partial}{\partial Y_{i,t}} \left[ P_{j,t} Y_{j,t} \right] dj
$$</span></p>
<p>The derivative inside the integral is <span class="math-container">$P_{i,t}$</span> if <span class="math-container">$i = j$</span>, zero otherwise. So I would think that we should have</p>
<p><span class="math-container">$$
\frac{\partial}{\partial Y_{i,t}} \int_0^1 P_{j,t} Y_{j,t} dj = \int_0^1 P_{i,t} \cdot \mathbf{1}(i = j) dj
$$</span></p>
<p>(where <span class="math-container">$\mathbf{1}$</span> is the indicator function for the given condition). But since the integrand is then zero almost everywhere (except for at one point), the integral should evaluate to zero:</p>
<p><span class="math-container">$$
\frac{\partial}{\partial Y_{i,t}} \int_0^1 P_{j,t} Y_{j,t} dj = 0
$$</span></p>
<p>Clearly that's not the standard result, which is that</p>
<p><span class="math-container">$$
\frac{\partial}{\partial Y_{i,t}} \int_0^1 P_{j,t} Y_{j,t} dj = P_{i,t}
$$</span></p>
<p>instead.</p>
<p>In the discrete case, the result is different, of course. If the integral is replaced with a finite sum (running from <span class="math-container">$i = 1$</span> to <span class="math-container">$N$</span> for some <span class="math-container">$N &lt; \infty$</span>), then everything works out. And since an integral is, in a sense, the continuous limit of a discrete sum, the standard result also makes sense.[1,2]</p>
<p>The same holds, mutatis mutandis, for the other integral encountered when deriving the FOC for the Dixit-Stiglitz aggregator (<span class="math-container">$\frac{\partial}{\partial Y_{i,t}} P_t Y_t$</span>).</p>
<p>I don't doubt that the standard result is correct. However, I wish to understand <em>why</em> it is and how I can arrive at it in a way that's mathematically rigorous.</p>
<p>(There is a <a href="https://economics.stackexchange.com/questions/29710/dixit-stiglitz-price-index-foc">related question here</a>, but the answer merely states that the continuous case &quot;follows as a sort of limiting extension&quot;, which is too handwavy for me. It also links to <a href="https://www.columbia.edu/%7Ejid2106/td/dixitstiglitzbasics.pdf" rel="nofollow noreferrer">Dingel's <em>The basics of “Dixit-Stiglitz lite”</em></a>, but there's nothing in there.)</p>
<p>Any help is welcome, especially pointers to relevant documents. Thanks!</p>
<p><strong>Footnotes:</strong></p>
<ol>
<li>My result also makes some intuitive sense to me: since there is a <em>continuum</em> of intermediate goods, it makes sense that a change in the amount used for production of <em>just one</em> (generally, a null set) would leave overall profits unchanged.</li>
<li>Mathematically speaking, since the integral is from 0 to 1, I feel that the more appropriate discrete sum it's a limit of is perhaps actually <span class="math-container">$\sum_{i=1}^N \frac1N P_{i,t} Y_{i,t}$</span>, and when letting <span class="math-container">$N \to \infty$</span> there the limit of the partial derivative is indeed zero.</li>
</ol>

<mathematical-economics><ces><first-order-condition><dixit-stiglitz><differentiation>
FOCs for the Dixit-Stiglitz aggregator: derivative of an integral w.r.t. integrand at one point
chsk
# FOCs for the Dixit-Stiglitz aggregator: derivative of an integral w.r.t. integrand at one point

(Asked by: username_0 on 2024-06-28)

This is perhaps more of a mathematical than an economic question, but since it's from an economic problem, I'm posing it here.

Suppose I have, in a macro model, a perfectly competitive final goods producer combining a continuum of differentiated intermediate goods using the Dixit-Stiglitz (CES) aggregator

$$
Y\_t = \left[ \int\_0^1 (Y\_{i,t})^{\frac1\lambda} di \right]^\lambda
$$

This producer chooses $Y\_{i,t}$ for all $0 \le i \le 1$ to maximize profits, taken as given input and output prices,

$$
\max\_{\{Y\_{i,t}\}} P\_t Y\_t - \int\_0^1 P\_{i,t} Y\_{i,t} di
$$

The first-order condition (FOC) for this problem is obtained by taking the derivative of profit (let's call it $\Pi\_t$) w.r.t. $Y\_{i,t}$, and textbooks invariably give this as

$$
\frac{\partial}{\partial Y\_{i,t}}\Pi\_t = P\_t \left[ \frac{ Y\_t }{ Y\_{i,t} } \right]^{\frac{\lambda-1}\lambda} - P\_{i,t}
$$

But how do you arrive there? Specifically, when taking the derivative of an integral such $\int\_0^1 P\_{j,t} Y\_{j,t} dj$ (where I've renamed the integration dummy to avoid confusion) w.r.t. some $Y\_{i,t}$ (with $i$ fixed), how does one proceed, mathematically?

My approach would've been to say that since the integral bounds do not depend on $i$, we can switch differentiation and integration by Leibniz rule to get that

$$
\frac{\partial}{\partial Y\_{i,t}} \int\_0^1 P\_{j,t} Y\_{j,t} dj = \int\_0^1 \frac{\partial}{\partial Y\_{i,t}} \left[ P\_{j,t} Y\_{j,t} \right] dj
$$

The derivative inside the integral is $P\_{i,t}$ if $i = j$, zero otherwise. So I would think that we should have

$$
\frac{\partial}{\partial Y\_{i,t}} \int\_0^1 P\_{j,t} Y\_{j,t} dj = \int\_0^1 P\_{i,t} \cdot \mathbf{1}(i = j) dj
$$

(where $\mathbf{1}$ is the indicator function for the given condition). But since the integrand is then zero almost everywhere (except for at one point), the integral should evaluate to zero:

$$
\frac{\partial}{\partial Y\_{i,t}} \int\_0^1 P\_{j,t} Y\_{j,t} dj = 0
$$

Clearly that's not the standard result, which is that

$$
\frac{\partial}{\partial Y\_{i,t}} \int\_0^1 P\_{j,t} Y\_{j,t} dj = P\_{i,t}
$$

instead.

In the discrete case, the result is different, of course. If the integral is replaced with a finite sum (running from $i = 1$ to $N$ for some $N < \infty$), then everything works out. And since an integral is, in a sense, the continuous limit of a discrete sum, the standard result also makes sense.[1,2]

The same holds, mutatis mutandis, for the other integral encountered when deriving the FOC for the Dixit-Stiglitz aggregator ($\frac{\partial}{\partial Y\_{i,t}} P\_t Y\_t$).

I don't doubt that the standard result is correct. However, I wish to understand *why* it is and how I can arrive at it in a way that's mathematically rigorous.

(There is a [related question here](https://economics.stackexchange.com/questions/29710/dixit-stiglitz-price-index-foc), but the answer merely states that the continuous case "follows as a sort of limiting extension", which is too handwavy for me. It also links to [Dingel's *The basics of “Dixit-Stiglitz lite”*](https://www.columbia.edu/%7Ejid2106/td/dixitstiglitzbasics.pdf), but there's nothing in there.)

Any help is welcome, especially pointers to relevant documents. Thanks!

**Footnotes:**

1. My result also makes some intuitive sense to me: since there is a *continuum* of intermediate goods, it makes sense that a change in the amount used for production of *just one* (generally, a null set) would leave overall profits unchanged.
2. Mathematically speaking, since the integral is from 0 to 1, I feel that the more appropriate discrete sum it's a limit of is perhaps actually $\sum\_{i=1}^N \frac1N P\_{i,t} Y\_{i,t}$, and when letting $N \to \infty$ there the limit of the partial derivative is indeed zero.

**Tags:** mathematical-economics, ces, first-order-condition, dixit-stiglitz, differentiation

---

## 2 answers

### Answer by username_2 on 2024-06-29. Score: 4 | Accepted answer

The `heuristic' way of taking first order conditions is indeed a bit 'mathematically' dodgy.

For this type of problems, where you are maximizing over an entire function, the first order conditions are (usually) obtained by applying `calculus of variation' principles. The idea is that you look at small perturbations from the optimal solution and require that any such variation does not improve the optimal solution.

First, I'm going to ignore some details, like corner (boundary) constraints that require for instance that inputs should always be non-negative. Also, I'm skipping quite a lot of details here.

To get started, let $C^1[0,1]$ be the class of continuous functions $g: [0,1] \to \mathbb{R}$ that are differentiable on $(0,1)$. The following holds:

**Lemma [fundamental lemma of the calculus of variation]** If $h:[0,1] \to \mathbb{R}$ is continuous and if for all $g \in C^1[0,1]$, $\int\_0^1 h(x) g(x) dx = 0$ then $h(x) = 0$ for all $x \in [0,1]$.

I'm not going to give the proof, but the idea is that if $h(x\_0) \ne 0$ for some $x\_0$, then (as $h$ is continuous) there is an interval containing $x\_0$ on which $h$ is either strictly positive or negative. Then choosing $g$ to be also strictly positive or negative only on a sub-interval of this interval guarantees that the integral $\int\_0^1 h(x) g(x) \ne 0$ giving a contradiction.

Now, let $Y: [0,1] \to \mathbb{R}$ be a function such that $Y(x)$ represents the amount chosen for input $x \in [0,1]$. We assume that this function is continuous. Consider our profit function, which depends on this function $Y$.
$$
\pi(Y) = \left[\int\_0^1 (Y(x))^{1/\lambda} dx \right]^\lambda - \int\_0^1 P(x) Y(x) dx
$$
Here $P(x)$ is the price of input $x$, which we assume to be fixed (and continuous).

We would like to find the function $Y^\ast: [0,1] \to \mathbb{R}$ that maximizes $\pi(Y)$.

In order to get a set of necessary first order conditions, we are going to use the calculus of variation.

First assume that we know the optimal solution $Y^\ast: [0,1] \to \mathbb{R}$. We are going to look at small variations (perturbations) to this optimal solution, and require that none of these perturbations improves the profit. To obtain these small variations, let $g \in C^1[0,1]$ and consider for a small enought $\varepsilon \in \mathbb{R}$, a new function:
$$
Y\_\varepsilon(x) = Y^\ast(x) + \varepsilon g(x).
$$
The function $Y\_\varepsilon$ can be considered as a small perturbation of the optimal function $Y^\ast$. Note that for $\varepsilon = 0$, $Y\_0(x) = Y^\ast(x)$. As such, $\pi(Y\_\varepsilon)$ reaches a maximum value for $\varepsilon = 0$. Given that $\varepsilon$ is a real number, we can use the usual first order condition with respect to $\varepsilon$.

This gives:
$$
\left. \frac{d \pi(Y\_\varepsilon)}{d\varepsilon} \right|\_{\varepsilon = 0} = 0
$$

Note that:
$$
\pi(Y\_\varepsilon) = \left[\int\_0^1 (Y^\ast(x) + \varepsilon g(x))^{1/\lambda} dx\right]^{\lambda} - \int\_0^1 P(x)(Y^\ast(x) + \varepsilon g(x)) dx.
$$
Taking the derivative of with respect to $\varepsilon$ and evaluating at $\varepsilon = 0$ gives:
$$
\begin{align\*}
&\left[\int\_0^1 (Y^\ast(x))^{1/\lambda} dx\right]^{\lambda-1} \int\_0^1 Y^\ast(x)^{\frac{1 - \lambda}{\lambda}} g(x) dx - \int\_0^1 P(x) g(x) dx,\\
&=\int\_0^1 \underbrace{\left\{ \left[\int\_0^1 (Y^\ast(x))^{1/\lambda} dx\right]^{\lambda-1} Y^\ast(x)^{\frac{1 - \lambda}{\lambda}} - P(x) \right\}}\_{h(x)} g(x) dx = 0\\
\end{align\*}
$$
Given that $g \in C^1[0,1]$ was arbitrary, we can use the Fundamental lemma of the calculus of variation to obtain that $h(x) = 0$ for all $x$, which gives the collection of first order conditions that you were looking for.

> **Comments:**
> **username_0**: Excellent, thank you so much; this really helps. So if I understand correctly, economically speaking, the key insight is that we're not taking the derivative wrt $Y(x)$ for each given $x$ in isolation, but instead for all $x$ at the same time? In other words, we're differentiating wrt. to the entire function $Y(\cdot)$, and obtaining one single functional FOC for $Y^*(\cdot)$. Given that, could we also obtain the result using a suitable notion of functional derivatives (eg Hadamard)?  

---

### Answer by username_0 on 2024-07-03. Score: 1

For reference, an explicit derivation akin to @tdm's, using the calculus of variations, is also given in Heer and Maußner (2024), *Dynamic General Equilibrium Modeling: Computational Methods and Applications,* 3rd edition, specifically section 4.6 and its appendices.

> **Comments:**
> **username_1**: Thank you for the reference '+1'  

---

