<p>Here's what I got for <span class="math-container">$\nu B_{\nu}(T)$</span> using Python, which is easy enough to read that maybe you can check against your Excel calculation. I also plotted just <span class="math-container">$B_{\nu}(T)$</span> for comparison.</p>

<p>Neither looks like a straight line and they shouldn't. If you print out <span class="math-container">$\log_{10}(k_B T / c)$</span> you get about 16.2 which is right in the middle of your range. They've specified a range of frequencies centered roughly on the peak of the Planck distribution.</p>

<p><a href="https://i.sstatic.net/U4PNJ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/U4PNJ.png" alt="enter image description here"></a></p>

<pre><code>def Bnu(nu, T):
    top = 2 * h * nu**3 / c**2
    bot = np.exp(h * nu / (kB * T)) - 1.
    return top/bot

import numpy as np
import matplotlib.pyplot as plt

h  = 6.6261E-34 # m^2 kg / s
c  = 2.9979E+08 # m / s
kB = 1.3806E-23 # m^2 kg / s^2 K

T   = 7.3E+05  # K

print "log10(kB T / h): ", np.log10(kB * T / h)

nu  = np.logspace(15.5, 17.5, 201) # Hz

lam = c / nu

print nu.min(), nu.max(), 'Hz'
print 1E+09*lam.min(), 1E+09*lam.max(), 'nm'

B = Bnu(nu, T)

plt.figure()

plt.subplot(1, 2, 1)
plt.title('B(nu, T)', fontsize=16)
plt.plot(nu, B)
plt.yscale('log')
plt.xscale('log')

plt.subplot(1, 2, 2)
plt.title('nu x B(nu, T)', fontsize=16)
plt.plot(nu, nu * B)
plt.yscale('log')
plt.xscale('log')

plt.show()
</code></pre>

CC BY-SA 4.0
2019-04-28T03:16:05.243Z
2019-04-28T08:41:32.163Z
2019-04-28T08:41:32.163Z
uhoh
<p>Here is my problem statement:</p>

<p>For a temperature of <span class="math-container">$7.3 \times 10^5 \ \text{K}$</span>, make a graph of the Plank function (Eq. 3.24), plotting <span class="math-container">$\log_{10}{\nu} B_\nu(T)$</span> vs <span class="math-container">$\log_{10} \nu$</span> for <span class="math-container">$\log_{10} \nu$</span> between 15.5 and 17.5. How does the behaviour of your graph of a blackbody compare with that of Fig. 28.14 for the continuous spectrum of the quasar 3C 273?</p>

<p>Here is the equation 3.24</p>

<p><span class="math-container">\begin{equation}
    B_\nu (T) = \frac{2h \nu^3/c^2}{e^{h\nu/kT}-1}.
\end{equation}</span></p>

<p>I have put together an excel spreadsheet and created a graph of <span class="math-container">$\log_{10}({\nu} B_\nu(T))$</span> vs <span class="math-container">$\log_{10} (\nu)$</span>, however, it is just a straight line (which is what I would have expected although the graph in the book is significantly different). I am wondering if I am misunderstanding the problem statement. What I did to get my data points for <span class="math-container">$\log_{10}{\nu} B_\nu(T)$</span> is I first computed <span class="math-container">$\nu$</span> values from the given range of <span class="math-container">$\log_{10} \nu$</span> values, then I computed B(T) values with the above-given equation. Then I substituted the product into logarithm : <span class="math-container">$\log_{10}({\nu} B_\nu(T))$</span>, thus obtaining my <span class="math-container">$y = f(x)$</span> values. and then I plotted it against  <span class="math-container">$x = \log_{10} \nu$</span>. Am I doing things wrong or is this fine?</p>

