Tue 11 Dec 2012 01:04:34 AM UTC, original submission:
I'm using quadcc (and comparing with quadgk) for an integral which in general has infinite bounds.
The function is
f = @(x) exp (-x .^ 2 / (2 * 500 ^ 2)) / (sqrt (2 * pi) * 500) .* (150e5 / 2) .* (22 - x) .^ 2 ./ (50 - (22 - x)) .* heaviside (-(22 - x), 1)
(the real coefficients and the Heaviside function relate to the physics that I'm modelling)
It has a large, finite value, which I can estimate with
> lim=1e5; quadcc ( f, -lim, lim, 1e-5 )
ans = 1.2703e+09
But with any larger limit (including Inf), quadcc returns 0:
> lim=1e6; quadcc ( f, -lim, lim, 1e-5 )
ans = 0
> lim=Inf; quadcc ( f, -lim, lim, 1e-5 )
ans = 0
quadgk is also misbehaving at large limits. I get the same solution (with some small error) at a limiting finite bound,
> lim=1e5; quadgk ( f, -lim, lim, 1e-5 )
warning: quadgk: maximum interval count (650) met
warning: quadgk: Error tolerance not met. Estimated error 0.000776351
ans = 1.2703e+09
> lim=1e6; quadgk ( f, -lim, lim, 1e-5 )
warning: quadgk: maximum interval count (650) met
warning: quadgk: Error tolerance not met. Estimated error 0.171285
ans = 1.2703e+09
but "mostly zero" at larger finite limits,
> lim=1e7; quadgk ( f, -lim, lim, 1e-5 )
ans = 5.4000e-131
But then at Inf, quadgk gives a finite value, meeting the correct value within gross error bars,
> lim=Inf; quadgk ( f, -lim, lim, 1e-5 )
warning: quadgk: Error tolerance not met. Estimated error 2.41746e+09
ans = 2.4847e+09
This quadgk behaviour is curious, but I understand quadgk is expected to come with greater error. I'm mainly filing this bug to address the misbehaviour in quadcc.
|