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

More precise error estimate for elementary functions #3973

Merged
merged 2 commits into from
Apr 10, 2024

Conversation

pleroy
Copy link
Member

@pleroy pleroy commented Apr 9, 2024

EXPECT_THAT(ULPDistance(std::cos(x), static_cast<double>(Cos(x))),
AnyOf(Eq(0), // Windows, macOS.
Eq(8))); // Linux.
EXPECT_THAT(ULPDistance(std::sin(x), Sin(x)), IsNear(9.89e-22_(1)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this is consistent with the result given by floating_point.wl:

In[1]:= << \
"C:\\Users\\robin\\Projects\\mockingbirdnest\\Principia\\mathematica\\\
floating_point.wl"

In[2]:= SetFloatingPointFormat[binary64]

In[3]:= SetRoundingMode[NearestTiesToEven]

In[4]:= x = 16^^16ac5b262ca1ff*2^797;

In[5]:= Block[{$MaxExtraPrecision = 300}, CorrectlyRound[Sin[x]]]

Out[5]= 1

In[6]:= Block[{$MaxExtraPrecision = 300}, 
 N[UlpDistance[Sin[16^^16ac5b262ca1ff*2^797], 1], 10]]

Out[6]= 9.894194191*10^-22

@eggrobin eggrobin added the LGTM label Apr 9, 2024
@pleroy pleroy merged commit 45b68d6 into mockingbirdnest:master Apr 10, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants