Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes a few translation errors in the initial port and adds some fixes since changed upstream.
See #19476.
I have tested this predominantly using a simple fuzzing setup, comparing the results of zig vs musl (which is the primary source). Code for this can be seen at the bottom of this PR.
For values in the range [0, 1) I'e fuzzed ~1 billion results with all matching to a small epsilon.
For larger values there are a few differences noted below, however this encompasses only ~5% of values max and generally the difference is small.
Observations
There are some known failures still present. These are not introduced by this PR and likely have been present for quite a while.
The primary reason from what I can see has to do with some minor precision differences which balloon under certain circumstances. Specifically I would investigate the difference in behaviour between where we emit builtins
@log,@sqrtvs. musl which use a software implementation.e.g. a failing test case
Tracing the Zig and C asin implementation we deviate marginally at a certain point which causes wildly different results:
Note however that both of the above results are incorrect. The correct value is instead
0.98553904473616791... + 44.409042651917785... i.This looks to occur for values ~1e7 or greater for input to
asin.asinis called by a few other hyperbolic functions so this can be observed in a few other places too.Aside from this there are some other minor accuracy differences. Likely due to the aforementioned builtins but for which the errors do not grow exponentially.
Fuzzing Code