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

enforce some minimum accuracy bound for implementation-approximated values #3347

Open
michaelficarra opened this issue Jun 6, 2024 · 5 comments
Labels
needs data This PR needs more information; such as web compatibility data, “web reality” (what all engines do)… web reality

Comments

@michaelficarra
Copy link
Member

It appears there is a web compatibility dependency on some level of accuracy of implementation-approximated results of Math functions. See compat-table/compat-table#392 and es-shims/es6-shim@90c803f for a research starting point.

We should figure out just how accurate these values are expected to be and try to document that within ECMA-262.

@michaelficarra michaelficarra added needs data This PR needs more information; such as web compatibility data, “web reality” (what all engines do)… web reality labels Jun 6, 2024
@michaelficarra
Copy link
Member Author

/cc @sunfishcode here as well

@sunfishcode
Copy link
Member

Additional history: This issue also surfaced in 2014. TC39 discussed it in person here and here. At the time, there seemed to be general agreement that math functions should be within at most 1 ulp, however no spec change proposal was advanced at the time.

There was some follow-up discussion about whether an ulp bound is enough, as there were reports of applications also depending on various symmetries and invariants, such as:

  sin(x) == -sin(-x)
  sin(x) <= 1
  sin(x) >= -1
  cos(x) == cos(-x)
  cos(x) <= 1
  cos(x) >= -1

Collecting all such invariants for all Math functions that applications might be depending on might be challenging, but in a recent conversation @michaelficarra pointed out to me that incrementally specifying invariants as they're discovered to be needed would be better than not specifying anything at all.

After the 2015 discussion there was also some follow-up investigation of whether crlibm might enable TC39 to require fully correct rounding for more things, however at that time it wasn't practical. Today, CORE-MATH, RLIBM, and LLVM libc might make this more practical.

@michaelficarra
Copy link
Member Author

@waldemarhorwat has expressed interest in helping out with this

@waldemarhorwat
Copy link

There are a bunch of existing libraries that compute exact, correctly rounded results for the trig and exponential functions. A lot of these are offshoots of crlibm. Here's one, used by the European Space Agency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs data This PR needs more information; such as web compatibility data, “web reality” (what all engines do)… web reality
Projects
None yet
Development

No branches or pull requests

4 participants