Planck's law
For a general introduction, see black body.
In physics, Planck's law describes the spectral radiance of electromagnetic radiation at all wavelengths from a black body at temperature T. As a function of frequency \nu, Planck's law is written as:
This function represents the emitted power per unit area of emitting surface, per unit solid angle, and per unit frequency. Sometimes, Planck's law is written as an expression u(\nu,T) = \pi I(\nu,T) for emitted power integrated over all solid angles. In other cases, it is written as u(\nu,T) = 4\pi I(\nu,T)/c for energy per unit volume.
The function I(\nu,T) peaks for h\nu = 2.82kT.  It falls off exponentially at higher frequencies and polynomially at lower.
As a function of wavelength , Planck's law written (for unit solid angle) as:
This function peaks for hc = 4.97kT, a factor of 1.76 shorter in wavelength (higher in frequency) than the frequency peak.  It is the more commonly used peak in Wien's displacement law.
The radiance emitted over a frequency range  or a wavelength range  =  can be obtained by integrating the respective functions.
The order of the integration limits is reversed because increasing frequencies correspond to decreasing wavelengths.
The following table provides the definition and SI units of measure for each symbol:

# Overview
The wavelength is related to the frequency by:
The law is sometimes written in terms of the spectral energy density
which has units of energy per unit volume per unit frequency (joule per cubic meter per hertz). Integrated over frequency, this expression yields the total energy density. The radiation field of a black body may be thought of as a photon gas, in which case this energy density would be one of the thermodynamic parameters of that gas.
The spectral energy density can also be expressed as a function of wavelength:
as shown in the derivation below.
Max Planck originally produced this law in 1900 (published in 1901) in an attempt to improve upon the Wien approximation, published in 1896 by Wilhelm Wien, which fit the experimental data at short wavelengths (high frequencies) but deviated from it at long wavelengths (low frequencies). The Rayleigh-Jeans law (first published in incomplete form by Rayleigh in 1900) fit well in the complementary domain (long wavelength, low frequency).  Planck found that the above function, Planck's function, fitted the data for all wavelengths remarkably well. 
In constructing a derivation of this law, he considered the possible ways of distributing electromagnetic energy over the different modes of charged oscillators in matter. Planck's law emerged when he assumed that the energy of these oscillators was limited to a set of discrete, integer multiples of a fundamental unit of energy, E, proportional to the oscillation frequency :
Planck made this quantization assumption five years before Albert Einstein hypothesized the existence of photons as a means of explaining the photoelectric effect.  At the time, Planck believed that the quantization applied only to the tiny oscillators that were thought to exist in the walls of the cavity (what we now know to be atoms), and made no assumption that light itself propagates in discrete bundles or packets of energy.  Moreover, Planck did not attribute any physical significance to this assumption, but rather believed that it was merely a mathematical device that enabled him to derive a single expression for the black body spectrum that matched the empirical data at all wavelengths.
Although Planck's formula predicts that a black body will radiate energy at all frequencies, the formula is only practically applicable when many photons are being measured. For example, a black body at room temperature (300 kelvin) with one square meter of surface area  will emit a photon in the visible range once about every thousand years or so, meaning that for most practical purposes, a black body at room temperature does not emit in the visible range. Significance of this fact for the derivation of Planck's law from experimental data, and for the substantiation of the law by the data, is discussed in 
Ultimately, Planck's assumption of energy quantization and Einstein's photon hypothesis became the fundamental basis for the development of quantum mechanics.

