Add support for tangent function
Associated issue: #81
Context
BigMath module supports sine (sin) and cosine (cos) trigonometric functions. It also supports arctangent (acan). But it doesn't support tangent, which is supported in Math module.
Solution
tan is related to sin and cos function such as (source):
tan(x) = sin(x) / cos(x)
This PR adds BigMath.tan(x, precision), dependent on existing BigMath.sin and BigMath.cos methods.
Hello @mrkn, anything I should do to this PR to improve it? Please let me know if I missed a step to have this PR reviewed 🙏 Thank you.
I'm working on supporting BigDecimal in assert_in_delta family assertions at https://github.com/test-unit/test-unit/pull/218.
I'm working on adding tests with higher precision at https://github.com/ruby/bigdecimal/pull/238
@mrkn Hello, I'm back after a small break. Maybe I can help with #238?
@rhannequin Although test-unit now supports BigDecimal in assert_in_delta family assertions, as tests of BigDecimal need to run also in Ruby's test-all, I have to let the test framework in Ruby's test-all support the new assert_in_delta family assertions.
Until finishing this work, could you try to rewrite tan implementation to depend on only sin?
Hello @mrkn, I hope you're doing great.
I did some research for a new algorithm for cos and arrived to the conclusion to just duplicate it, for now, so that tan only depends on sin.
I committed it a few minutes ago, what do you think?
@mrkn Hello, sorry for taking so long to move forward with this pull request.
My math background is not really advanced and I wasn't familiar with this definition of cosine based on sine.
I changed the implementation of tan to only depend on sin with this new definition, which is indeed much clearer and probably much faster.
Would you still like a link to a paper or an "official" definition for the documentation?
@hsbt I allow myself to ping you here as you seem to have been active on the project recently. Please let me know if this PR needs to be reviewed by someone in particular, or if anything must be changed in the content.
@rhannequin He’s recent work is only for leaving this library out of Ruby’s default gems. I think there are few people who can review new features of bigdecimal in the Ruby core team. Could you please wait until I can look into your new commits?
Absolutely, @mrkn. Sorry if my comment sounded pressing, I wasn't sure you had time for this at the moment. I'll wait now all the time needed.
@rhannequin Thank you for your understanding and cooperation!