tarcieri / micromath

Embedded Rust arithmetic, 2D/3D vector, and statistics library
Apache License 2.0
401 stars 21 forks source link

Consider adding a round of Newton's method to `sqrt` #101

Open jdahlstrom opened 1 year ago

jdahlstrom commented 1 year ago

Right now, sqrt is incredibly fast, but the ~5% max error really makes it a poor fit for many uses. Adding a single round of Newton's method makes it much more precise, at the expense of a division. This could be behind a feature flag, or the current sqrt could be kept available as fast_sqrt or similar.

tarcieri commented 1 year ago

We could potentially add a feature like precision to improve precisions. Of course, it would have global impact.