title: Scipy: Maximize Distance between Interpolated Curves
body: <p>I have two interpolated curves created with <code>scipy.interpolate.interp1d</code> - how can I calculate the x value that maximizes the difference between these two curves?</p>
  
  <p>Here is the relevant code:</p>
  
  <pre><code>from scipy import interpolate
  
  units =   [0.0, 1.0, 2.0 ,..., 49.0, 50.0]
  revenue = [0.0, 1.2, 2.4 ,..., 79.1, 80.0]
  cost =    [0.3, 0.6, 0.9 ,..., 14.7, 15.0] 
  
  revenue_func = interpolate.interp1d(units,revenue,kind='cubic')
  cost_func = interpolate.interp1d(units,cost,kind='linear')
  </code></pre>
  
  <p>I need to find the value of units that maximizes <code>revenue_func - cost_func</code>.  This would be easy if I could limit the result to integer values for units, but I need to treat units as continuous between 0 and 50.</p>
  
  <p>I'm stumped on this one, and would really appreciate any suggestions - even those that use another package besides scipy</p>