API for clojure.math - Clojure v1.12.4 (stable)

by Alex Miller

Full namespace name: clojure.math

Overview

Clojure wrapper functions for java.lang.Math static methods.

Function calls are inlined for performance, and type hinted for primitive
long or double parameters where appropriate. In general, Math methods are
optimized for performance and have bounds for error tolerance. If
greater precision is needed, use java.lang.StrictMath directly instead.

For more complete information, see:
https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html

Public Variables and Functions



E

var

    
Constant for e, the base for natural logarithms.
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#E

    Added in Clojure version 1.11
Source


IEEE-remainder

function
Usage: (IEEE-remainder dividend divisor)
Returns the remainder per IEEE 754 such that
  remainder = dividend - divisor * n
where n is the integer closest to the exact value of dividend / divisor.
If two integers are equally close, then n is the even one.
If the remainder is zero, sign will match dividend.
If dividend or divisor is ##NaN, or dividend is ##Inf or ##-Inf, or divisor is zero => ##NaN
If dividend is finite and divisor is infinite => dividend
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#IEEEremainder-double-double-

    Added in Clojure version 1.11
Source


PI

var

    
Constant for pi, the ratio of the circumference of a circle to its diameter.
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#PI

    Added in Clojure version 1.11
Source


acos

function
Usage: (acos a)
Returns the arc cosine of a, in the range 0.0 to pi.
If a is ##NaN or |a|>1 => ##NaN
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#acos-double-

    Added in Clojure version 1.11
Source


add-exact

function
Usage: (add-exact x y)
Returns the sum of x and y, throws ArithmeticException on overflow.
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#addExact-long-long-

    Added in Clojure version 1.11
Source


asin

function
Usage: (asin a)
Returns the arc sine of an angle, in the range -pi/2 to pi/2.
If a is ##NaN or |a|>1 => ##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#asin-double-

    Added in Clojure version 1.11
Source


atan

function
Usage: (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-

    Added in Clojure version 1.11
Source


atan2

function
Usage: (atan2 y x)
Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta).
Computes the phase theta by computing an arc tangent of y/x in the range of -pi to pi.
For more details on special cases, see:
https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#atan2-double-double-

    Added in Clojure version 1.11
Source


cbrt

function
Usage: (cbrt a)
Returns the cube root of a.
If a is ##NaN => ##NaN
If a is ##Inf or ##-Inf => a
If a is zero => zero with sign matching a
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#cbrt-double-

    Added in Clojure version 1.11
Source


ceil

function
Usage: (ceil a)
Returns the smallest double greater than or equal to a, and equal to a
mathematical integer.
If a is ##NaN or ##Inf or ##-Inf or already equal to an integer => a
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#ceil-double-

    Added in Clojure version 1.11
Source


copy-sign

function
Usage: (copy-sign magnitude sign)
Returns a double with the magnitude of the first argument and the sign of
the second.
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#copySign-double-double-

    Added in Clojure version 1.11
Source


cos

function
Usage: (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-

    Added in Clojure version 1.11
Source


cosh

function
Usage: (cosh x)
Returns the hyperbolic cosine of x, (e^x + e^-x)/2.
If x is ##NaN => ##NaN
If x is ##Inf or ##-Inf => ##Inf
If x is zero => 1.0
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#cosh-double-

    Added in Clojure version 1.11
Source


decrement-exact

function
Usage: (decrement-exact a)
Returns a decremented by 1, throws ArithmeticException on overflow.
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#decrementExact-long-

    Added in Clojure version 1.11
Source


exp

function
Usage: (exp a)
Returns Euler's number e raised to the power of a.
If a is ##NaN => ##NaN
If a is ##Inf => ##Inf
If a is ##-Inf => +0.0
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#exp-double-

    Added in Clojure version 1.11
Source


expm1

function
Usage: (expm1 x)
Returns e^x - 1. Near 0, expm1(x)+1 is more accurate to e^x than exp(x).
If x is ##NaN => ##NaN
If x is ##Inf => #Inf
If x is ##-Inf => -1.0
If x is zero => x
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#expm1-double-

    Added in Clojure version 1.11
Source


floor

function
Usage: (floor a)
Returns the largest double less than or equal to a, and equal to a
mathematical integer.
If a is ##NaN or ##Inf or ##-Inf or already equal to an integer => a
If a is less than zero but greater than -1.0 => -0.0
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#floor-double-

    Added in Clojure version 1.11
Source


floor-div

function
Usage: (floor-div x y)
Integer division that rounds to negative infinity (as opposed to zero).
The special case (floorDiv Long/MIN_VALUE -1) overflows and returns Long/MIN_VALUE.
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#floorDiv-long-long-

    Added in Clojure version 1.11
Source


floor-mod

function
Usage: (floor-mod x y)
Integer modulus x - (floorDiv(x, y) * y). Sign matches y and is in the
range -|y| < r < |y|.
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#floorMod-long-long-

    Added in Clojure version 1.11
Source


get-exponent

function
Usage: (get-exponent d)
Returns the exponent of d.
If d is ##NaN, ##Inf, ##-Inf => Double/MAX_EXPONENT + 1
If d is zero or subnormal => Double/MIN_EXPONENT - 1
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#getExponent-double-

    Added in Clojure version 1.11
Source


hypot

function
Usage: (hypot x y)
Returns sqrt(x^2 + y^2) without intermediate underflow or overflow.
If x or y is ##Inf or ##-Inf => ##Inf
If x or y is ##NaN and neither is ##Inf or ##-Inf => ##NaN
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#hypot-double-double-

    Added in Clojure version 1.11
Source


increment-exact

function
Usage: (increment-exact a)
Returns a incremented by 1, throws ArithmeticException on overflow.
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#incrementExact-long-

    Added in Clojure version 1.11
Source


log

function
Usage: (log a)
Returns the natural logarithm (base e) of a.
If a is ##NaN or negative => ##NaN
If a is ##Inf => ##Inf
If a is zero => ##-Inf
See: