How to integrate an array?

Robert Kern rkern at ucsd.edu
Sun Sep 4 16:02:37 EDT 2005


Tom Kaz wrote:
> I need to compute integral of some array function, something
> like:
> 
> from scipy import *
> f = lambda x: array( [sin(x),cos(x)] )
> integrate.quad(f, 0, 1)
> 
> Unfortunately integrate.quad requires Float type.
> 
> Any ideas how to perform this?

Do each function separately. The routine that scipy.integrate.quad uses
adapts to the local conditions of the function (when the function is
flat, it uses fewer samples; when steep, more).

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter




More information about the Python-list mailing list