First order conditions GK_2011

Hello everyone, I have recently been replicating the GK-2011 paper and encountered a problem when handling the first-order conditions. I am unsure how to derive the following equations for price dispersion and optimal pricing. Thank you in advance!!!

Price Dispersion

D_t=\gamma D_{t-1} \Pi_{t-1}^{-\gamma_p \varepsilon} \Pi_t^{\varepsilon}+(1-\gamma)\left(\frac{1-\gamma \Pi_{t-1}^{\gamma_p(1-\gamma)} \Pi_t^{\gamma-1}}{1-\gamma}\right)^{\frac{-\varepsilon}{1-\gamma}}

Optimal Pricing

\Pi_t^*=\Pi_t \frac{\varepsilon}{\varepsilon-1} \frac{F_t}{Z_t}

Auxiliary Variable

\begin{gathered} F_t=P_t^m Y_t+E_t \Lambda_{t, t+1} \beta \gamma \Pi_{t+1}^{\varepsilon} \Pi_t^{-\varepsilon \gamma_p} F_{t+1} \\ Z_t=Y_t+E_t \Lambda_{t, t+1} \beta \gamma \Pi_{t+1}^{\varepsilon-1} \Pi_t^{\gamma_{p(1-\varepsilon)}} Z_{t+1} \end{gathered}

In fact, I once attempted to derive the price dispersion following Professor Jpfeifer’s method for deriving price dispersion of Gali(2015), but the results I obtained were different from those in the paper.

\begin{aligned} D_t & =\int_0^1\left(\frac{P_t(i)}{P_t}\right)^{-\varepsilon} \, di \\ & =(1-\theta)\left(\frac{P_t^*}{P_t}\right)^{-\varepsilon}+\int_{D(i)}\left(\frac{P_{t-1}(i) \Pi_{t-1}^{\gamma_p}}{P_t}\right)^{-\varepsilon} \, di \\ & =(1-\theta)\left(\frac{P_t^*}{P_t}\right)^{-\varepsilon}+\Pi_{t-1}^{-\gamma_p \varepsilon} \int_{D(i)}\left(\frac{P_{t-1}}{P_t} \frac{P_{t-1}(i)}{P_{t-1}}\right)^{-\varepsilon} \, di \\ & =(1-\theta)\left(\frac{P_t^*}{P_t}\right)^{-\varepsilon}+\Pi_{t-1}^{-\gamma_p \varepsilon} \Pi_t^{\varepsilon} \int_{D(i)}\left(\frac{P_{t-1}(i)}{P_{t-1}}\right)^{-\varepsilon} \, di \\ & =(1-\theta)\left(\frac{P_t^*}{P_t}\right)^{-\varepsilon}+\theta \Pi_{t-1}^{-\gamma_p \varepsilon} \Pi_t^{\varepsilon} D_{t-1} \end{aligned}

You are pretty close. Try replacing the optimal price P_t^* using the definition of aggregate price index P_t. You will get the same expression of dispersion as the paper. Concerning the rest of the equations, they are standard in NK literature. Have a look at notes of Prof. Eric Sims or any other notes on NK models.

Thank you!