Skip to content

Commit 46dca76

Browse files
rhannequinmrkn
authored andcommitted
Make tan depend only on sin
1 parent 83c2723 commit 46dca76

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/bigdecimal/math.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ def cos(x, prec)
148148
# #=> "0.999999999999999999999955588155008544487055622030633191403625599381672572e0"
149149
#
150150
def tan(x, prec)
151-
sin(x, prec) / cos(x, prec)
151+
sine = sin(x, prec)
152+
cosine = sqrt(1 - sine**2, prec)
153+
sine / cosine
152154
end
153155

154156
# call-seq:

0 commit comments

Comments
 (0)