4 assert('Math.sin 0') do
5 assert_float(0, Math.sin(0))
8 assert('Math.sin PI/2') do
9 assert_float(1, Math.sin(Math::PI / 2))
12 assert('Math.cos 0') do
13 assert_float(1, Math.cos(0))
16 assert('Math.cos PI/2') do
17 assert_float(0, Math.cos(Math::PI / 2))
20 assert('Math.tan 0') do
21 assert_float(0, Math.tan(0))
24 assert('Math.tan PI/4') do
25 assert_float(1, Math.tan(Math::PI / 4))
28 assert('Fundamental trig identities') do
36 assert_float(Math.cos(ca), s)
37 assert_float(1 / Math.tan(ca), t)
38 assert_float(1, s ** 2 + c ** 2)
39 assert_float((1/c) ** 2, t ** 2 + 1)
40 assert_float((1/s) ** 2, (1/t) ** 2 + 1)
44 assert('Math.erf 0') do
45 assert_float(0, Math.erf(0))
48 assert('Math.exp 0') do
49 assert_float(1.0, Math.exp(0))
52 assert('Math.exp 1') do
53 assert_float(2.718281828459045, Math.exp(1))
56 assert('Math.exp 1.5') do
57 assert_float(4.4816890703380645, Math.exp(1.5))
60 assert('Math.log 1') do
61 assert_float(0, Math.log(1))
64 assert('Math.log E') do
65 assert_float(1.0, Math.log(Math::E))
68 assert('Math.log E**3') do
69 assert_float(3.0, Math.log(Math::E**3))
72 assert('Math.log2 1') do
73 assert_float(0.0, Math.log2(1))
76 assert('Math.log2 2') do
77 assert_float(1.0, Math.log2(2))
80 assert('Math.log10 1') do
81 assert_float(0.0, Math.log10(1))
84 assert('Math.log10 10') do
85 assert_float(1.0, Math.log10(10))
88 assert('Math.log10 10**100') do
89 assert_float(100.0, Math.log10(10**100))
92 assert('Math.sqrt') do
93 num = [0.0, 1.0, 2.0, 3.0, 4.0]
94 sqr = [0, 1, 4, 9, 16]
95 sqr.each_with_index do |v,i|
96 assert_float(num[i], Math.sqrt(v))
100 assert('Math.cbrt') do
101 num = [-2.0, -1.0, 0.0, 1.0, 2.0]
102 cub = [-8, -1, 0, 1, 8]
103 cub.each_with_index do |v,i|
104 assert_float(num[i], Math.cbrt(v))
108 assert('Math.hypot') do
109 assert_float(5.0, Math.hypot(3, 4))
112 assert('Math.frexp 1234') do
114 fraction, exponent = Math.frexp(n)
115 assert_float(n, Math.ldexp(fraction, exponent))
118 assert('Math.erf 1') do
119 assert_float(0.842700792949715, Math.erf(1))
122 assert('Math.erfc 1') do
123 assert_float(0.157299207050285, Math.erfc(1))
126 assert('Math.erf -1') do
127 assert_float(-0.8427007929497148, Math.erf(-1))
130 assert('Math.erfc -1') do
131 assert_float(1.8427007929497148, Math.erfc(-1))