[SciPy-User] Problems with scipy.integrate.quad and sinusoidal weights
Per Nielsen
evilper@gmail....
Fri Sep 28 03:51:58 CDT 2012
Hi all,
I am getting some strange (wrong or highly unaccurate) results when I try
to use scipy.integrate.quad to integrate highly oscillatory functions.
Please consider the following code:
In [40]: from scipy.integrate import quad
In [41]: from math import exp, sin, cos
In [42]: fsin = lambda x: exp(-x) * sin(100*x)
In [43]: quad(fsin, 0., 10., args=(), weight='sin', wvar=100.)
Out[43]: (0.4974066723952844, 0.0005303917238325333)
In [44]: quad(fsin, 0., 10., args=())
Out[44]: (0.0099990111781435, 0.0006814046027542903)
where the last line, without the weight function gives the correct result.
I have looked at the documentain for quad at:
https://github.com/scipy/scipy/blob/master/scipy/integrate/quadpack.py#L134
and to me this should be the way to integrate fsin. Am I misunderstanding
the arguments or whats going on? :)
Cheers,
Per
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20120928/8d16ae03/attachment.html
More information about the SciPy-User
mailing list