Skip to content

Faster log(10) calculation #398

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

Closed
wants to merge 1 commit into from
Closed

Faster log(10) calculation #398

wants to merge 1 commit into from

Conversation

tompng
Copy link
Member

@tompng tompng commented Aug 9, 2025

Improve log(x_small_precision) by decomposing log(x) into a*log(4/3)+b*log(5/4)+log(close_to_one_rational).
Improving log(10) will improve performance of log(x) of x<=0.1 and x>=10.

BigMath.log(10, 10000)
# master branch:            15.398019s
# pull #381 (sqrt improve):  1.313900s
# this pull request:         0.167481s

@tompng tompng marked this pull request as draft August 10, 2025 03:39
Add fast log calculation of small rational.
log(x_small_precision) will be decomposed into a*log(4/3)+b*log(5/4)+log(close_to_one_rational).
Examples:
  log(10) = 8*log(4/3)+log(32805/32768)
  log(2) = 3*log(5/4)+log(128/125)
@tompng
Copy link
Member Author

tompng commented Aug 14, 2025

Diff is not so simple, and not so optimal.

BigMath.log(BigDecimal(2), 250000)
# This optimization: 86.393285 seconds
# sqrt(pull #381) + mult(pull #380) optimization: 77.847769 seconds

I'll revisit this after introducing BigMath.log2 and BigMath.log10

@tompng tompng closed this Aug 14, 2025
@tompng tompng deleted the faster_ln10 branch August 14, 2025 13:43
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.

1 participant