Open GoogleCodeExporter opened 9 years ago
2/(3-cos(y)) evaluates to 1 when y is close to 0, and then ellipk returns +inf
It should work if you wrap the integrand with, say, extraprec(100).
The reason this only happens with tanh-sinh quadrature is that it uses
interpolation nodes much closer to the endpoints than the other algorithms.
Original comment by fredrik....@gmail.com
on 26 Jun 2013 at 5:13
Ah, okay I see, thank you! Works for me now. I apologize that this ended up
not being an actual issue.
I guess I'm not really understanding something here. If working at low
precision, and evaluating at y close to 0, suppose we get something like
1.0e500, which would count as infinity given a precision of 30, correct?
By using the extraprec decorator with sufficient n, func is able to resolve the
integrand, but then this number gets passed out to the internals of the
integrator, which are operating under the global precision of 30, no? Or does
the integrator tweak the precision as needed on its own?
Original comment by grant.wa...@gmail.com
on 26 Jun 2013 at 6:58
1.0e500 does not count as infinity. However, the numerical integration code in
mpmath is based on absolute errors and not relative errors, so it might fail to
converge if there are such large numbers.
The integrator does not tweak the precision except for adding a few guard bits
against normal rounding error. If the precision is 100 bits, say, then quad()
will set the precision to something like 110 bits and assume that this is
sufficient for evaluating the integrand accurately to 100 bits.
If 200 bits are required to evaluate the integrand accurately to 100 bits, then
user must increase the working precision appropriately inside the integrand.
The autoprec decorator can also be useful. In this case, it does not actually
help since two consecutive precisions both happen to produce the same value
(+inf).
Original comment by fredrik....@gmail.com
on 26 Jun 2013 at 7:08
Ok, thank you! Everything makes sense now.
Original comment by grant.wa...@gmail.com
on 26 Jun 2013 at 7:21
Original issue reported on code.google.com by
grant.wa...@gmail.com
on 24 Jun 2013 at 9:11