Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*Do 6 Newton method iterations in cuberoot #550

Closed

Conversation

Hallberg-NOAA
Copy link
Member

@Hallberg-NOAA Hallberg-NOAA commented Jan 23, 2024

Modified the cuberoot() function to do 6 iterations with Newton's method, starting from the optimal first guess of (3/8)**(1/3). Following guidance from performance testing of the previous version (documented in the conversation surrounding #544), all convergence testing has been removed and the same number of iterations are applied regardless of the input value. The form of Newton's method used here does one division per iteration, but it is good at polishing the root to give an accurate final solution and by simply repeatedly using the same instructions it appears to optimize well. This commit changes answers at roundoff for code that uses the cuberoot() function, so ideally this PR would be dealt with before the cuberoot() becomes widely used.

Copy link

codecov bot commented Jan 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d7d126a) 37.20% compared to head (3557f72) 37.19%.

Additional details and impacted files
@@             Coverage Diff              @@
##           dev/gfdl     #550      +/-   ##
============================================
- Coverage     37.20%   37.19%   -0.01%     
============================================
  Files           271      271              
  Lines         80355    80341      -14     
  Branches      14985    14982       -3     
============================================
- Hits          29894    29882      -12     
+ Misses        44903    44902       -1     
+ Partials       5558     5557       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

  Modified the cuberoot function to do 6 iterations with Newton's method,
starting from the optimal first guess of (3/8)**(1/3).  Following guidance from
performance testing of the previous version, all convergence testing has been
removed and the same number of iterations are applied regardless of the input
value.  The form of Newton's method used here does one division per iteration,
but it is good at polishing the root to give an accurate final solution and by
simply repeatedly using the same instructions it appears to optimize well.  This
commit changes answers at roundoff for code that uses the cuberoot function, so
ideally this PR would be dealt with before the cuberoot becomes widely used.
@Hallberg-NOAA Hallberg-NOAA changed the title *Do 5(+1) Newton method iterations in cuberoot *Do 6 Newton method iterations in cuberoot Jan 24, 2024
@marshallward
Copy link
Member

Handled in #544

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants