(PC-12xx~14xx) qthsh Tanh-Sinh quadrature
|
04-24-2021, 08:24 PM
Post: #71
|
|||
|
|||
RE: (PC-12xx~14xx) qthsh Tanh-Sinh quadrature
(04-24-2021 02:31 AM)robve Wrote: Some progress. The following updated and improved method predicts an optimal splitting point d for Exp-Sinh quadratures \( \int_a^\infty f(x)\,dx = \int_a^d f(x)\,dx + \int_d^\infty f(x)\,dx \). The method uses bisection with an exponential scale. The method inspects 2 or 4 points to check if an optimization is applicable. Bisection uses just 8 points to find a close-to-optimal d. Max. of 12 points ... impressive For illustration purpose, I tried 1 from Appendix C, where suggested d does most good. (there were 1 that does better, but integrand is oscillatory, so it might be just luck) lua> f = function(x) local y=sqrt(x*x-1); return exp(-y*11/1000)*x/y end lua> Q.exp_sinh_opt_d(f, 1) -- default eps=1e-9, d=1. 512 Code: N x f(1+x) f(1+x)*x sign(top-bot) I also made a version based on peak, and extrapolate for x-intercept. I've noticed after the peak, the curve mostly go straight down. (code use tangent line of last point, of the fitted quadratic) Of course, with peak, there are really 2 valleys. Code assumed optimal d is to the right of peak. Code: function Q.peak(f, a, d) lua> Q.peak(f, 1) 89.13375894266683 399.8238469921945 Note that code evaluated an extra point passes the peak (when points are too close) This is to get a more reasonable slope for the tangent line. Without the extra point, we would get peak, x-intercept ≈ 88.25, 9106. Code: N x f(1+x) f(1+x)*x Let's see effect of suggested d, vs default d=1 lua> function quad(f,...) local s,e = Q.quad(Q.count(f),...); return s,e,Q.n end lua> quad(f, 1, huge) -- default d=1 90.90909088146049 3.999609164190213e-009 273 lua> quad(f, 1, huge, 512) -- sign change based d 90.90909089915341 6.360683358493127e-011 143 lua> quad(f, 1, huge, 400) -- x-intercept based d 90.90909089845148 2.0323842611238905e-011 143 lua> quad(f, 1, huge, 89) -- peak based d 90.90909089656193 4.928270670014641e-011 141 The peak may be used for d. In that case, exp-sinh transformed plot, when folded, turn into half a bell-shaped curve. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 6 Guest(s)