By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,994 Members | 1,166 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,994 IT Pros & Developers. It's quick & easy.

How to integrate an array?

P: n/a
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?

Thanks,
T.Kaz.
Sep 4 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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
rk***@ucsd.edu

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

Sep 4 '05 #2

P: n/a
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).


It's not so easy to do it separately. I want to integrate function that
includes linalg.expm - as you see calculation the function is quite
expensive.

T.Kaz.
Sep 4 '05 #3

P: n/a
Tom Kaz wrote:

[I wrote:] (please attribute quotes)
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).


It's not so easy to do it separately. I want to integrate function that
includes linalg.expm - as you see calculation the function is quite
expensive.


I understand, but the good integration algorithms really do need to
evaluate each dimension separately.

If you can bear algorithms that only use samples from fixed intervals,
then you can use the functions romb(), simps(), or trapz() in
scipy.integrate.

BTW, a better place to ask scipy questions would be the scipy mailing list.

http://scipy.net/mailman/listinfo/scipy-user

--
Robert Kern
rk***@ucsd.edu

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

Sep 4 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.