# Derivation of demand for intermediate goods in DSGE model

I'm self-studying Herbst-Schorfheide book on DSGE estimation and having troubles replicating their steps in the derivation of demand for final goods firms (Ungated model is here, page 3: http://ink.library.smu.edu.sg/cgi/viewcontent.cgi?article=1361&context=soe_research). Their final goods producers maximize profit function:

$\Pi_t = P_t (\int_0^1 Y_t(j)^{1-\nu} dj)^\frac{1}{1-\nu} - \int_0^1 P_t (j) Y_t(j) dj$

and get the demand:

$Y_t(j) = (\frac{P_t(j)}{P_t})^{-\frac{1}{\nu}} Y_t$

My trouble is that I cannot understand derivation steps: how FOC looks like and why? Help is much appreciated!

So I've seen this sort of thing where you basically differentiate with respect to each Y_j so the integral drops out (seen this in moral hazard chapter from MWG and Romer's endogenous growth model).

The foc becomes:

$P_t(Y_t(j)^{(1-v)})^{v/(1-v)}Y^{-v}-P_t(j)=0$

This gets the result.

To solve the problem you also need the equation:

$Y_t=\left(\int_0^1 Y_t(j)^{1-\nu} \ dj \right)^{\frac{1}{1-\nu}}$

Now, the FOC is the same for every $Y_t(j)$, so we only have to differentiate once. Applying the chain rule we get:

$\frac{\partial \Pi_t}{\partial Y_t(j)}=P_t \left(\int_0^1 Y_t(j)^{1-\nu} \ dj \right)^{\frac{\nu}{1-\nu}} Y_t(j)^{-\nu}-P_t(j)=0$

At this point, the trick of the trade is that

$\left(\int_0^1 Y_t(j)^{1-\nu} \ dj \right)^{\frac{\nu}{1-\nu}}$ which is a part of the FOC, equals $Y_t^{\nu}$ (check the first equation)

Setting $\left(\int_0^1 Y_t(j)^{1-\nu} \ dj \right)^{\frac{\nu}{1-\nu}}= Y_t^{\nu}$ in the FOC, and solving for $Y_t(j)$ will give the desired result.