# Namespace: joker.math

v1.0

## Summary

Provides basic constants and mathematical functions.

## Constants

Constants are variables with :const true in their metadata. Joker currently does not recognize them as special; as such, it allows redefining them or their values.

Double v1.0

e

• ### ln-of-10

Double v1.0

Natural logarithm of 10

• ### ln-of-2

Double v1.0

Natural logarithm of 2

• ### log-10-of-e

Double v1.0

Base-10 logarithm of e

• ### log-2-of-e

Double v1.0

Base-2 logarithm of e

• ### max-double

Double v1.0

Largest finite value representable by Double

Double v1.0

Phi

Double v1.0

pi

• ### smallest-nonzero-double

Double v1.0

Smallest positive, non-zero value representable by Double

• ### sqrt-of-2

Double v1.0

Square root of 2

• ### sqrt-of-e

Double v1.0

Square root of e

• ### sqrt-of-phi

Double v1.0

Square root of phi

• ### sqrt-of-pi

Double v1.0

Square root of pi

(None.)

## Functions, Macros, and Special Forms

• ### abs

Function v1.0
````(abs x)`
```

Returns the absolute value of x.

• ### ceil

Function v1.0
````(ceil x)`
```

Returns the least integer value greater than or equal to x.

• ### copy-sign

Function v1.0
````(copy-sign x y)`
```

Returns value with the magnitude of x and the sign of y.

• ### cos

Function v1.0
````(cos x)`
```

Returns the cosine of the radian argument x.

• ### cube-root

Function v1.0
````(cube-root x)`
```

Returns the cube root of x.

• ### dim

Function v1.0
````(dim x y)`
```

Returns the maximum of x-y and 0.

• ### exp

Function v1.0
````(exp x)`
```

Returns e**x, the base-e exponential of x.

• ### exp-2

Function v1.0
````(exp-2 x)`
```

Returns 2**x, the base-2 exponential of x.

• ### exp-minus-1

Function v1.0
````(exp-minus-1 x)`
```

Returns e**x - 1, the base-e exponential of x minus 1.

This is more accurate than (- (exp x) 1.) when x is near zero.

• ### floor

Function v1.0
````(floor x)`
```

Returns the greatest integer value greater than or equal to x.

• ### hypot

Function v1.0
````(hypot p q)`
```

Returns Sqrt(p*p + q*q), taking care to avoid unnecessary overflow and underflow.

• ### inf

Function v1.0
````(inf sign)`
```

Returns positive infinity if sign >= 0, negative infinity if sign < 0.

• ### inf?

Function v1.0
````(inf? x sign)`
```

Returns whether x is an infinity.

If sign > 0, returns whether x is positive infinity; if < 0, whether negative infinity; if == 0, whether either infinity.

• ### log

Function v1.0
````(log x)`
```

Returns the natural logarithm of x.

• ### log-10

Function v1.0
````(log-10 x)`
```

Returns the decimal logarithm of x.

• ### log-2

Function v1.0
````(log-2 x)`
```

Returns the binary logarithm of x.

• ### log-binary

Function v1.0
````(log-binary x)`
```

Returns the binary exponent of x.

• ### log-plus-1

Function v1.0
````(log-plus-1 x)`
```

Returns the natural logarithm of 1 plus x.

This is more accurate than (log (+ 1 x)) when x is near zero.

• ### modf

Function v1.0
````(modf x)`
```

Returns a vector with the integer and fractional floating-point numbers that sum to x.

Both values have the same sign as x.

• ### nan

Function v1.0
````(nan)`
```

Returns an IEEE 754 "not-a-number" value.

• ### nan?

Function v1.0
````(nan? x)`
```

Returns whether x is an IEEE 754 "not-a-number" value.

• ### next-after

Function v1.0
````(next-after x y)`
```

Returns the next representable Double value after x towards y.

• ### pow

Function v1.0
````(pow x y)`
```

Returns x**y, the base-x exponential of y.

• ### pow-10

Function v1.0
````(pow-10 x)`
```

Returns 10**x, the base-10 exponential of x.

• ### precision

Function v1.0
````(precision f)`
```

Returns the precision of a Number.

The precision excludes any sign or exponent. For a BigInt, it's the
number of bits needed to represent the number; for a BigFloat, Int,
or Double, it's the number of bits available in that instance or
type. E.g. (precision 1) returns either 31 or 63, depending on
whether the Joker executable is 32-bit or 64-bit (for integers);
(precision 1.0) returns 53 (as Double is always a float64); and
(precision 1.0M) returns 53 as well, though prepending or appending
enough 0 digits will result in a BigFloat with more precision
reported.

If f is not a supported Number type (such as Ratio), a panic
results.

• ### round

Function v1.0
````(round x)`
```

Returns the integer nearest to x, rounding half away from zero.

• ### round-to-even

Function v1.0
````(round-to-even x)`
```

Returns the integer nearest to x, rounding ties to the nearest even integer.

• ### set-precision

Function v1.0
````(set-precision prec f)`
```

Returns a copy of a BigFloat with the specified precision.

Calls Go's math/big.(*Float)SetPrec(prec) on a copy of f. prec must
evaluate to a non-negative integer. Returns the resulting BigFloat.

• ### sign-bit

Function v1.0
````(sign-bit x)`
```

Returns whether x is negative or negative zero.

• ### sin

Function v1.0
````(sin x)`
```

Returns the sine of the radian argument x.

• ### sqrt

Function v1.0
````(sqrt x)`
```

Returns the square root of x.

• ### trunc

Function v1.0
````(trunc x)`
```

Returns the integer value of x.