(PC-12xx~14xx) qthsh Tanh-Sinh quadrature
|
04-29-2021, 11:38 PM
Post: #74
|
|||
|
|||
RE: (PC-12xx~14xx) qthsh Tanh-Sinh quadrature
(04-29-2021 07:33 PM)robve Wrote: I noticed that when a sign change is detected, peak() also does overall very well, except for one strange case that costs a lot more, 180 points more for log(1+9*(x*x))/(1+16*(x*x)) where d=10.9477 which for a small d<1 is better, meaning the movement of d is in the wrong direction? Q.peak() got the direction wrong. (with points at 1/4, 1/2, 1. left side intercept ≈ 0.158) Q.peak() always go for the x-intercept of the right. In other words, it tried to push bulk of the area to \(\int_a^{a+d}\) Sometimes that is not appropriate, when we really need more points close to a. Without knowing the shape of curve, peak for d is the safe choice. Quote:Albert, you have the following "magic numbers" hardcoded without explanation: With quadratic fit, last two points cannot be too flat, otherwise tangent line would be way off. I had based on \(\int_0^∞ e^{-mx}\,dx\), with optimal d ≈ 6/m to 7/m. Let f(x) = exp(-m*x), g(x) = f(x)*x With g(2x)/g(x) ≈ 85%, we considered it just passes the peak. f(2x)/f(x) ≈ 0.85/2 = 0.425, or reverse direction: 1/0.425 = 2.353 With 85% setting, x-intercept roughly hit the sweet spot. lua> Q = require 'quad' lua> F = function(m) return function(x) return exp(-m*x) end end lua> for m=1,9 do p,x=Q.peak(F(m)); print(m, m*x) end 1 5.734205371025561 2 5.734205371025561 3 4.41325021172599 4 5.734205371025561 5 4.509031895026867 6 4.41325021172599 7 8.628727480200146 8 5.734205371025561 9 4.841791367031226 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)