# Derivation
The following derivation of Planck's law can be found, e.g., in . See also the gas in a box article for a general derivation.
Consider a cube of side L with conducting walls filled with electromagnetic radiation.
At the walls of the cube, the parallel component of the electric field and the orthogonal component of the magnetic field must vanish. Analogous to the wave function of a particle in a box, one finds that the fields are superpositions of periodic functions. The three wavelengths \lambda_{1}, \lambda_{2} and \lambda_{3}, in the three directions  orthogonal to the walls can be:
where the n_{i} are integers. For each set of integers n_{i} there are two linear independent solutions (modes). According to quantum theory, the energy levels of a mode are given by:
The quantum number r can be interpreted as the number of photons in the mode. The two modes for each set of n_{i} correspond to the two polarization states of the photon which has a spin of 1. Note that for r=0 the energy of the mode is not zero. This vacuum energy of the electromagnetic field is responsible for the Casimir effect. In the following we will calculate the internal energy of the box at temperature T relative to the vacuum energy.
According to statistical mechanics, the probability distribution over the energy levels of a particular mode is given by:
Here
The denominator Z(\beta), is the partition function of a single mode and makes P_{r} properly normalized:
Here we have implicitly defined
which is the energy of a single photon. As explained here, the average energy in a mode can be expressed in terms of the partition function:
This formula is a special case of the general formula for particles obeying Bose-Einstein statistics. Since there is no restriction on the total number of photons, the chemical potential is zero.
The total energy in the box now follows by summing \left\langle E\right\rangle over all allowed single photon states. This can be done exactly in the thermodynamic limit as L approaches infinity. In this limit, \varepsilon becomes continuous and we can then integrate \left\langle E\right\rangle over this parameter. To calculate the energy in the box in this way, we need to evaluate how many photon states there are in a given energy range. If we write the total number of single photon states with energies between \varepsilon and \varepsilon + d\varepsilon as g(\varepsilon)\,d\varepsilon, where g(\varepsilon) is the density of states which we'll evaluate in a moment, then we can write:
To calculate the density of states we rewrite equation (1) as follows:
where n is the norm of the vector \vec{n}=\left(n_{1},n_{2},n_{3}\right):
For every vector n with integer components larger than or equal to zero there are two photon states. This means that the number of photon states in a certain region of n-space is twice the volume of that region. An energy range of d\varepsilon corresponds to shell of thickness dn= (2L/hc) d\varepsilon in n-space. Because the components of \vec{n} have to be positive, this shell spans an octant of a sphere. The number of photon states g(\varepsilon)\,d\varepsilon in an energy range d\varepsilon is thus given by:
Inserting this in Eq. (2) gives:
From this equation one easily derives the spectral energy density as a function of frequency u(\nu,T) and as a function of wavelength u(\lambda,T):
where:
u(\nu,T) is known as the black body spectrum.  It is a spectral energy density function with units of energy per unit frequency per unit volume.
And:
where
This is also a spectral energy density function with units of energy per unit wavelength per unit volume. Integrals of this type for Bose and Fermi gases can be expressed in terms of polylogarithms. In this case, however, it is possible to calculate the integral in closed form using only elementary functions. Substituting
in Eq. (3), makes the integration variable dimensionless giving:
where J is given by:
We prove this result in the Appendix below.
The total electromagnetic energy inside the box is thus given by:
where V=L^3 is the volume of the box. (Note - This is not the Stefan-Boltzmann law, which is the total energy radiated by a black body. See that article for an explanation.) Since the radiation is the same in all directions, and propagates at the speed of light (c), the spectral radiance (energy/time/area/solid angle/frequency) is
which yields
It can be converted to an expression for I'(\lambda,T) in wavelength units by substituting \nu by c/\lambda and evaluating

# Percentiles
The shape of Planck's law is independent of temperature.  It is therefore possible to list the percentile points of the total radiation as well as the peaks for wavelength and frequency, in a form which gives the wavelength \lambda when divided by temperature T.  The second row of the following table lists those x for which the wavelength \lambda = x/T microns at the radiance percentile point given by the corresponding entry in the first row.
The wavelength and frequency peaks are in bold and occur at 25.0% and 64.6% respectively.  The 41.8% point is the wavelength-frequency-neutral peak.  These are the points at which the quotients by e^{h\nu/kT}-1 of the respective Planck-law functions 1/\lambda^5, \nu^3, and (\nu/\lambda)^2 attain their maxima.
Which peak to use depends on the application.  The conventional choice is the wavelength peak at 25.0% given by Wien's displacement law.  For some purposes the median or 50% point dividing the total radiation into two halves may be more suitable.  The latter is closer to the frequency peak than to the wavelength peak because the radiance drops exponentially at short wavelengths and only polynomially at long.  The neutral peak occurs at a shorter wavelength than the median for the same reason.
For the Sun, T = 5778 K, allowing the percentile points of the Sun's radiation from 10% to 90%, in nanometers, to be tabulated as follows when modeled as a black body radiator, to which the Sun is a fair approximation.
This is the radiation arriving at the top of the atmosphere.  Radiation below 400 nm, or ultraviolet, is about 12%, while that above 700 nm, or infrared, starts at about the 49% point and so accounts for 51% of the total. The atmosphere shifts these percentages substantially in favor of visible light as it absorbs most of the ultraviolet and significant amounts of infrared.

