1 ;;;; tests of irrational floating point functions
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; While most of SBCL is derived from the CMU CL system, the test
7 ;;;; files (like this one) were written from scratch after the fork
10 ;;;; This software is in the public domain and is provided with
11 ;;;; absolutely no warranty. See the COPYING and CREDITS files for
12 ;;;; more information.
18 ;;; This used to fail with
19 ;;; The value -0.44579905382680446d0 is not of type (DOUBLE-FLOAT 0.0d0).
20 ;;; MNA's port of Raymond Toy work on CMU CL fixed this in sbcl-0.6.12.53.
21 (assert (equal (log #c
(0.4
0.5)) #C
(-0.44579905
0.8960554)))
26 (assert (equal (expt #c
(0 1) 2) -
1))
27 (assert (equal (prin1-to-string (expt 2 #c
(0 1))) "#C(0.7692389 0.63896126)"))
30 (assert (equal (prin1-to-string (log -
3 10)) "#C(0.47712126 1.3643764)"))
31 (assert (= (log 3 0) 0))
34 (assert (= (sqrt 9) 3.0))
35 (assert (= (sqrt -
9.0) #c
(0.0
3.0)))
36 (assert (= (isqrt 9) 3))
37 (assert (= (isqrt 26) 5))
40 ;;; sin, sinh, asin, asinh
41 (assert (equal (prin1-to-string (sin (* 8 (/ pi
2)))) "-4.898425415289509d-16"))
42 (assert (equal (prin1-to-string (sin (expt 10 3))) "0.82687956"))
43 (assert (= (sinh 0) 0.0))
44 (assert (equal (prin1-to-string (sinh #c
(5.0 -
9.6)))
45 "#C(-73.06699 12.936809)"))
46 (assert (= (sin (* #c
(0 1) 5)) (* #c
(0 1) (sinh 5))))
47 (assert (= (sinh (* #c
(0 1) 5)) (* #c
(0 1) (sin 5))))
48 (assert (equal (prin1-to-string (asin -
1)) "-1.5707964"))
49 (assert (= (asin 0) 0.0))
50 (assert (= (asin 2) #c
(1.5707964 -
1.3169578)))
51 (assert (equal (prin1-to-string (asinh 0.5)) "0.4812118"))
52 (assert (equal (prin1-to-string (asinh 3/7)) "0.41643077"))
54 ;;; cos, cosh, acos, acosh
55 (assert (= (cos 0) 1.0))
56 (assert (equal (prin1-to-string (cos (/ pi
2))) "6.123031769111886d-17"))
57 (assert (= (cosh 0) 1.0))
58 (assert (equal (prin1-to-string (cosh 1)) "1.5430807"))
59 (assert (= (cos (* #c
(0 1) 5)) (cosh 5)))
60 (assert (= (cosh (* #c
(0 1) 5)) (cos 5)))
61 (assert (equal (prin1-to-string (acos 0)) "1.5707964"))
62 (assert (equal (prin1-to-string (acos -
1)) "3.1415927"))
63 (assert (equal (prin1-to-string (acos 2)) "#C(0.0 1.3169578)"))
64 (assert (= (acos 1.00001) #c
(0.0
0.0044751678)))
65 (assert (= (acosh 0) #c
(0 1.5707964)))
66 (assert (= (acosh 1) 0))
67 (assert (= (acosh -
1) #c
(0 3.1415927)))
70 (assert (equal (prin1-to-string (tan 1)) "1.5574077"))
71 (assert (equal (prin1-to-string (tan (/ pi
2))) "1.6331778728383844d+16"))
72 (assert (equal (prin1-to-string (tanh 0.00753)) "0.0075298576"))
73 (assert (= (tanh 50) 1.0))
74 (assert (= (tan (* #c
(0 1) 5)) (* #c
(0 1) (tanh 5))))
75 (assert (= (atan 1) 0.7853982))
76 (assert (equal (prin1-to-string (atanh 0.5) ) "0.54930615"))
77 (assert (equal (prin1-to-string (atanh 3/7)) "0.45814538"))