Back
atan (clj)
(source)function
(atan a)
Returns the arc tangent of a, in the range of -pi/2 to pi/2.
If a is ##NaN => ##NaN
If a is zero => zero with the same sign as a
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#atan-double-
Examples
clojure
(ns clojure.test-clojure.math
(:require
[clojure.test :refer :all]
[clojure.math :as m]))
(deftest test-atan
(is (NaN? (m/atan ##NaN)))
(is (pos-zero? (m/atan 0.0)))
(is (neg-zero? (m/atan -0.0)))
(is (ulp= (m/atan 1) 0.7853981633974483 1)))
(deftest test-atan2
(is (NaN? (m/atan2 ##NaN 1.0)))
(is (NaN? (m/atan2 1.0 ##NaN)))
(is (pos-zero? (m/atan2 0.0 1.0)))
(is (neg-zero? (m/atan2 -0.0 1.0)))
(is (ulp= (m/atan2 0.0 -1.0) m/PI 2))
(is (ulp= (m/atan2 -0.0 -1.0) (- m/PI) 2))
(is (ulp= (* 2.0 (m/atan2 1.0 0.0)) m/PI 2))
(is (ulp= (* -2.0 (m/atan2 -1.0 0.0)) m/PI 2))
(is (ulp= (* 4.0 (m/atan2 ##Inf ##Inf)) m/PI 2))
(is (ulp= (/ (* 4.0 (m/atan2 ##Inf ##-Inf)) 3.0) m/PI 2))
(is (ulp= (* -4.0 (m/atan2 ##-Inf ##Inf)) m/PI 2))
(is (ulp= (/ (* -4.0 (m/atan2 ##-Inf ##-Inf)) 3.0) m/PI 2)))