Post Reply 
(PC-12xx~14xx) qthsh Tanh-Sinh quadrature
04-08-2021, 01:29 AM
Post: #35
RE: (PC-12xx~14xx) qthsh Tanh-Sinh quadrature
(04-07-2021 07:31 PM)emece67 Wrote:  Just uploaded to GitHub a new version of the Python script. Based on the ideas of Rob about applying strength reduction. The speed increase is about 20%. Precision and TNFE suffered a little bit, though.

Well, this is wrong I'm afraid. I ran a comparison of the original WP34S code written in C and the optimized WP34S code written in C. I only made the small change to replace:

Code:
      double ch = cosh(t);
      double ecs = cosh(M_PI/2 * sqrt(ch*ch - 1));
      double r = sqrt(ecs*ecs - 1)/ecs;
      double w = 1/(ecs*ecs);
with these optimizations:
Code:
    ex = eh = exp(h);
    if (k > 0)
      eh *= eh;
    do {
      double ch = (ex+1/ex)/2; // = cosh(t)
      double u = exp(M_PI*(ex-1/ex)/4);
      double ecs = u+1/u;      // = 2*cosh(M_PI*(ex-1/ex)/4);
      double r = (u-1/u)/ecs;  // = tanh(pi/2*sinh(t))
      double w = 4/(ecs*ecs);
      ...
      ex *= eh;

The optimized code evaluates the same number of functions for all 818 integrals. There is no difference.

Secondly, the absolute error of the results to the exact result is actually smaller for every integral with the optimized version!

I will be happy to share the spreadsheet but you can run the experiment with the zip file I shared earlier by making the changes to the wp34s.sh code as shown above.

- 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-08-2021 01:29 AM



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