Post Reply 
(PC-12xx~14xx) qthsh Tanh-Sinh quadrature
04-17-2021, 01:51 PM (This post was last modified: 04-17-2021 09:16 PM by robve.)
Post: #61
RE: (PC-12xx~14xx) qthsh Tanh-Sinh quadrature
(04-17-2021 12:03 AM)Albert Chan Wrote:  The plot showed a nice bell-shaped curve, easy to get area, simply by summing squares.

Rather than doing that, I think we can do better to quickly estimate an optimal d using a geometric sequence of points. I ran a few tests with this change to 'quad' for Exp-Sinh:

Code:
  else if (isfinite(a)) {
    int i;
    mode = 1; // Exp-Sinh
    for (i = 1; i <= 12; ++i) {
      v = 1 << i;
      printf("%d diff=%g\n", 1 << i, f(a + d/v)/v - f(a + v*d)*v);
    }
    c = a;
    v = a+d;
  }

Note what happens to 'diff' for these integrands:

exp(-.2*x) on [0,inf) d~45 is good
exp(-.1*x) on [0,inf) d~100 is good
exp(-.01*x) on [0,inf) d~700 is good
exp(-.001*x) on [0,inf) d~9000 is good
1/(x*x) on [1,inf) d~1 is good
1/(1+x*x) on [0,inf) d~1 is good
log(1+(x*x))/(x*x) on [0,inf] d~1 is good
(x*x*x)/(exp(x)-1) on [0,inf) d~7 is best d~8 is good
x/sinh(x) on [0,inf) d~9 is best d~8 is good
(x*x)/sqrt(exp(x)-1) on [0,inf) d~17 is best d~16 is good
pow(x,7)*exp(-x) on [0,inf) d~25 is best and d~32 is good
exp(-sqrt(x)) on [0,inf) d~81 is best and d~64 is good
exp(-x)*(x*x*x) on [0,inf) d~28 is good
exp(-x)*pow(x,5) on [0,inf) d~50 is good

Note the \( 2^i \) value when the diff sign changes, if it changes.

Periodic functions switch signs multiple times, these are not great to integrate with Exp-Sinh anyway e.g. sin(x)/(x*x) on [0,inf).

The idea of using geometric sequences to determine d aligns with the Exp-Sinh rule. This method is not perfect yet and certainly needs some tweaking.

- Rob

Edit: I checked 208 Exp-Sinh integrals from the benchmarks and they all show that this conceptually works. I've added some more interesting cases to the list.

"I count on old friends to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (PC-12xx~14xx) qthsh Tanh-Sinh quadrature - robve - 04-17-2021 01:51 PM



User(s) browsing this thread: 1 Guest(s)