(PC-12xx~14xx) qthsh Tanh-Sinh quadrature
|
04-06-2021, 12:49 PM
Post: #25
|
|||
|
|||
RE: (PC-12xx~14xx) qthsh Tanh-Sinh quadrature
(04-06-2021 06:48 AM)emece67 Wrote: I've just tested re-using the previous fpl or fmi when the exception raises, but the end results are the same. I preferred original default of 0.0, instead of previous point. My first post here mentioned problems if u-transformation is applied. Instead of sharp point, when f(0) or f(1) = inf, it widened the problematic edge. (03-28-2021 06:59 PM)Albert Chan Wrote: >>> from mpmath import * This is not just an issue of u-transformation. Perhaps integrand already have fuzzy bad edge(s). Previous point for default will have "upward pressure" for the fuzzy edge. (this assumed previous point is next to current point; false if calculating points in parallel) Default of 0.0 will have "downward pressure" for the fuzzy edge. However, with double-exponential transform, I think more of the bad edge is closer to zero. Example, using above f, uf, and we apply u-transform to uf, getting uuf. Run double_exponential() with different behavior for "bad" edge, then square the result (should be pi) First number is points evaluated, reported from double_exponential() third entry. Code: Default Zero Previous Point --- I think setting 0.0 for any exceptions may be overkill. Example: if f(x) = x^p, and p is not yet defined, quadrature should raised NameError. Trap ArithmeticError is good enough (= OverflowError, ZeroDivisionError, FloatingPointError) On the other hand, Inf/NaN can occur without raising exceptions. >>> ln(0), atanh(1), exp(inf), inf-inf (mpf('-inf'), mpf('+inf'), mpf('+inf'), mpf('nan')) We should also test for these, like this patch for double_exponential.py Code: try: y = f(bpa2 + bma2*r) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)