<s>[INST] Writing Fourier transform integral in terms of real-valued functions I am interested in the following integral.
$$ f(x,t) = \int \limits_{-\infty}^{\infty} \mathrm{d}k e^{-k^2}\left( e^{i(kx-pt-qk^2t)}+e^{i(kx+pt+qk^2t)} \right)$$
One way (for example, by using Mathematica) to solve it is in the following way.
$$ f(x,t) = \frac{\sqrt{\pi}}{2} \frac{(e^{-ipt}e^{\frac{ix^2}{-4i+4qt}}\sqrt{1-iqt}+e^{ipt}e^{\frac{-ix^2}{4i+4qt}}\sqrt{1+iqt})}{\sqrt{1+q^2t^2}} $$
I believe that $f(x,t)$ should be real valued, but it is not clear to me how to simplify given expression so that it consists only of real valued functions.
 [/INST] The two parts of your answer are obviously a complex conjugate pair.
Let's just take one of the terms and double its real part:
$$\begin{align*}f(x,t) &= \frac{\sqrt{\pi}}{2} \frac{(e^{-ipt}e^{\frac{ix^2}{-4i+4qt}}\sqrt{1-iqt}+e^{ipt}e^{\frac{-ix^2}{4i+4qt}}\sqrt{1+iqt})}{\sqrt{1+q^2t^2}}\\
\\
&= \sqrt{\pi}\;\Re\left[\frac{e^{-ipt}e^{-\frac{x^2}{4}\frac{1}{1+iqt}}}{\sqrt{1+iqt}}\right]\\
\\
&= \dfrac{\sqrt{\pi}}{\sqrt{1+q^2t^2}}\;\Re\left[\sqrt{1-iqt}\cdot e^{-ipt}e^{-\frac{x^2}{4}\frac{1-iqt}{1+q^2t^2}}\right] \\
\\
&= \dfrac{\sqrt{\pi}}{\sqrt{1+q^2t^2}}e^{-\frac{x^2}{4}\frac{1}{1+q^2t^2}}\;\Re\left[\sqrt{1-iqt}\cdot e^{-ipt}e^{-\frac{x^2}{4}\frac{-iqt}{1+q^2t^2}}\right] \\
\\
&= \dfrac{\sqrt{\pi}}{\sqrt{1+q^2t^2}}e^{-\frac{x^2}{4}\frac{1}{1+q^2t^2}}\;\Re\left[\sqrt{re^{i(\theta +2n\pi)}}\cdot e^{i\left(\frac{x^2}{4}\frac{qt}{1+q^2t^2}-pt\right)}\right] \\
\\
&= \dfrac{\sqrt{\pi}}{\sqrt{1+q^2t^2}}e^{-\frac{x^2}{4}\frac{1}{1+q^2t^2}}\;\Re\left[{\sqrt[4]{1+q^2t^2}e^{i(\theta/2 +n\pi)}}\cdot e^{i\left(\frac{x^2}{4}\frac{qt}{1+q^2t^2}-pt\right)}\right] \\
\\
&= \dfrac{\sqrt{\pi}}{\sqrt[4]{1+q^2t^2}}e^{-\frac{x^2}{4}\frac{1}{1+q^2t^2}}\;\Re\left[e^{i\left(\frac{\theta}{2}+n\pi+\frac{x^2}{4}\frac{qt}{1+q^2t^2}-pt\right)}\right] \\
\\
&= \dfrac{\sqrt{\pi}}{\sqrt[4]{1+q^2t^2}}e^{-\frac{x^2}{4}\frac{1}{1+q^2t^2}}\;\cos\left(\frac{\theta}{2}+n\pi+\frac{x^2}{4}\frac{qt}{1+q^2t^2}-pt\right) \\
\\
&= \dfrac{\sqrt{\pi}}{\sqrt[4]{1+q^2t^2}}e^{-\frac{x^2}{4}\frac{1}{1+q^2t^2}}\;\cos\left(\frac{\mathrm{arctan2}(-qt,1)}{2}+n\pi+\frac{x^2}{4}\frac{qt}{1+q^2t^2}-pt\right) \\
\\
\end{align*}$$
You can take $n=0$ for the principal value of the square root.  Or you can take $n=1$ and effectively just change the sign of the answer.
</s>