title: I am trying to vectorize the scalar function
body: <p>Here the code I had written</p>
  <pre><code>def scalar_function(x, y):
      &quot;&quot;&quot;
      Returns the f(x,y) defined in the problem statement.
      &quot;&quot;&quot;
      if x&lt;=y:
         return (np.dot(x,y))
      else:
         return(x/y)
  
  def vector_function(x, y):
      &quot;&quot;&quot;
      Make sure vector_function can deal with vector input x,y 
      &quot;&quot;&quot;
      vfunc = np.vectorize(scalar_function(x,y))
      return vfunc
  </code></pre>
  <p>Here is am trying to do as::scalar_function can only handle scalar input, we could use the function np.vectorize() turn it into a vectorized function. Note that the input argument of np.vectorize() should be a scalar function, and the output of np.vectorize() is a new function that can handle vector input.</p>
  <p>But after running it I got an error</p>
  <pre><code>TypeError: unsupported operand type(s) for -: 'float' and 'vectorize'
  </code></pre>
  <p>Now I don't know what to do</p>
  <pre><code>NumPy as np
  </code></pre>
  <p>has imported already
  Thank you</p>