Back
cos (clj)
(source)function
(cos a)
Returns the cosine of an angle.
If a is ##NaN, ##-Inf, ##Inf => ##NaN
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#cos-double-
Examples
clojure
(ns clojure.test-clojure.math
(:require
[clojure.test :refer :all]
[clojure.math :as m]))
(deftest test-cos
(is (NaN? (m/cos ##NaN)))
(is (NaN? (m/cos ##-Inf)))
(is (NaN? (m/cos ##Inf)))
(is (= 1.0 (m/cos 0.0) (m/cos -0.0)))
(is (ulp= (m/cos m/PI) (m/cos (- m/PI)) 1)))
(deftest test-acos
(is (NaN? (m/acos ##NaN)))
(is (NaN? (m/acos -2.0)))
(is (NaN? (m/acos 2.0)))
(is (ulp= (* 2 (m/acos 0.0)) m/PI 1)))
(deftest test-cosh
(is (NaN? (m/cosh ##NaN)))
(is (= ##Inf (m/cosh ##Inf)))
(is (= ##Inf (m/cosh ##-Inf)))
(is (= 1.0 (m/cosh 0.0))))