# History
Many popular science accounts of quantum theory, as well as some physics textbooks, contain some serious errors in their discussions of the history of Planck's Law.  Although these errors were pointed out over forty years ago by historians of physics, they have proved to be difficult to eradicate. An article by Helge Kragh gives a lucid account of what actually happened.
Contrary to popular opinion, Planck did not quantize light; this is evident from his original 1901 paper 
and the references therein to his earlier work.  He also plainly explains in his book "Theory of Heat Radiation" that his constant refers to Hertzian oscillators.  The idea of quantization was developed by others into what we now know as quantum mechanics. The next step along this direction was made by Albert Einstein, who, by studying the photoelectric effect, proposed a model and equation whereby light was not only emitted but also absorbed in packets or photons. Then, in 1924, Satyendra Nath Bose developed the theory of the statistical mechanics of photons, which allowed a theoretical derivation of Planck's law.
Contrary to another myth, Planck did not derive his law in an attempt to resolve the "ultraviolet catastrophe", the name given by Paul Ehrenfest to the paradoxical result that the total energy in the cavity tends to infinity when the equipartition theorem of classical statistical mechanics is applied to black body radiation. Planck did not consider the equipartition theorem to be universally valid, so he never noticed any sort of "catastrophe"  it was only discovered some five years later by Einstein, Lord Rayleigh, and Sir James Jeans.

# Appendix
A simple way to calculate the integral
is to calculate the general case first and then compute the answer at the end. Consider the integral
Since the denominator is always less than one, we can expand it in powers of e^{-x} to get a convergent series
Here we have used the formula for the sum of a geometric series.  The fraction on the left is the expression for the series indicated by the summation:  1 + e^{-x} + e^{-2x} + e^{-3x} + \cdots.  The common multiplier is e^{-x}.
Then we have
Multiplication by the e^{-x} on the left shifts our summation series one position to the right.  That is, 1 + e^{-x} + e^{-2x} + \cdots becomes e^{-x} + e^{-2x} + e^{-3x} + \cdots.  Therefore, we bump the index up by one and drop the e^{-x}:
By changing variables such that u = kx, thereby making x^n = \frac{u^n}{k^n} and dx = \frac{du}{k}, we have
-r,
Since each term in the sum represents a convergent integral, we can move the summation out from under the integral sign:
The summation on the left is the Riemann zeta function \zeta(n+1), while the integral on the right is the Gamma function  \Gamma(n+1) , and we are finally left with the general result
-r equivalently
For our problem, the numerator contains x^3, leaving us with our specific result
Here we have used the fact that
is the Riemann zeta function evaluated for the argument 4, which is given by \pi^{4}/90. (See "Finding Zeta(4)" at Wallis product for a simple though lengthy derivation of \zeta(4).  This fact can also be proven by considering the following contour integral.)
Where C_{R} is a contour of radius R around the origin. In the limit, as R approaches infinity, the integral approaches zero. Using the residue theorem the integral can also be written as a sum of residues at the poles of the integrand. The poles are at zero, the positive and negative integers. The sum of the residues yields precisely twice the desired summation plus the residue at zero. Because the integral approaches zero, the sum of all the residues must be zero. The summation must therefore equal minus one half times the residue at zero. From the series expansion of the cotangent function
\cot(x)=\frac{1}{x} - \frac {x}{3} - \frac {x^3} {45} +\ldots,
we see that the residue at zero is -\pi^{4}/45 which yields the desired result. The evaluation of the Gamma function can be done by recognizing that for integral values of n, \Gamma(n+1) = n!. In the appendix of the article Stefan-Boltzmann law we give a different derivation of this integral. (See also the integral of the Bose-Einstein distribution in the polylogarithm article.)