@@ -38,26 +38,29 @@ local function TestOneInput(buf, _size)
3838 local b = fdp :consume_number (test_lib .MIN_INT , test_lib .MAX_INT )
3939 if b < 0 or b == 1 then return - 1 end
4040
41+ local eps = 1 ^- 10
42+
4143 -- Product rule.
42- assert (test_lib .approx_equal (math.log ( x * y , b ),
43- math.log (x , b ) + math.log (y , b ), 0.01 ))
44+ assert (test_lib .approx_equal (
45+ math.log ( x * y , b ), math.log (x , b ) + math.log (y , b ), eps ))
4446 -- Quotient rule.
45- -- assert(test_lib.approx_equal(math.log(x / y, b), math.log(x, b) - math.log(y, b), 0.5))
46-
47+ assert (test_lib .approx_equal (
48+ math.log ( x / y , b ), math.log ( x , b ) - math.log ( y , b ), eps ))
4749 -- Power rule.
48- assert (test_lib .approx_equal (math.log (pow (x , y ), b ), y * math.log (x , b ), 0.01 ))
50+ assert (test_lib .approx_equal (
51+ math.log (pow (x , y ), b ), y * math.log (x , b ), eps ))
4952 -- Inverse property of logarithm.
50- assert (test_lib .approx_equal (math.log (pow (b , x ), b ), x , 0.01 ))
53+ assert (test_lib .approx_equal (math.log (pow (b , x ), b ), x , eps ))
5154 -- Inverse property of exponent.
52- assert (test_lib .approx_equal (pow (b , math.log (x , b )), x , 0.01 ))
55+ assert (test_lib .approx_equal (pow (b , math.log (x , b )), x , eps ))
5356 -- Zero rule.
5457 assert (math.log (1 , b ) == 0 )
5558 -- Identity rule.
56- assert (test_lib .approx_equal (math.log (b , b ), 1 , 0.1 ))
59+ assert (test_lib .approx_equal (math.log (b , b ), 1 , eps ))
5760 -- Change of base formula.
5861 local log_b_y = math.log (b , y )
5962 if log_b_y ~= 0 then
60- assert (test_lib .approx_equal (math.log (x , b ), math.log (x , y ) / log_b_y , 0.01 ))
63+ assert (test_lib .approx_equal (math.log (x , b ), math.log (x , y ) / log_b_y , eps ))
6164 end
6265end
6366
0 commit comments