title: Convert sympy formula to values: unsupported operand type(s) for *: 'function' and 'float'
body: <p>I'm trying to draw a &quot;spherical coordinate system&quot; 3D formula using matplotlib and sympy.</p>
  <p>the formula was calculated as sympy formula,
  but I can't convert formula to values.</p>
  <p>I need to convert <code>result</code> to <code>numpy.ndarray</code> for matplotlib.</p>
  <p>I want to create numpy array, but I get array of sympy function!
  the commented lines are the codes I was test :|</p>
  <pre class="lang-py prettyprint-override"><code>import matplotlib.pyplot as plt
  import numpy as np
  import sympy as sp
  import math
  
  fact = math.factorial #sp.factorial
  exp = sp.exp
  cos = np.cos #sp.cos
  sin = np.sin #sp.sin
  pi = sp.pi #np.pi
  
  count = 20
  theta = np.linspace(0, 2 * np.pi, count)
  phi = np.linspace(0, np.pi, count)
  
  n = 3 #int(input(&quot;n:&quot;))
  l = 2 #int(input(&quot;l:&quot;))
  m = 2 #int(input(&quot;m:&quot;))
  
  def sqrt_n(x, n):
      return x**(1/float(n))
  
  def diff(f, n):
      fn = f
      for i in range(n):
          fn = sp.diff(fn)
      return fn
  
  # some other calculation functions ...
  
  def PSI(n,l,m, r, theta, phi):
      a1 = (2/n)**3
      a2 = fact(n-l-1)
      a3 = 2*n* fact(n+l)**3
      a = a1 * a2 / a3
      b = exp(-r/n)
      c = sp.diff(2*r/n)
      d = L2(2*l+1,n-l-1, 2*r/n)
      #e = Y(m,l, theta,phi)
      return sp.sqrt(a) * b * c * d #* e
  
  x = sp.Symbol('x')
  result = PSI(n,l,m, x,theta,phi)
  
  # THE PROBLEM: HOW TO CONVERT? &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;
  
  #R = result.rhs
  R = sp.lambdify(x, result, 'numpy')
  #eqR = sp.Eq(result, 0)
  #R = sp.solve(eqR, x)
  
  THETA, PHI = np.meshgrid(theta, phi)
  # HERE THE ERROR OCCURS: unsupported operand type(s) for *: 'function' and 'float' &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;
  XX = R * np.sin(PHI) * np.cos(THETA)
  YY = R * np.sin(PHI) * np.sin(THETA)
  ZZ = R * np.cos(PHI)
  
  fig = plt.figure()
  ax = fig.add_subplot(111, projection='3d')
  plot = ax.plot_surface(XX, YY, ZZ)
  plot = ax.plot_wireframe(XX, YY, ZZ, color='w', linewidth=0.05)
  plt.show()
  </code></pre>