I'm trying to use an algorithm to find the wavelength maxima of the Planck function for a temperature T in Fortran 90. I used the golden selection search method to find the maximum wavelength of the Planck function for a given T, and compared it to Wien's displacement law. Here's the Planck function in terms of wavelength:
and here's a screenshot of my output:
Now, I know that my maxima finding search method is correct, since apparently according to this exercise, my Planck function, which is: intensity = (2.0d0*h*nu**(3.0d0))/c**(2.0d0) * 1d0 / (EXP((h*nu)/(k*T))-1d0)
will end up never agreeing with Wien's displacement law on the maximum wavelength. However, I am instead prompted to multiply use a new "modified" Planck function $B_{\nu,2}(T) = \nu^2 B_{\nu}(T)$ which then agreed with the Wien displacement law maximum wavelength with any temperature for up to seven digits or more.
Why is this now complying?


Wien's displacement law is in terms of frequency instead of wavelength. The Planck function has a shape that is dependent on the parametrization you use. In other words, the maxima will not be the same according to which parametrization you use.
EDIT: The quantity you study is itself a derivative w.r.t. either $\lambda$, either $\nu$. $B$ is a spectral density. But that means the spectral densities are connected by
$$B_{\lambda} = \frac{d\nu}{d\lambda} B_{\nu}$$
Since $\lambda\nu=c$, the scaling factor is exactly $\frac{d\nu}{d\lambda}=-\frac{\nu^2}{c}$. Note on the wikipedia page they add an extra $-$ sign, I suppose that's to keep the densities positive.