Post Reply 
(PC-12xx~14xx) qthsh Tanh-Sinh quadrature
04-18-2021, 12:56 PM (This post was last modified: 04-19-2021 07:01 PM by robve.)
Post: #65
RE: (PC-12xx~14xx) qthsh Tanh-Sinh quadrature
(04-17-2021 11:45 PM)Albert Chan Wrote:  With sign checking method, both will suggest optimal d ~ 700.

Edit: I've updated the document with an improved version of the predictor (shown below) and an explanation how it works.

The following update sets d=1/700 for this case, so d is now either increased or decreased towards an optimum:

Code:
  else if (isfinite(a)) {
    int i;
    double ph = 0, h;
    mode = 1; // Exp-Sinh
    for (i = 1; i <= 16; ++i) {
      double r = 1 << i;
      double fl = f(a + d/r), fr = f(a + d*r)*r*r;
      double h = fl - fr;
      if (!isfinite(h))
        break;
      if (i > 1 && sign(ph) != sign(h)) {
        if (h != 0)
          r /= 2; // r = (r/2*h - r*ph)/(h - ph); // we can also try regula falsi
        if (fabs(fl) < fabs(fr))
          d /= r;
        else
          d *= r;
        break;
      }
      if (fabs(h) < 3e-5) // sqrt(eps) or cbrt(MachEps)
        break
      ph = h;
      printf("%g diff=%g (%g - %g)\n", r, h, fl, fr); // diagnostics
    }
    if (d != 1)
      printf("optimal d=%g\n", d);

This is a rough predictor that could be further improved. But this predictor is already reasonably effective to increase or decrease d in order to reduce the number of points evaluated by Exp-Sinh.

The predictor evaluates points too, but quits when an optimal d is found. There are ways to reduce this overhead, e.g. taking larger steps for d and perhaps followed by a second refinement step to adjust d.

With the simple predictor I've tested 208 integrals on [a,+inf) in the zip file with eps=1e-9: 29 are improved with 61 fewer points on average to integrate each of those.

- Rob

"I count on old friends" -- HP 71B,Prime|Ti VOY200,Nspire CXII CAS|Casio fx-CG50...|Sharp PC-G850,E500,2500,1500,14xx,13xx,12xx...
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-18-2021 12:56 PM



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