During reading proof of Stirling's formula $n! \sim \sqrt{2n\pi}\left(\frac ne\right)^n$, I started finding the reason of $\pi$'s presence in the expression; which led to Gaussian Integral, i.e. $\int^{\infty}_{-\infty}{e^{-x^2}}dx = \sqrt{\pi}$.
The main suspect according to me in its derivation is:
$$ \left(\int_{-\infty}^{\infty} e^{-x^{2}} \, dx\right)^{2} = \int_{-\infty}^{\infty} e^{-x^{2}} \, dx \int_{-\infty}^{\infty} e^{-y^{2}} \, dy = \int_{-\infty}^{\infty} \int_{-\infty}^{\infty} e^{-(x^2+y^2)} \, dxdy. $$
This has that term $( x^2 + y^2 )$ which seems to be taking a sort of circle and consequently $\pi$ in the formula. I am not finding any bigger picture of how exactly this arrival is taking place here.
Question:
How can I visualize the Gaussian integral to get the intuition for $\pi$'s presence in it? Also,
$$ \left(\int_{-\infty}^{\infty} e^{-x^{2}} \, dx\right)^{2} = \int_{-\infty}^{\infty} e^{-x^{2}} \, dx \int_{-\infty}^{\infty} e^{-y^{2}} \, dy $$
is quite confusing for me from perspective of $x$ and $y$ axis' emergence out of area's square. (I know its correct mathematically, but this is something that has boggled the noggin of mine.)
Thanks.
I understand your frustration; the calculation tells us $\pi$ appears in the answer, but it seems to come from nowhere. What does exponentiation have to do with circles/rotation? Weirder still, why is it square-rooted?
Surprisingly, the best place to get an intuition for this isn't geometry; it's statistics.
One way to think of it is this. Since $r^2=x^2+y^2$, $\exp -r^2$ is separable in $x,\,y$ (meaning it's a function of $x$, times a function of $y$). Similarly, the Jacobian $r$ in $dxdy=rdrd\theta$ is separable (indeed, the "function of $\theta$" we'd use is constant, but that still counts). And where do separable functions famously come up? The "joint" distribution of independent random variables.
Now $2r\exp -r^2$ is a pdf on $[0,\,\infty)$, and $\frac{1}{2\pi}$ is a pdf on $[0,\,2\pi)$. Multiplying two expressions for $1$ to get another expression for $1$, we have a joint distribution for polar variables $r,\,\theta$ whereby they're also independent:
$$1=\int_{r\ge 0,\,0\le\theta\le2\pi}f(r,\,\theta)drd\theta,\,f:=\frac{1}{\pi}r\exp-r^2.$$But deliciously, this distribution also makes the Cartesian coordinates $x\leftrightarrow y$ independent! (In fact, you can show that, to within scaling, this is the only way for a distribution in the plane to satisfy both independence conditions.) Obviously we can rewrite the above integral as $$1=\int_{x,\,y\in\Bbb R}\frac{f(r,\,\theta)}{r}dxdy=\int_{x,\,y\in\Bbb R}\frac{1}{\pi}\exp\left(-x^2\right)\exp\left(-y^2\right)dxdy.$$The Cartesian formalism has the added beautiful consequence that the distributions of $x,\,y$ are identical. Indeed, $X$ has pdf $$\frac{1}{\sqrt{\pi}}\exp-x^2,$$which is equivalent to your original result. So in short, the reason $\sqrt{\pi}$ comes up is because of the very special way you can simultaneously make $x,\,y$ independent and $r,\,\theta$ independent.