Final Step in calculating option prices under the Heston Stochastic Volatility Model Let:
$$
\alpha = -\frac{u^2}{2}-\frac{iu}{2}+jiu\\
\beta = \lambda-\rho \eta i u - j \rho \eta\\
\gamma = \frac{\eta ^2}{2}\\
$$
where $j \in \{0,1\}$ and $i^2=-1$, $g=\frac{r_-}{r_+}$ and $r_{\pm}=\frac{\beta\pm \sqrt{\beta^2-4\alpha\gamma}}{2\gamma}=\frac{\beta \pm d }{\eta^2}$.
Then let:
$$
D(u,\tau)=r_-\frac{1-e^{-d\tau}}{1-ge^{-d\tau}}\\
C(u,\tau)=\lambda \left[\tau r_--\frac{2}{\eta^2}log(\frac{1-ge^{-d\tau}}{1-g}) \right]
$$
Where $\lambda$ is a constant.
For the function:
$$
\hat{P}_j(u,v,\tau)=\frac{1}{iu}exp\left[C(u,\tau)\bar{v}+D(u,\tau)v \right]
$$
$\bar{v}\in \mathscr R$.
Show that:
$$
P_j(x,v,\tau)=\int_{-\infty}^{\infty}\frac{e^{iux}}{2\pi} \hat{P_j}(u,v,\tau)du\\=\frac{1}{2}+\frac{1}{\pi}\int_0^\infty Re\left[\frac{exp[C_j(u,\tau)\bar{v}+D_j(u,\tau)v+iux]}{iu} \right]du
$$
This result comes up in a text I am reading on stochastic volatility models, it is stated but not proven, the math involved is probably way above my level, but it would be great to see the steps involved in proving this. I guess it just amounts to showing the imaginary part of this integral is equal to half.
I don't mean for the question to be lazy, I have worked through all other parts of this relatively long proof, this technique seems to be used a lot in stochastic volatility/liquidity models which I am interested in studying further, and that's the reason I posted.
 A: Gatheral leaves out something important and it makes all the difference for the derivation but not the final result. Specifically, on pg. 17 he states the following, $$\hat{P}(u,v,0)=\int_{-\infty}^\infty\Theta(x)e^{-iux}dx=\frac{1}{iu},$$ where $\Theta(x)$ is the Heaviside unit step function (as defined in his Eq. 2.7, take a look at his definition and convince yourself that it is basically the same as Wikipedias). But this is not true - there is a Dirac delta missing. See rule 313 column 3 on WP - Tables of important Fourier transforms. The equation should be: $$\hat{P}(u,v,0)=\int_{-\infty}^\infty\Theta(x)e^{-iux}dx=\frac{1}{iu}+\pi\delta(u),$$ where $\delta(x)$ is the Dirac delta distribution. Next, we have $$\hat{P}_j(u,v,t)=\exp(C[u,\tau]\bar{v}+D[u,\tau]v)\hat{P}_j(u,v,0)\\
=(\frac{1}{iu}+\pi\delta[u])\exp(C[u,\tau]\bar{v}+D[u,\tau]v).$$ Then $$\int_{-\infty}^\infty \frac{e^{iux}}{2\pi}\hat{P}_j(u)\text{d}u = \int_{-\infty}^\infty \frac{e^{iux}}{2\pi}(\frac{1}{iu}+\pi\delta[u])\exp(C[u,\tau]\bar{v}+D[u,\tau]v)\text{d}u.$$ Lets split this into two parts. Lets consider the integral over the delta function first. Noting that $C(0,\tau)=0$ and $D(0,\tau)=0$ we have $$ \int_{-\infty}^\infty \frac{e^{iux}}{2\pi}(\pi\delta[u])\exp(C[u,\tau]\bar{v}+D[u,\tau]v)\text{d}u=\frac{1}{2}.$$ Now consider the part with $\frac{1}{iu}$. Let $$\hat{P}'_j:=\frac{1}{iu}\exp(C[u,\tau]\bar{v}+D[u,\tau]v)$$
The important thing to notice is, assuming $j,\rho,\eta,\lambda$ and $\tau$ are real, that $r_\pm(u)$ is conjugate-even in $u$. That is, $r_\pm(-u)=r_\pm^\ast(u)$, where $\ast$ denotes complex conjugate. Then g and d and therefore $D$ and $C$ and therefore $\hat{P}'_j$ are conjugate-even. I make the additional assumption that $\bar{v}$ indicates the mean of the real parameter $v$ and not the complex conjugate. Then, $$\int_{-\infty}^\infty \frac{e^{iux}}{2\pi}\hat{P}'_j(u)\text{d}u = \int_{-\infty}^0 \frac{e^{iux}}{2\pi}\hat{P}'_j(u)\text{d}u + \int_{0}^\infty \frac{e^{iux}}{2\pi}\hat{P}'_j(u)\text{d}u \\ = \int_{0}^\infty \frac{e^{-iux}}{2\pi}\hat{P}'_j(-u)\text{d}u + \int_{0}^\infty \frac{e^{iux}}{2\pi}\hat{P}'_j(u)\text{d}u \\ = \frac{1}{2\pi}\int_{0}^\infty \left [ e^{-iux}\hat{P'}_j^\ast(u) +  e^{iux}\hat{P}'_j(u) \right ]\text{d}u \\ = \frac{1}{\pi}\int_{0}^\infty  \text{Re}\left[e^{iux}\hat{P}'_j(u) \right ]\text{d}u. $$ On the last line I have used the identity $2\text{Re}(z)=z+z^\ast$.
Putting it all together gives $$P_j(x,v,\tau)=\frac{1}{2}+\frac{1}{\pi}\int_{0}^\infty  \text{Re}\left[e^{iux}\hat{P}'_j(u) \right ]\text{d}u,$$ which is the solution in the book.
Update:
If you remain unsatisfied and are skeptical that Gatheral omitted the delta, consider this:
On pg 19 Gatheral gives the conditions $C(u,0)=0$ and $D(u,0)=0$. Note again that according to his definition, $\hat{P}(u,v,0)=1/(iu)$. Then, using the inverse transform as he defines in Eq. 2.8, this gives $$\Theta(x)=\lim_{\tau \rightarrow 0}P_j(x,v,\tau)=\lim_{\tau \rightarrow 0}\int_{-\infty}^\infty \frac{1}{2\pi iu}\exp(C[u,\tau]\bar{v}+D[u,\tau]v)e^{iux}du\\=\int_{-\infty}^\infty \frac{1}{2\pi iu}e^{iux}du \\ = \frac{1}{2}\text{sgn}(x) \neq \Theta(x)$$ where on the last line we used the inverse transform version of rule 309 on the WP fourier transform page. Notice that this answer is off by exactly $1/2$! That is, $1/2+ (1/2)\text{sgn}(x)=\Theta(x)$. In other words, Gatheral omitted the delta and his derivation as printed is not self-consistent. It should be noted, however, that the omission does not affect his final result (which remains valid).
