Skip to content

[decimal] Add rational root decompostion to root() and add atanh approach to ln()#168

Merged
forfudan merged 2 commits intodecfrom
update
Feb 24, 2026
Merged

[decimal] Add rational root decompostion to root() and add atanh approach to ln()#168
forfudan merged 2 commits intodecfrom
update

Conversation

@forfudan
Copy link
Copy Markdown
Owner

@forfudan forfudan commented Feb 24, 2026

This PR adds two performance optimizations to BigDecimal's exponential functions: rational root decomposition for fractional roots and a hybrid Taylor/atanh approach for the natural logarithm series.

Changes:

  • Added rational root decomposition for root() to compute fractional roots like x^(2/3) using integer_power(integer_root(x, a), b) instead of the expensive exp(ln(x)/n) path
  • Refactored ln_series_expansion() to use atanh identity for large z values, reducing iterations by ~3× through faster convergence (rate 1/9 vs 1/2)
  • Fixed markdown table-of-contents comment syntax from "omit in toc" to "omit from toc"

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds two performance optimizations to BigDecimal's exponential functions: rational root decomposition for fractional roots and a hybrid Taylor/atanh approach for the natural logarithm series.

Changes:

  • Added rational root decomposition for root() to compute fractional roots like x^(2/3) using integer_power(integer_root(x, a), b) instead of the expensive exp(ln(x)/n) path
  • Refactored ln_series_expansion() to use atanh identity for large z values, reducing iterations by ~3× through faster convergence (rate 1/9 vs 1/2)
  • Fixed markdown table-of-contents comment syntax from "omit in toc" to "omit from toc"

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/decimojo/bigdecimal/exponential.mojo Added _gcd() helper, _rational_root_decomposition() function, integrated rational root decomposition into root(), and refactored ln_series_expansion() with hybrid Taylor/atanh approach
docs/readme_zht.md Fixed markdown TOC comment syntax (spelling fix)
docs/readme_unreleased.md Fixed markdown TOC comment syntax (spelling fix)
docs/readme_tomlmojo.md Fixed markdown TOC comment syntax (spelling fix)
docs/plans/bigdecimal_biguint_benchmark_analysis.md Updated task completion status for Task 3f (atanh for ln) and Task 7c (rational root decomposition)
README.md Fixed markdown TOC comment syntax (spelling fix)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@forfudan forfudan merged commit 8c85dba into dec Feb 24, 2026
1 check passed
@forfudan forfudan deleted the update branch February 24, 2026 23:10
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