Skip to content

Commit

Permalink
Make tan depend only on sin
Browse files Browse the repository at this point in the history
  • Loading branch information
rhannequin committed Feb 16, 2024
1 parent a18cbed commit 38bd414
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/bigdecimal/math.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ def cos(x, prec)
# #=> "0.999999999999999999999955588155008544487055622030633191403625599381672572e0"
#
def tan(x, prec)
sin(x, prec) / cos(x, prec)
sine = sin(x, prec)
cosine = sqrt(1 - sine**2, prec)
sine / cosine
end

# call-seq:
Expand Down

0 comments on commit 38bd414

Please sign in to comment.