Skip to content

Conversation

@forfudan
Copy link
Owner

@forfudan forfudan commented Jul 3, 2025

This pull request introduces significant improvements to the BigDecimal library by optimizing the calculation of π (pi) for high precision and documenting the performance characteristics of different algorithms. The main changes include replacing Machin's formula with the Chudnovsky algorithm for faster computation, introducing binary splitting for efficiency, and adding internal notes on time complexity and algorithm results.

Optimizations for π Calculation:

  • src/decimojo/bigdecimal/constants.mojo: Replaced Machin's formula with the Chudnovsky algorithm for π calculation, leveraging binary splitting for higher precision and faster computation. Added caching logic to store precomputed values for precision ≤ 1024.
  • src/decimojo/bigdecimal/constants.mojo: Introduced helper functions pi_chudnovsky_binary_split, chudnovsky_split, and compute_m_k_rational to implement the Chudnovsky algorithm efficiently.

Documentation Updates:

  • docs/internal_notes.md: Added a section describing time complexity and performance results for π calculation using Machin's formula and the Chudnovsky algorithm.

Code Cleanup:

@forfudan forfudan merged commit b9c526e into main Jul 3, 2025
1 check passed
@forfudan forfudan deleted the work branch July 3, 2025 17:54
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