Learning Scientific Programming with Python (2nd edition)

P8.4.3: The Wien displacement law

Question P8.4.3

The Wien displacement law predicts that the wavelength of maximum emission from a black body described by Planck's law is proportional to $1/T$: $$ \lambda_\mathrm{max} T = b, $$ where $b$ is a constant known as Wien's displacement constant. Given the Planck distribution of emitted energy density as a function of wavelength, $$ u(\lambda, T) = \frac{8\pi^2hc}{\lambda^5}\frac{1}{e^{hc/\lambda k_\mathrm{B}T} - 1}, $$ determine the constant $b$ by using scipy.optimize.minimize_scalar to find the maximum in $u(\lambda, T)$ for temperatures in the range $500\;\mathrm{K} \le T \le 6000\;\mathrm{K}$ and fitting $\lambda_\mathrm{max}$ to a straight line against $1/T$. Compare with the "exact" value of $b$, which is available within scipy.constants (see Section 8.1.1 of the book).