Skip to content

Fix BigMath.atan precision safe margin #320

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tompng
Copy link
Member

@tompng tompng commented May 17, 2025

Increase BigMath.atan(x, prec) precision when |x|>0.5

BigMath.atan(x, prec) is calculated with precision=prec+BigDecimal.double_fig when |x| <= 0.5.
But this safe margin was not properly applied when |x| > 0.5.

BigMath.atan(BigDecimal('0.2'), 100) #=> accuracy was about 116 digits
BigMath.atan(BigDecimal('0.8'), 100) #=> accuracy was about 108 digits
BigMath.atan(BigDecimal('3'), 100) #=> accuracy was about 100 digits

Added test code that failed before

atan(BigDecimal("0.8"), n) # Precision is not enough: 107 < 100 + 12.
atan(BigDecimal("3"), n) # Precision is not enough: 50 < 50 + 12.

tompng added 2 commits May 17, 2025 14:33
BigMath.atan(x, prec) is calculated with precision=prec+BigDecimal.double_fig when |x| <= 0.5.
But this safe margin was not properly applied when |x| > 0.5.
@mrkn mrkn modified the milestones: v3.2, v3.3 May 29, 2025
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