@@ -134,6 +134,39 @@ def test_tan
134
134
assert_relative_precision { |n | tan ( PI ( 200 ) * 100 , n ) }
135
135
end
136
136
137
+ def test_asin
138
+ [ "-1" , "-0.9" , "-0.1" , "0" , "0.1" , "0.9" , "1" ] . each do |x |
139
+ assert_in_delta ( Math . asin ( x . to_f ) , asin ( BigDecimal ( x ) , N ) )
140
+ end
141
+ assert_raise ( Math ::DomainError ) { BigMath . asin ( BigDecimal ( "1.1" ) , N ) }
142
+ assert_raise ( Math ::DomainError ) { BigMath . asin ( BigDecimal ( "-1.1" ) , N ) }
143
+ assert_in_delta ( PI ( 100 ) / 6 , asin ( BigDecimal ( "0.5" ) , 100 ) , BigDecimal ( "1e-100" ) )
144
+ assert_relative_precision { |n | asin ( BigDecimal ( "-0.4" ) , n ) }
145
+ assert_relative_precision { |n | asin ( BigDecimal ( "0.3" ) , n ) }
146
+ assert_relative_precision { |n | asin ( BigDecimal ( "0.9" ) , n ) }
147
+ assert_relative_precision { |n | asin ( BigDecimal ( "0.#{ "9" * 50 } " ) , n ) }
148
+ assert_relative_precision { |n | asin ( BigDecimal ( "0.#{ "9" * 100 } " ) , n ) }
149
+ assert_relative_precision { |n | asin ( BigDecimal ( "0.#{ "9" * 195 } " ) , n ) }
150
+ assert_relative_precision { |n | asin ( BigDecimal ( "1e-30" ) , n ) }
151
+ end
152
+
153
+ def test_acos
154
+ [ "-1" , "-0.9" , "-0.1" , "0" , "0.1" , "0.9" , "1" ] . each do |x |
155
+ assert_in_delta ( Math . acos ( x . to_f ) , acos ( BigDecimal ( x ) , N ) )
156
+ end
157
+ assert_raise ( Math ::DomainError ) { BigMath . acos ( BigDecimal ( "1.1" ) , N ) }
158
+ assert_raise ( Math ::DomainError ) { BigMath . acos ( BigDecimal ( "-1.1" ) , N ) }
159
+ assert_equal ( 0 , acos ( BigDecimal ( "1.0" ) , N ) )
160
+ assert_in_delta ( PI ( 100 ) / 3 , acos ( BigDecimal ( "0.5" ) , 100 ) , BigDecimal ( "1e-100" ) )
161
+ assert_relative_precision { |n | acos ( BigDecimal ( "-0.4" ) , n ) }
162
+ assert_relative_precision { |n | acos ( BigDecimal ( "0.3" ) , n ) }
163
+ assert_relative_precision { |n | acos ( BigDecimal ( "0.9" ) , n ) }
164
+ assert_relative_precision { |n | acos ( BigDecimal ( "0.#{ "9" * 50 } " ) , n ) }
165
+ assert_relative_precision { |n | acos ( BigDecimal ( "0.#{ "9" * 100 } " ) , n ) }
166
+ assert_relative_precision { |n | acos ( BigDecimal ( "0.#{ "9" * 195 } " ) , n ) }
167
+ assert_relative_precision { |n | acos ( BigDecimal ( "1e-30" ) , n ) }
168
+ end
169
+
137
170
def test_atan
138
171
assert_equal ( 0.0 , atan ( BigDecimal ( "0.0" ) , N ) )
139
172
assert_in_delta ( Math ::PI /4 , atan ( BigDecimal ( "1.0" ) , N ) )
0 commit comments