Not enough transparency in numerical integration

14 views
Skip to first unread message

maldun

unread,
Sep 16, 2010, 5:58:55 PM9/16/10
to mpmath
Hi,

I'm doing some (hopefully useful) improvements to the sage numerical
integration tool, and there is something bothering me.

If we consider for example highly oscillating integrals we run into
trouble: (I did the calculations in sage)

sage: mpmath.call(mpmath.quad,lambda a:
mpmath.exp(a)*mpmath.sin(1000*a),[0,pi])
-1.458868938634994559655
now compare this to the exact result:

sage: integrate(sin(1000*x)*exp(x),x,0,pi)
-1000/1000001*e^pi + 1000/1000001
sage: integrate(sin(1000*x)*exp(x),x,0,pi).n()
-0.0221406704921088

Well this was somehow expected, since the hight oscillation causes
troubles for the numerical integration, but what really bothers me,is
that there is absolutely no warning! But this is important because the
user has to know, if the result is trustworthy or not!

Pari also doesn't give any warnings.

SciPy does this:

sage: import scipy.integrate
sage: scipy.integrate.quad(lambda a: exp(a)*sin(1000*a),0,pi)
Warning: The integral is probably divergent, or slowly convergent.
(-0.1806104043408597, 0.092211010882734368)

But don't support arbitrary precision

For further improvements in Sage, but I also think for mpmath itself,
it is important to solve this.
I will give any help I can, but I'm quite a beginner, so be patient
with me...

greez,
maldun
Reply all
Reply to author
Forward
0 new messages