<p>I think the problem you’re having is that you’re solving for the optimal <span class="math-container">$p$</span> as a standard multivariable optimisation problem. There is a noticeable difference between functional optimisation compared with multivariate optimisation, but this difference is often ignored in economics in favour of heuristic methods.</p>
<p>In the problem you stated, we need to find the optimal <span class="math-container">$\textit{function}$</span> <span class="math-container">$p:(0,\infty)\to \mathbb{R}$</span> along with an optimal value of a <span class="math-container">$\textit{variable}$</span> <span class="math-container">$K$</span>. Your first question likely stems from this difference.</p>
<p>The Lagrangian is <span class="math-container">$$\mathcal{L}=\mathbb{E}[S(p(\theta),\theta)-cD(p(\theta),\theta)+\lambda(\theta)(K-D(p(\theta),\theta))]-rK$$</span> The reason we have <span class="math-container">$\lambda(\theta)$</span> inside the expectation is that we have the constraint <span class="math-container">$D(p(\theta),\theta)\leq K$</span> holding for all <span class="math-container">$\theta$</span>. If <span class="math-container">$\theta$</span> were drawn from some finite set <span class="math-container">$\Theta$</span>, we would have the Lagrangian as <span class="math-container">$$\mathcal{L}=\sum_{\theta'\in \Theta}[S(p(\theta'),\theta')-cD(p(\theta'),\theta')+\lambda(\theta')(K-D(p(\theta'),\theta'))]\mathbb{P}(\theta=\theta')-rK$$</span> which may be more familiar. The integral simply generalises this to the case when <span class="math-container">$\Theta$</span> is a continuum. It is also intuitive that the constraint should be within the expectation operator as it is a stochastic constraint. We know that for any <span class="math-container">$\theta$</span> realisation the constraint will bind, but since we don't know what value <span class="math-container">$\theta$</span> will take we consider an expectation over the possible realisations of the constraint.</p>
<p>Now we can move on to the optimisation problem.</p>
<p>Consider the variable optimisation problem, i.e., the choice of <span class="math-container">$K$</span>. Taking the FOC of <span class="math-container">$\mathcal{L}$</span> w.r.t. <span class="math-container">$K$</span>, we find (assuming regularity conditions on <span class="math-container">$S$</span> and <span class="math-container">$D$</span> allowing us to differentiate under the integral) that <span class="math-container">$$\begin{align*} \frac{\partial \mathcal{L}}{\partial K} &amp;=\frac{\partial }{\partial K}[\mathbb{E}[S(p(\theta),\theta)-cD(p(\theta),\theta)+\lambda(\theta)(K-D(p(\theta),\theta))]-rK] \\
&amp;= \mathbb{E}\left[\frac{\partial }{\partial K}(S(p(\theta),\theta)-cD(p(\theta),\theta)+\lambda(\theta)(K-D(p(\theta),\theta)))\right]-r \\
&amp;= \mathbb{E}[\lambda(\theta)]-r \end{align*}$$</span></p>
<p>Second, for the functional optimisation problem, we should really take a variational approach. This answer by tdm gives a good overview of the methodology: <a href="https://economics.stackexchange.com/questions/58727/focs-for-the-dixit-stiglitz-aggregator-derivative-of-an-integral-w-r-t-integra/58731#58731">FOCs for the Dixit-Stiglitz aggregator: derivative of an integral w.r.t. integrand at one point</a> . Suppose we are given an optimal function choice <span class="math-container">$p^*$</span>. Consider perturbing this optimal choice by any other <span class="math-container">$C^1$</span> function <span class="math-container">$g$</span> to <span class="math-container">$p^*+\varepsilon g$</span>. Define <span class="math-container">$$\mathcal{L}(f)=\mathbb{E}[S(f(\theta),\theta)-cD(f(\theta),\theta)+\lambda(\theta)(K-D(f(\theta),\theta))]-rK$$</span> Since <span class="math-container">$p^*$</span> is optimal, we must have that <span class="math-container">$$\frac{\partial}{\partial \varepsilon} \mathcal{L}(p^*+\varepsilon g)\Bigg|_{\varepsilon=0}=0$$</span> Evaluation of this gives <span class="math-container">$$\begin{align*} 0 &amp;= \frac{\partial}{\partial \varepsilon} \mathcal{L}(p^*+\varepsilon g)\Bigg|_{\varepsilon=0} \\
&amp;=\frac{\partial}{\partial \varepsilon} [\mathbb{E}[S(p^*(\theta)+\varepsilon g(\theta),\theta)-cD(p^*(\theta)+\varepsilon g(\theta),\theta)+\lambda(\theta)(K-D(p^*(\theta)+\varepsilon g(\theta),\theta))]-rK]\Bigg|_{\varepsilon=0} \\
&amp;=\frac{\partial}{\partial \varepsilon} [\mathbb{E}[S(p^*(\theta)+\varepsilon g(\theta),\theta)-cD(p^*(\theta)+\varepsilon g(\theta),\theta)+\lambda(\theta)(K-D(p^*(\theta)+\varepsilon g(\theta),\theta))]]\Bigg|_{\varepsilon=0}\\
&amp;=\mathbb{E}\left[\frac{\partial}{\partial \varepsilon}(S(p^*(\theta)+\varepsilon g(\theta),\theta)-cD(p^*(\theta)+\varepsilon g(\theta),\theta)+\lambda(\theta)(K-D(p^*(\theta)+\varepsilon g(\theta),\theta)))\right]\Bigg|_{\varepsilon=0} \\
&amp;=\mathbb{E}\left[\frac{\partial S}{\partial p}(p^*(\theta)+\varepsilon g(\theta),\theta)g(\theta)-(c+\lambda(\theta))\frac{\partial D}{\partial p}(p^*(\theta)+\varepsilon g(\theta),\theta)g(\theta) \right]\Bigg|_{\varepsilon=0} \\
&amp;= \mathbb{E}\left[\left(\frac{\partial S}{\partial p}(p^*(\theta)+\varepsilon g(\theta),\theta)-(c+\lambda(\theta))\frac{\partial D}{\partial p}(p^*(\theta)+\varepsilon g(\theta),\theta)\right)g(\theta) \right]\Bigg|_{\varepsilon=0} \\
&amp;= \mathbb{E}\left[\left(\frac{\partial S}{\partial p}(p^*(\theta),\theta)-(c+\lambda(\theta))\frac{\partial D}{\partial p}(p^*(\theta),\theta)\right)g(\theta) \right] \end{align*}$$</span></p>
<p>The above is equal to zero for any <span class="math-container">$g\in C^1$</span>. Hence, assuming <span class="math-container">$S$</span> and <span class="math-container">$D$</span> are continuous (and that the optimal <span class="math-container">$p^*$</span> is continuous), by the Fundamental Lemma of the Calculus of Variations, we must have <span class="math-container">$$\frac{\partial S}{\partial p}(p^*(\theta),\theta)-(c+\lambda(\theta))\frac{\partial D}{\partial p}(p^*(\theta),\theta)=0$$</span></p>
<p>What I meant in the comments about this being pointwise is that we can get the exact same result if we ignore the the expectation operator in <span class="math-container">$\mathcal{L}$</span> and take the derivative w.r.t. <span class="math-container">$p(\theta)$</span> for a fixed <span class="math-container">$\theta$</span>. Generally this is acceptable if derivatives of <span class="math-container">$p(\theta)$</span> are not included in <span class="math-container">$\mathcal{L}$</span>. If the first derivative is included, we can use the Euler-Lagrange equation to get a first-order condition.</p>

CC BY-SA 4.0
2024-07-22T08:20:05.790Z
Thank you for the answer. It makes sense and the argumentation is convincing to me. Just like your comments. I am, however, not the one to judge whether this constitutes a mathematically sound proof. If no one else has anything to add on the matter I will definitely accept your answer. Thx. again for taking the time to write this up.
Jesper Hybel
CC BY-SA 4.0
2024-07-22T14:10:41.000Z
@Jesper Hybel: Thanks for the interesting question. I'm trying to follow the whole thing but the note that you linked to in your question at the bottom ( why the constraint is included in the expectation operator) is currently not working. It may not clear things up for me but it can't hurt. Thanks again.
mark leeds
CC BY-SA 4.0
2024-07-22T14:13:38.153Z
I will refresh it but it is on something completely different. So prepare to be underwhelmed.
Jesper Hybel
CC BY-SA 4.0
2024-07-22T15:07:28.917Z
No problem. One last bother on this: Do you know of a reference that talks about where Joseph mentions: "That is the "bite" of the Lagrange Multiplier method in the comments at the top. It sounds like an interesting way to think about it especially because I'm used to the standard marginal cost-shadow price argument. Thanks.
mark leeds
CC BY-SA 4.0
2024-07-22T15:48:33.483Z
Link has been updated and is also here: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2883305. No, I have no knowledge of where the idea of interpreting the Lagrange coefficient like that is followed through.
Jesper Hybel
CC BY-SA 4.0
2024-07-22T16:11:38.853Z
This answer (and also the question, +1 both) is very interesting, as it points out a distinction that in mathematics is far from trivial, the difference between optimization in usual calculus and the optimizations problems in which we must choose not the value of a variable, but a whole function, as in the calculus of variations.
BakerStreet
CC BY-SA 4.0
2024-07-22T16:13:20.390Z
In addition, we have here a stochastic context, that is stochastic processes, and therefore we are talking about *stochastic calculus of variations*,  which it is also called Mallavin calculus https://en.wikipedia.org  https://www.ams.org/journals/bull/2007-44-03/S0273-0979-07-01146-9/S0273-0979-07-01146-9.pdf. And also this is not a trivial generalization of calculus of variations.  I wonder if @Joseph Basford  could suggest an introductory text to this part of the theory of stochastic processes.
BakerStreet
CC BY-SA 4.0
2024-07-22T18:16:42.870Z
@BakerStreet thank you for your comments. What you’ve said betrays an assumption I’d accidentally hidden in my answer. I had assumed that $\theta$ was drawn from an absolutely continuous distribution, such that it admitted a probability density function, $f$ which was everywhere strictly positive. This fact is crucial for the derivation. If F admits no density, differentiation under the integral is not direct. Also, if the density is not everywhere positive, the FOC is multiplied by $f(\theta)$, so that when it is zero, we can pick $p(\theta)$ arbitrarily.
Joseph Basford
CC BY-SA 4.0
2024-07-22T08:09:09.807Z
2024-07-22T08:09:09.807Z
Joseph Basford
<p>I am considering a maximization problem:</p>
<p><span class="math-container">\begin{align}
\max_{p(\theta),K} \mathbb E[S(p(\theta),\theta) - c D(p(\theta),\theta)]
\end{align}</span></p>
<p>subject to the constraint</p>
<p><span class="math-container">\begin{align}
D(p(\theta),\theta)\leq K \ \ \forall\theta \ \ \ (\lambda(\theta)).
\end{align}</span>
For which it is stated that the Lagrangian is</p>
<p><span class="math-container">$$\mathcal L = \mathbb E[S(p(\theta),\theta) - c D(p(\theta),\theta) + \lambda(\theta)(K - D(p(\theta),\theta))] - rK.$$</span></p>
<p>It is then stated that the first-order conditions are</p>
<p><span class="math-container">\begin{align}
(1) &amp;\ \ \frac{\partial \mathcal L}{\partial p(\theta)} = \frac{\partial S(p(\theta),\theta)}{\partial p(\theta)} - (c + \lambda(\theta)) \frac{\partial D(p(\theta),\theta)}{\partial p(\theta)}=0 \\[8pt]
(2) &amp;\ \ \frac{\partial \mathcal L}{\partial K} = \mathbb E[\lambda(\theta)] - r= 0.
\end{align}</span></p>
<p>It is assumed that <span class="math-container">$\theta$</span> is random hence the expectation and <span class="math-container">$\theta \in (0,\infty)$</span> for some distribution <span class="math-container">$\theta \sim F(\theta)$</span>.</p>
<p>My question is:</p>
<p><strong>Why can the expectation operator be &quot;ignored&quot; for deriving (1) but not for (2)?</strong></p>
<p>Also, it would be nice to get an explanation for</p>
<p><strong>Why the constraint is included within the expectation operator?</strong></p>
<p>and perhaps being pointed to some good references for some lecture notes teaching these techniques. I am currently reading this <a href="https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2883305" rel="nofollow noreferrer">note</a> to see if that solves the problem for me.</p>
<p>The source of the maximization problem is Thomas-Olivier Léautier (2018) 'Imperfect Markets and Imperfect Regulation. An Introduction to the Microeconomics and Political Economy of Power Markets' page 65</p>

CC BY-SA 4.0
2024-07-12T17:50:57.907Z
The expression in (1) is a point-wise maximisation whilst the condition in (2) is not point-wise. Additionally, the constraint holds for all $\theta$, not just one, which is why we need to integrate over all of the constraints, i.e, why we need to take the expectation over the constraint.
Joseph Basford
CC BY-SA 4.0
2024-07-12T18:25:31.160Z
Yes, that makes sense ... So being point-wise the choice of maximizing $p(\theta)$ for some $\theta$ does not depend on how the function behaves elsewhere - read in any other $\theta$. And similarly in a discrete analogue with only two values of $\theta$ - $\theta_1$ and $\theta_2$ - differentiating with respect to $p(\theta_1)$ nullifies the part of the expectation concerned with $p(\theta_2)$?! - if I get what you are saying.
Jesper Hybel
CC BY-SA 4.0
2024-07-13T07:02:32.700Z
That is the "bite" of the Lagrange multiplier method; all the dependency of $p(\theta_1)$ on $p(\theta_2)$ (and vice versa) is moved to the co-state $\lambda(\theta)$. The $\lambda(\theta)$ term is effectively a penalty for the effect that changing one $p(\theta_i)$ value has on the other $p(\theta_j)$'s.
Joseph Basford
CC BY-SA 4.0
2024-07-18T19:38:42.460Z
Hi Joseph: Do you know of anything that expounds on your comment immediately above. I've read about lagrange multipliers ( over the years, off and on )  but never saw it described that way and it's interesting. Thanks. Oh, textbook or reference is great.
mark leeds
CC BY-SA 4.0
2024-07-18T21:56:04.287Z
Can you provide the source of the maximization problem? The note you link to is also not accessible (link expired).
Herr K.
CC BY-SA 4.0
2024-07-18T22:21:04.893Z
I added the source. But it is not available online to my knowledge.
Jesper Hybel
<lagrangian><expectations>
Lagrange with expectation: Why can we "ignore" the expectation operator?
Jesper Hybel
# Lagrange with expectation: Why can we "ignore" the expectation operator?

(Asked by: username_0 on 2024-07-12)

I am considering a maximization problem:

\begin{align}
\max\_{p(\theta),K} \mathbb E[S(p(\theta),\theta) - c D(p(\theta),\theta)]
\end{align}

subject to the constraint

\begin{align}
D(p(\theta),\theta)\leq K \ \ \forall\theta \ \ \ (\lambda(\theta)).
\end{align}
For which it is stated that the Lagrangian is

$$\mathcal L = \mathbb E[S(p(\theta),\theta) - c D(p(\theta),\theta) + \lambda(\theta)(K - D(p(\theta),\theta))] - rK.$$

It is then stated that the first-order conditions are

\begin{align}
(1) &\ \ \frac{\partial \mathcal L}{\partial p(\theta)} = \frac{\partial S(p(\theta),\theta)}{\partial p(\theta)} - (c + \lambda(\theta)) \frac{\partial D(p(\theta),\theta)}{\partial p(\theta)}=0 \\[8pt]
(2) &\ \ \frac{\partial \mathcal L}{\partial K} = \mathbb E[\lambda(\theta)] - r= 0.
\end{align}

It is assumed that $\theta$ is random hence the expectation and $\theta \in (0,\infty)$ for some distribution $\theta \sim F(\theta)$.

My question is:

**Why can the expectation operator be "ignored" for deriving (1) but not for (2)?**

Also, it would be nice to get an explanation for

**Why the constraint is included within the expectation operator?**

and perhaps being pointed to some good references for some lecture notes teaching these techniques. I am currently reading this [note](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2883305) to see if that solves the problem for me.

The source of the maximization problem is Thomas-Olivier Léautier (2018) 'Imperfect Markets and Imperfect Regulation. An Introduction to the Microeconomics and Political Economy of Power Markets' page 65

**Tags:** lagrangian, expectations
> **Comments:**
> **username_1**: The expression in (1) is a point-wise maximisation whilst the condition in (2) is not point-wise. Additionally, the constraint holds for all $\theta$, not just one, which is why we need to integrate over all of the constraints, i.e, why we need to take the expectation over the constraint.  
> **username_0**: Yes, that makes sense ... So being point-wise the choice of maximizing $p(\theta)$ for some $\theta$ does not depend on how the function behaves elsewhere - read in any other $\theta$. And similarly in a discrete analogue with only two values of $\theta$ - $\theta_1$ and $\theta_2$ - differentiating with respect to $p(\theta_1)$ nullifies the part of the expectation concerned with $p(\theta_2)$?! - if I get what you are saying.  
> **username_1**: That is the "bite" of the Lagrange multiplier method; all the dependency of $p(\theta_1)$ on $p(\theta_2)$ (and vice versa) is moved to the co-state $\lambda(\theta)$. The $\lambda(\theta)$ term is effectively a penalty for the effect that changing one $p(\theta_i)$ value has on the other $p(\theta_j)$'s.  
> **username_2**: Hi Joseph: Do you know of anything that expounds on your comment immediately above. I've read about lagrange multipliers ( over the years, off and on )  but never saw it described that way and it's interesting. Thanks. Oh, textbook or reference is great.  
> **username_3**: Can you provide the source of the maximization problem? The note you link to is also not accessible (link expired).  
> **username_0**: I added the source. But it is not available online to my knowledge.  

---

## 1 answers

### Answer by username_1 on 2024-07-22. Score: 3 | Accepted answer

I think the problem you’re having is that you’re solving for the optimal $p$ as a standard multivariable optimisation problem. There is a noticeable difference between functional optimisation compared with multivariate optimisation, but this difference is often ignored in economics in favour of heuristic methods.

In the problem you stated, we need to find the optimal $\textit{function}$ $p:(0,\infty)\to \mathbb{R}$ along with an optimal value of a $\textit{variable}$ $K$. Your first question likely stems from this difference.

The Lagrangian is $$\mathcal{L}=\mathbb{E}[S(p(\theta),\theta)-cD(p(\theta),\theta)+\lambda(\theta)(K-D(p(\theta),\theta))]-rK$$ The reason we have $\lambda(\theta)$ inside the expectation is that we have the constraint $D(p(\theta),\theta)\leq K$ holding for all $\theta$. If $\theta$ were drawn from some finite set $\Theta$, we would have the Lagrangian as $$\mathcal{L}=\sum\_{\theta'\in \Theta}[S(p(\theta'),\theta')-cD(p(\theta'),\theta')+\lambda(\theta')(K-D(p(\theta'),\theta'))]\mathbb{P}(\theta=\theta')-rK$$ which may be more familiar. The integral simply generalises this to the case when $\Theta$ is a continuum. It is also intuitive that the constraint should be within the expectation operator as it is a stochastic constraint. We know that for any $\theta$ realisation the constraint will bind, but since we don't know what value $\theta$ will take we consider an expectation over the possible realisations of the constraint.

Now we can move on to the optimisation problem.

Consider the variable optimisation problem, i.e., the choice of $K$. Taking the FOC of $\mathcal{L}$ w.r.t. $K$, we find (assuming regularity conditions on $S$ and $D$ allowing us to differentiate under the integral) that $$\begin{align\*} \frac{\partial \mathcal{L}}{\partial K} &=\frac{\partial }{\partial K}[\mathbb{E}[S(p(\theta),\theta)-cD(p(\theta),\theta)+\lambda(\theta)(K-D(p(\theta),\theta))]-rK] \\
&= \mathbb{E}\left[\frac{\partial }{\partial K}(S(p(\theta),\theta)-cD(p(\theta),\theta)+\lambda(\theta)(K-D(p(\theta),\theta)))\right]-r \\
&= \mathbb{E}[\lambda(\theta)]-r \end{align\*}$$

Second, for the functional optimisation problem, we should really take a variational approach. This answer by tdm gives a good overview of the methodology: [FOCs for the Dixit-Stiglitz aggregator: derivative of an integral w.r.t. integrand at one point](https://economics.stackexchange.com/questions/58727/focs-for-the-dixit-stiglitz-aggregator-derivative-of-an-integral-w-r-t-integra/58731#58731) . Suppose we are given an optimal function choice $p^\*$. Consider perturbing this optimal choice by any other $C^1$ function $g$ to $p^\*+\varepsilon g$. Define $$\mathcal{L}(f)=\mathbb{E}[S(f(\theta),\theta)-cD(f(\theta),\theta)+\lambda(\theta)(K-D(f(\theta),\theta))]-rK$$ Since $p^\*$ is optimal, we must have that $$\frac{\partial}{\partial \varepsilon} \mathcal{L}(p^\*+\varepsilon g)\Bigg|\_{\varepsilon=0}=0$$ Evaluation of this gives $$\begin{align\*} 0 &= \frac{\partial}{\partial \varepsilon} \mathcal{L}(p^\*+\varepsilon g)\Bigg|\_{\varepsilon=0} \\
&=\frac{\partial}{\partial \varepsilon} [\mathbb{E}[S(p^\*(\theta)+\varepsilon g(\theta),\theta)-cD(p^\*(\theta)+\varepsilon g(\theta),\theta)+\lambda(\theta)(K-D(p^\*(\theta)+\varepsilon g(\theta),\theta))]-rK]\Bigg|\_{\varepsilon=0} \\
&=\frac{\partial}{\partial \varepsilon} [\mathbb{E}[S(p^\*(\theta)+\varepsilon g(\theta),\theta)-cD(p^\*(\theta)+\varepsilon g(\theta),\theta)+\lambda(\theta)(K-D(p^\*(\theta)+\varepsilon g(\theta),\theta))]]\Bigg|\_{\varepsilon=0}\\
&=\mathbb{E}\left[\frac{\partial}{\partial \varepsilon}(S(p^\*(\theta)+\varepsilon g(\theta),\theta)-cD(p^\*(\theta)+\varepsilon g(\theta),\theta)+\lambda(\theta)(K-D(p^\*(\theta)+\varepsilon g(\theta),\theta)))\right]\Bigg|\_{\varepsilon=0} \\
&=\mathbb{E}\left[\frac{\partial S}{\partial p}(p^\*(\theta)+\varepsilon g(\theta),\theta)g(\theta)-(c+\lambda(\theta))\frac{\partial D}{\partial p}(p^\*(\theta)+\varepsilon g(\theta),\theta)g(\theta) \right]\Bigg|\_{\varepsilon=0} \\
&= \mathbb{E}\left[\left(\frac{\partial S}{\partial p}(p^\*(\theta)+\varepsilon g(\theta),\theta)-(c+\lambda(\theta))\frac{\partial D}{\partial p}(p^\*(\theta)+\varepsilon g(\theta),\theta)\right)g(\theta) \right]\Bigg|\_{\varepsilon=0} \\
&= \mathbb{E}\left[\left(\frac{\partial S}{\partial p}(p^\*(\theta),\theta)-(c+\lambda(\theta))\frac{\partial D}{\partial p}(p^\*(\theta),\theta)\right)g(\theta) \right] \end{align\*}$$

The above is equal to zero for any $g\in C^1$. Hence, assuming $S$ and $D$ are continuous (and that the optimal $p^\*$ is continuous), by the Fundamental Lemma of the Calculus of Variations, we must have $$\frac{\partial S}{\partial p}(p^\*(\theta),\theta)-(c+\lambda(\theta))\frac{\partial D}{\partial p}(p^\*(\theta),\theta)=0$$

What I meant in the comments about this being pointwise is that we can get the exact same result if we ignore the the expectation operator in $\mathcal{L}$ and take the derivative w.r.t. $p(\theta)$ for a fixed $\theta$. Generally this is acceptable if derivatives of $p(\theta)$ are not included in $\mathcal{L}$. If the first derivative is included, we can use the Euler-Lagrange equation to get a first-order condition.

> **Comments:**
> **username_0**: Thank you for the answer. It makes sense and the argumentation is convincing to me. Just like your comments. I am, however, not the one to judge whether this constitutes a mathematically sound proof. If no one else has anything to add on the matter I will definitely accept your answer. Thx. again for taking the time to write this up.  
> **username_2**: @Jesper Hybel: Thanks for the interesting question. I'm trying to follow the whole thing but the note that you linked to in your question at the bottom ( why the constraint is included in the expectation operator) is currently not working. It may not clear things up for me but it can't hurt. Thanks again.  
> **username_0**: I will refresh it but it is on something completely different. So prepare to be underwhelmed.  
> **username_2**: No problem. One last bother on this: Do you know of a reference that talks about where Joseph mentions: "That is the "bite" of the Lagrange Multiplier method in the comments at the top. It sounds like an interesting way to think about it especially because I'm used to the standard marginal cost-shadow price argument. Thanks.  
> **username_0**: Link has been updated and is also here: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2883305. No, I have no knowledge of where the idea of interpreting the Lagrange coefficient like that is followed through.  
> **username_4**: This answer (and also the question, +1 both) is very interesting, as it points out a distinction that in mathematics is far from trivial, the difference between optimization in usual calculus and the optimizations problems in which we must choose not the value of a variable, but a whole function, as in the calculus of variations.  
> **username_4**: In addition, we have here a stochastic context, that is stochastic processes, and therefore we are talking about *stochastic calculus of variations*,  which it is also called Mallavin calculus https://en.wikipedia.org  https://www.ams.org/journals/bull/2007-44-03/S0273-0979-07-01146-9/S0273-0979-07-01146-9.pdf. And also this is not a trivial generalization of calculus of variations.  I wonder if @Joseph Basford  could suggest an introductory text to this part of the theory of stochastic processes.  
> **username_1**: @BakerStreet thank you for your comments. What you’ve said betrays an assumption I’d accidentally hidden in my answer. I had assumed that $\theta$ was drawn from an absolutely continuous distribution, such that it admitted a probability density function, $f$ which was everywhere strictly positive. This fact is crucial for the derivation. If F admits no density, differentiation under the integral is not direct. Also, if the density is not everywhere positive, the FOC is multiplied by $f(\theta)$, so that when it is zero, we can pick $p(\theta)$ arbitrarily.  

---

