Confusion related to derivation of product of gaussian I am confused. Given

how come this is derived?

 A: The main problem here is to complete the squares.
We have 
\begin{align}
\{x;\mu_1,\sigma_1^2\}\{x;\mu_2,\sigma_2^2\}&=\exp\left(-\frac{\sigma_1^{-2}(x-\mu_1)^2+\sigma_2^{-2}(x-\mu_2)^2}2\right)\\
&=\small\exp\left(-\frac{x^2(\sigma_1^{-2}+\sigma_2^{-2})-2x(\mu_1\sigma_1^{-2}+\mu_2\sigma_2^{-2})+\sigma_1^{-2}\mu_1^2+\sigma_2^{-2}\mu_2^2}2\right)\\
&=\exp\left(-\color{red}{(\sigma_1^{-2}+\sigma_2^{-2})}\frac{x^2-2x\frac{\mu_1\sigma_1^{-2}+\mu_2\sigma_2^{-2}}{\sigma_1^{-2}+\sigma_2^{-2}}+\frac{\sigma_1^{-2}\mu_1^2+\sigma_2^{-2}\mu_2^2}{\sigma_1^{-2}+\sigma_2^{-2}}}2\right)\\
&=\exp\left(-\frac{\sigma_1^{-2}+\sigma_2^{-2}}2\left(x-\frac{\mu_1\sigma_1^{-2}+\mu_2\sigma_2^{-2}}{\sigma_1^{-2}+\sigma_2^{-2}}\right)^2\right)\\
&\quad\cdot 
\exp\left(\frac{\left(\mu_1\sigma_1^{-2}+\mu_2\sigma_2^{-2}\right)^2}{2(\sigma_1^{-2}+\sigma_2^{-2})}-\frac{\sigma_1^{-2}\mu_1^2+\sigma_2^{-2}\mu_2^2}{2}\right) \\
&= \left\{x;\frac{\mu_1/\sigma_1^2+\mu_2/\sigma_2^2}{1/\sigma_2^2+1/\sigma_2^2}, (1/\sigma_1^2+1/\sigma_2^2)^{-1}\right\} \\
&\quad\cdot\exp\left(-\frac{\sigma_1^{-2}\sigma_2^{-2}(\mu_1 - \mu_2)^2}{2(\sigma_1^{-2}+\sigma_2^{-2})}\right) \\
&= \left\{x;\frac{\mu_1/\sigma_1^2+\mu_2/\sigma_2^2}{1/\sigma_2^2+1/\sigma_2^2}, (1/\sigma_1^2+1/\sigma_2^2)^{-1}\right\} \cdot\left\{\mu_1; \mu_2, \sigma_1^2 + \sigma_2^2\right\} \\
\end{align}
