title: Planck's Energy Density Python
body: <p>I want to plot the graphs for different temperatures and frequencies in Python, I defined a function, but when I want to plot it, it shows me an error.</p>
  
  <pre><code>def planck(v,T):
      h=6.62606957*(10**-34.0)
      c=3*(10**8.0)
      k=1.3806488*(10**-23.0)
  
      x=(h*8*pi/c**3.0)
      y=v**3
      exponente = (h*v/k*T)
      ex = math.exp(exponente)-1
  
      PLANCK=(x*y)*(ex**-1)
      return PLANCK
  
  x0, xf, dx = 800,2*(10**8),1000  
  X = arange(x0, xf, dx)
  print X
  
  P1=planck(X, 3000)
  
  ---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-16-034ad82af010&gt; in &lt;module&gt;()
  ----&gt; 1 P1=planck(X, 3000)
  
  &lt;ipython-input-11-e52b9512e92c&gt; in planck(v, T)
        7     y=v**3
        8     exponente = (h*v/k*T)
  ----&gt; 9     ex = math.exp(exponente)-1
       10 
       11     PLANCK=(x*y)*(ex**-1)
  
   TypeError: only length-1 arrays can be converted to Python scalars
  </code></pre>
  
  <p>And then, if I just use <code>exp</code> instead of <code>math.exp</code>, the graph results a constant.</p>