CC BY-SA 4.0
2019-04-28T03:17:11.310Z
*Welcome to Stack Exchange!* If you are seeing a straight line, then I think you may have something wrong. See [this answer](https://astronomy.stackexchange.com/a/31671/7982). Can you copy the lines you've written in the spreadsheet cells and paste them into your question? That may be where the problem is, but without it it's hard to guess what's wrong.
uhoh
CC BY-SA 4.0
2019-04-29T15:37:10.277Z
I'm voting to close this question as off-topic because this is asking for programming help, not astronomy
Carl Witthoft
CC BY-SA 4.0
2019-04-29T15:38:20.477Z
BTW,  if at all possible,  do **not** use Excel.  Grab Python, R, Matlab, FreeMat, etc.
Carl Witthoft
<black-body>
Trouble with plotting a graph for the Planck function
Elen Khachatryan
# Trouble with plotting a graph for the Planck function

(Asked by: username_0 on 2019-04-27)

Here is my problem statement:

For a temperature of $7.3 \times 10^5 \ \text{K}$, make a graph of the Plank function (Eq. 3.24), plotting $\log\_{10}{\nu} B\_\nu(T)$ vs $\log\_{10} \nu$ for $\log\_{10} \nu$ between 15.5 and 17.5. How does the behaviour of your graph of a blackbody compare with that of Fig. 28.14 for the continuous spectrum of the quasar 3C 273?

Here is the equation 3.24

\begin{equation}
B\_\nu (T) = \frac{2h \nu^3/c^2}{e^{h\nu/kT}-1}.
\end{equation}

I have put together an excel spreadsheet and created a graph of $\log\_{10}({\nu} B\_\nu(T))$ vs $\log\_{10} (\nu)$, however, it is just a straight line (which is what I would have expected although the graph in the book is significantly different). I am wondering if I am misunderstanding the problem statement. What I did to get my data points for $\log\_{10}{\nu} B\_\nu(T)$ is I first computed $\nu$ values from the given range of $\log\_{10} \nu$ values, then I computed B(T) values with the above-given equation. Then I substituted the product into logarithm : $\log\_{10}({\nu} B\_\nu(T))$, thus obtaining my $y = f(x)$ values. and then I plotted it against $x = \log\_{10} \nu$. Am I doing things wrong or is this fine?

**Tags:** black-body
> **Comments:**
> **username_1**: *Welcome to Stack Exchange!* If you are seeing a straight line, then I think you may have something wrong. See [this answer](https://astronomy.stackexchange.com/a/31671/7982). Can you copy the lines you've written in the spreadsheet cells and paste them into your question? That may be where the problem is, but without it it's hard to guess what's wrong.  
> **username_2**: I'm voting to close this question as off-topic because this is asking for programming help, not astronomy  
> **username_2**: BTW,  if at all possible,  do **not** use Excel.  Grab Python, R, Matlab, FreeMat, etc.  

---

## 1 answers

### Answer by username_1 on 2019-04-28. Score: 3 | Accepted answer

Here's what I got for $\nu B_{\nu}(T)$ using Python, which is easy enough to read that maybe you can check against your Excel calculation. I also plotted just $B_{\nu}(T)$ for comparison.
Neither looks like a straight line and they shouldn't. If you print out $\log_{10}(k_B T / c)$ you get about 16.2 which is right in the middle of your range. They've specified a range of frequencies centered roughly on the peak of the Planck distribution.

def Bnu(nu, T):
    top = 2 * h * nu**3 / c**2
    bot = np.exp(h * nu / (kB * T)) - 1.
    return top/bot

import numpy as np
import matplotlib.pyplot as plt

h  = 6.6261E-34 # m^2 kg / s
c  = 2.9979E+08 # m / s
kB = 1.3806E-23 # m^2 kg / s^2 K

T   = 7.3E+05  # K

print "log10(kB T / h): ", np.log10(kB * T / h)

nu  = np.logspace(15.5, 17.5, 201) # Hz

lam = c / nu

print nu.min(), nu.max(), 'Hz'
print 1E+09*lam.min(), 1E+09*lam.max(), 'nm'

B = Bnu(nu, T)

plt.figure()

plt.subplot(1, 2, 1)
plt.title('B(nu, T)', fontsize=16)
plt.plot(nu, B)
plt.yscale('log')
plt.xscale('log')

plt.subplot(1, 2, 2)
plt.title('nu x B(nu, T)', fontsize=16)
plt.plot(nu, nu * B)
plt.yscale('log')
plt.xscale('log')

plt.show()


---

