-
Notifications
You must be signed in to change notification settings - Fork 79
Implement major math functions #336
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
base: master
Are you sure you want to change the base?
Conversation
1a93b02
to
5ebf5dc
Compare
Calculate `tan(x, prec)` by `sin(x, prec) / cos(x, denominator_prec)`. If the precision of cos is not enough, increase denominator_prec and recalculate cos again.
5ebf5dc
to
f29ba89
Compare
Implement BigMath version of Math.cbrt(x). Added internal-use method BigMath.int_cbrt(n): cube root version of Integer.sqrt(n)
f29ba89
to
316d713
Compare
return BigDecimal::NAN if x.nan? | ||
return BigDecimal::INFINITY if x.infinite? == 1 | ||
|
||
prec2 = prec + BigDecimal.double_fig * 3 / 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious: why do we decide what prec2
is needed? It differs between the functions and I'm wondering how it's calculated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally, BigMath functions calculate with prec+BigDecimal.double_fig
precision.
I think BigMath.log2(1024, prec)
is expected to return exactly 10
. To calculate exact value for 2**n
numbers, we need to round the result to precision = prec+BigDecimal.double_fig
.
log(x)/log(2)
should be calculated with prec + BigDecimal.double_fig + extra
precision.
I decided to use extra=BigDeciaml.double_fig/2
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Implement these methods
Remaining methods