[decimal] Implement sin() and cos() for BigDecimal
#96
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant enhancements to the
BigDecimalmodule, focusing on trigonometric functionality, precision handling, and modular arithmetic. It also updates documentation and test cases to support these changes. The most important changes include the addition ofsinandcosfunctions, improvements to rounding precision methods, and modular arithmetic support.Trigonometric Functionality Enhancements:
sinandcosfunctions tostruct BigDecimal, with range reduction and Taylor series implementations for accurate calculations. These functions handle edge cases for π-related values and ensure high precision. (src/decimojo/bigdecimal/bigdecimal.mojosrc/decimojo/bigdecimal/bigdecimal.mojoR765-R774,src/decimojo/bigdecimal/trigonometric.mojoF4fb1110L30R321)arctanfunction to useround_to_precisionfor consistent precision handling and added intermediate result handling for better readability. (src/decimojo/bigdecimal/trigonometric.mojoF4fb1110L56R355)Precision Handling Improvements:
roundwithround_to_precisionacross multiple functions, adding options to remove extra digits due to rounding and prevent trailing zeros. (src/decimojo/bigdecimal/constants.mojoF7b2c265L166R322,src/decimojo/bigdecimal/rounding.mojosrc/decimojo/bigdecimal/rounding.mojoL102-R104)round_to_precisionmethod to clarify the behavior of precision-related parameters. (src/decimojo/bigdecimal/bigdecimal.mojosrc/decimojo/bigdecimal/bigdecimal.mojoR848-R854)Modular Arithmetic Support:
__mod__method instruct BigDecimalto support modulo operations, leveragingtruncate_modulo. (src/decimojo/bigdecimal/bigdecimal.mojosrc/decimojo/bigdecimal/bigdecimal.mojoR526-R534)Documentation Updates:
docs/internal_notes.mdto include examples and precision comparisons forsinfunctionality, highlighting discrepancies between Decimojo, WolframAlpha, andmpmath. (docs/internal_notes.mddocs/internal_notes.mdL5-R16)Test Case Enhancements:
sinandarctanfunctions, enabling modular test execution through a reusablerun_testfunction. (tests/bigdecimal/test_bigdecimal_trigonometric.mojotests/bigdecimal/test_bigdecimal_trigonometric.mojoL14-R45)