# How to calculate how many photons are in the universe?

The "universe" is a sphere with a radius of $10^{25}$ m the medium temperature is 3K, how many photons there are in the universe?

$$n_\gamma = \int_{0}^{\infty} \frac{8h\pi\nu^3} {{c^3}{}} \frac{1} {{e^\frac{h\nu} {KT} -1}{}}d\nu = 2.4\frac{8\pi} {c^3} (\frac{KT} {h})^3 \simeq 1.64* 10^{17} photons$$

but according to previous answers and other references...

the number is much bigger $$10^{89}$$

where is the problem in my tentative?

As you can see in my tentative, I would be better if the answer is based on "classical thermodynamic" using plack distribution, and a boltzmann-like point of view.

Estimation based on cosmological facts are also welcome.

When you solve the integral while you do some substitution you have to solve an integral like this $$\int_{0}^{\infty} \frac{x^2} {{e^x -1}{}} dx \simeq2.4$$

## 2 Answers

The number of photons in the Universe is dominated by the CMB photons, by two orders of magnitude (see this answer for a discussion of the Universal photon background). Each cm$$^3$$ of space holds roughly $$n_\gamma = 410$$ photons (see Sean Lake's nice calculation), so with a radius of 46.3 billion lightyears, or $$4.4\times10^{28}$$ cm, for the observable Universe — i.e. a volume of $$V = 3.5\times10^{86}$$ cm$$^3$$ — the total number of photons is $$N = n_\gamma V = 1.4\times10^{89}\,\mathrm{photons}.$$

As has been commented above, the number of photons is not really conserved. However, the amount of CMB photons that has been absorbed since they were emitted is actually negligible. The only interactions of these photons that alter their state is scattering on free electrons after the Universe was reionized (which happened 0.5 to 1 billion years after they were emitted). The optical depth to this so-called Thompson scattering is $$\tau = 0.066$$ (Planck collaboration 2015), so the fraction of CMB photons that have scattered is $$1 - e^{-0.066} = 0.06$$. But this process doesn't remove any photons from the budget, it only polarizes them.

You can convert the Planck function into the phase space number density of photons: $$n(\mathbf{x}, \mathbf{p}) = \frac{2}{h^3 \left[\operatorname{exp}\left(\frac{pc}{kT}\right) - 1\right]}.$$ Integrating that expression over both space and momenta gives a formula for the total number of photons: \begin{align} N & = \frac{8\pi V}{h^3} \left[\frac{kT}{c}\right]^3 \int_0^\infty \frac{u^2}{\operatorname{e}^u - 1} \operatorname{d} u \\ & = 16 \pi V \left[\frac{kT}{hc}\right]^3 \zeta(3),\end{align} c.f. the expression for $N$ in Wikipedia's photon gas article.

Using just the Cosmic Microwave Background (CMB), which is extremely close to a blackbody, will be a slight underestimate because it doesn't account for newly emitted light in the last 13 billion years or so, but not by much. The density of energy stored in the electromagnetic field is dominated by the CMB and, since it has mean frequency lower than most photons emitted since, the density of photons will be even more dominated by the CMB than the energy is.

For more, see this 2016 review by Cooray, especially Figure 1.