Mathematics

Documentation for the %base desk's /lib/math.hoon library, which contains mathematical operations.

/lib/math is a standard library which lives outside of the /sys kernel and supports userspace applications which need transcendental mathematical constants and operators. /lib/math is not currently subject to kelvin versioning.

Like Lagoon, /lib/math is intended to support general-purpose linear algebraic types, but at this point it focuses on integers and IEEE 754 floating-point numbers.

Like the basic floating-point support in Hoon, /lib/math is divided into doors along the lines of the supported data types. At the current time, it supports:

  • +rh, half-precision (16-bit) floating-point numbers.

  • +rs, single-precision (32-bit) floating-point numbers.

  • +rd, double-precision (64-bit) floating-point numbers.

  • +rq, quadruple-precision (128-bit) floating-point numbers.

+rs

Single-precision IEEE 754 mathematical operations.

A container core for operations related to single-precision binary floats.

+rs has four rounding modes: round to nearest (%n), round up (%u), round down (%d), and round to zero (%z). The default rounding mode is %z. If you need a different rounding mode, you'd do something like =/ rs-n ~(. rs [%n rtol]) and then call the arms of your modified version instead.

+rs supports a relative tolerance for precision of operations, which is set by the rtol parameter. The default value is _.1e-5, but you can change it by passing a different value in the rs door.

Source

++  rs
  ^|
  |_  $$:  r=$?(%n %u %d %z)   :: round nearest, up, down, to zero
          rtol=_.1e-5         :: relative tolerance for precision of operations
      ==

+tau

The value τ=2π\tau = 2 \pi (OEIS A019692), radian angle measure of a full turn.

Produces

The value of tau τ\tau or 2 pi π\pi, radian angle measure of a full turn, represented as a single-precision floating-point atom.

Source


+pi

The value pi (OEIS A000796), radian angle measure of a half turn.

Produces

The value of pi π\pi, radian angle measure of a half turn, represented as a single-precision floating-point atom.

Source


+e

Return the value e (Euler's constant) (OEIS A001113).

Produces

The value of e, represented as a single-precision floating-point atom.

Source


+phi

The value phi (golden ratio) (OEIS A001622).

Produces

The value of phi, represented as a single-precision floating-point atom.

Source


+sqt2

The value sqrt(2) (OEIS A002193).

Produces

The value of sqrt(2), represented as a single-precision floating-point atom.

Source


+invsqt2

The value 1/sqrt(2) (OEIS A010503).

Produces

The value of 1/sqrt(2), represented as a single-precision floating-point atom.

Source


+log2

The value log(2) (OEIS A002162).

Produces

The value of log(2), represented as a single-precision floating-point atom.

Source


+invlog2

The value 1/log(2).

Produces

The value of 1/log(2), represented as a single-precision floating-point atom.

Source


+log10

The value log(10) (OEIS A002392).

Produces

The value of log(10), represented as a single-precision floating-point atom.

Source


+huge

The value of the largest representable number.

Produces

The value of the largest representable number, represented as a single-precision floating-point atom.

Source


+tiny

The value of the smallest representable normal number.

Produces

The value of the smallest representable normal number, represented as a single-precision floating-point atom.

Source


+sea

Floating-point atom representation.

Accepts

A floating-point atom (@rs).

Produces

The $fn representation of the floating-point atom.

Source


+bit

Floating-point atom representation.

Accepts

The $fn representation of a floating-point atom.

Produces

A floating-point atom (@rs).

Source


+sun

Floating-point atom of an unsigned integer atom.

Accepts

An unsigned integer atom (@ud).

Produces

A floating-point atom (@rs).

Source


+san

Floating-point atom of a signed integer atom.

Accepts

A signed integer atom (@sd).

Produces

A floating-point atom (@rs).

Source


+exp

The value of e^x for a given floating-point atom.

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Source


+toi

The unitized signed integer atom of a rounded floating-point atom.

Accepts

A floating-point atom (@rs).

Produces

A unitized signed integer atom (@sd).

Source


+drg

The decimal form of a floating-point atom using the Dragon4 algorithm.

Accepts

A floating-point atom (@rs).

Produces

A decimal form (+dn).

Source


+grd

The floating-point atom of a decimal form. Inverse of +drg.

Accepts

A decimal form (+dn).

Produces

A floating-point atom (@rs).

Source


+lth

The comparison of two floating-point atoms, less than.

Accepts

A pair of floating-point atoms (@rs).

Produces

A $flag.

Source


+lte

The comparison of two floating-point atoms, less than or equal to.

Accepts

A pair of floating-point atoms (@rs).

Produces

A $flag.

Source


+leq

The comparison of two floating-point atoms, less than or equal to. Alias for +lte.

Accepts

A pair of floating-point atoms (@rs).

Produces

A $flag.

Source


+equ

The comparison of two floating-point atoms, equal to.

Accepts

A pair of floating-point atoms (@rs).

Produces

A $flag.

Source


+gth

The comparison of two floating-point atoms, greater than.

Accepts

A pair of floating-point atoms (@rs).

Produces

A $flag.

Source


+gte

The comparison of two floating-point atoms, greater than or equal to.

Accepts

A pair of floating-point atoms (@rs).

Produces

A $flag.

Source


+geq

The comparison of two floating-point atoms, greater than or equal to. Alias for +gte.

Accepts

A pair of floating-point atoms (@rs).

Produces

A $flag.

Source


+neq

The comparison of two floating-point atoms, not equal to.

Accepts

A pair of floating-point atoms (@rs).

Produces

A $flag.

Source


+is-close

The comparison of two floating-point atoms, within a relative tolerance (provided by the +rs door).

Accepts

A pair of floating-point atoms (@rs).

Produces

A $flag.

Source


+all-close

The comparison of a floating-point atom to a list of floating- point atoms, within a relative tolerance (provided by the +rs door).

Accepts

A pair of floating-point atoms (@rs).

Produces

A $flag.

Source


+is-int

Returns whether a floating-point value is an integer (no fractional part).

Accepts

A floating-point atom (@rs).

Produces

A $flag.

Source


+add

The sum of two floating-point atoms.

Accepts

A pair of floating-point atoms (@rs).

Produces

A floating-point atom (@rs).

Source


+sub

The difference of two floating-point atoms.

Accepts

A pair of floating-point atoms (@rs).

Produces

A floating-point atom (@rs).

Source


+mul

The product of two floating-point atoms.

Accepts

A pair of floating-point atoms (@rs).

Produces

A floating-point atom (@rs).

Source


+div

The quotient of two floating-point atoms.

Accepts

A pair of floating-point atoms (@rs).

Produces

A floating-point atom (@rs).

Source


+mod

The modulus of two floating-point atoms.

Accepts

A pair of floating-point atoms (@rs).

Produces

A floating-point atom (@rs).

Source


+fma

The fused multiply-add of three floating-point atoms.

Accepts

A triplet of floating-point atoms (@rs).

Produces

A floating-point atom (@rs).

Source


+sig

The sign of a floating-point atom.

Accepts

A floating-point atom (@rs).

Produces

A $flag.

Source


+sgn

The sign of a floating-point atom. Alias for +sig.

Accepts

A floating-point atom (@rs).

Produces

A $flag.

Source


+neg

The negation of a floating-point atom.

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Source


+factorial

The factorial of a floating-point atom. Assumes integer input.

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Source


+abs

The absolute value of a floating-point atom.

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Source


+exp

The exponential of a floating-point atom.

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Examples

Source


+sin

The sine of a floating-point atom.

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Examples

Source


+cos

The cosine of a floating-point atom.

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Examples

Source


+tan

The tangent of a floating-point atom.

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Examples

Source


+asin

The inverse sine of a floating-point atom.

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Examples

Source


+acos

The inverse cosine of a floating-point atom.

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Examples

Examples

Source


+atan

The inverse tangent of a floating-point atom.

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Examples

Source


+atan2

The inverse tangent of a floating-point coordinate.

Accepts

A pair of floating-point atoms (@rs), representing the y and x coordinates.

Produces

A floating-point atom (@rs).

Examples

Source


+pow-n

The power of a floating-point atom to an integer exponent.

Accepts

A pair of floating-point atoms (@rs), representing the base and the exponent.

Produces

A floating-point atom (@rs).

Examples

Source


+log

The natural logarithm of a floating-point atom.

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Examples

Source


+log-10

The base-10 logarithm of a floating-point atom.

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Examples

Source


+log-2

The base-2 logarithm of a floating-point atom.

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Examples

Source


+pow

The power of a floating-point atom to a floating-point exponent.

Accepts

A pair of floating-point atoms (@rs), representing the base and the exponent.

Produces

A floating-point atom (@rs).

Examples

Source


+sqrt

The square root of a floating-point atom. Alias for +sqt.

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Examples

Source


+sqt

The square root of a floating-point atom.

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Examples

Source


+cbrt

The cube root of a floating-point atom. Alias for +cbt. ]

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Examples

Source


+cbt

The cube root of a floating-point atom.

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Examples

Source


+arg

The argument of a floating-point atom (real argument = absolute value).

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Examples

Source


+round

The floating-point atom rounded to a given number of decimal places.

Accepts

A pair of floating-point atom (@rs) and an unsigned integer atom (@ud), where the integer specifies the number of significant digits to round to.

Produces

A floating-point atom (@rs).

Examples

Discussion

This is exceptionally sensitive to off-by-one FP rounding error.

Source


+round-places

The floating-point atom rounded to a given number of decimal places.

Accepts

A pair of floating-point atom (@rs) and an unsigned integer atom (@ud), where the integer specifies the number of significant digits to round to.

Produces

A floating-point atom (@rs).

Examples

Discussion

This is exceptionally sensitive to off-by-one FP rounding error.

Source


+round-bankers

The floating-point atom rounded to the nearest integer, with ties rounded to the nearest even integer.

Accepts

A floating-point atom (@rs).

Produces

A floating-point atom (@rs).

Examples

Source


+rd

Double-precision IEEE 754 mathematical operations.

A container core for operations related to double-precision binary floats.

+rd has four rounding modes: round to nearest (%n), round up (%u), round down (%d), and round to zero (%z). The default rounding mode is %z. If you need a different rounding mode, you'd do something like =/ rd-n ~(. rd [%n rtol]) and then call the arms of your modified version instead.

+rd supports a relative tolerance for precision of operations, which is set by the rtol parameter. The default value is _.~1e-10, but you can change it by passing a different value in the rd door.

Source


+tau

The value τ=2π\tau = 2 \pi (OEIS A019692), radian angle measure of a full turn.

Produces

The value of tau τ\tau or 2 pi π\pi, radian angle measure of a full turn, represented as a single-precision floating-point atom.

Examples

Source


+pi

The value pi (OEIS A000796), radian angle measure of a half turn.

Produces

The value of pi π\pi, radian angle measure of a half turn, represented as a single-precision floating-point atom.

Examples

Source


+e

Return the value e (Euler's constant) (OEIS A001113).

Produces

The value of e, represented as a double-precision floating-point atom.

Examples

Source


+phi

The value phi (golden ratio) (OEIS A001622).

Produces

The value of phi, represented as a double-precision floating-point atom.

Examples

Source


+sqt2

The value sqrt(2) (OEIS A002193).

Produces

The value of sqrt(2), represented as a double-precision floating-point atom.

Examples

Source


+invsqt2

The value 1/sqrt(2) (OEIS A010503).

Produces

The value of 1/sqrt(2), represented as a double-precision floating-point atom.

Examples

Source


+log2

The value log(2) (OEIS A002162).

Produces

The value of log(2), represented as a double-precision floating-point atom.

Examples

Source


+invlog2

The value 1/log(2).

Produces

The value of 1/log(2), represented as a double-precision floating-point atom.

Examples

Source


+log10

The value log(10) (OEIS A002392).

Produces

The value of log(10), represented as a double-precision floating-point atom.

Examples

Source


+huge

The value of the largest representable number.

Produces

The value of the largest representable number, represented as a double-precision floating-point atom.

Examples

Source


+tiny

The value of the smallest representable normal number.

Produces

The value of the smallest representable normal number, represented as a double-precision floating-point atom.

Examples

Source


+sea

Floating-point atom representation.

Accepts

A floating-point atom (@rd).

Produces

The $fn representation of the floating-point atom.

Examples

Source


+bit

Floating-point atom representation.

Accepts

The $fn representation of a floating-point atom.

Produces

A floating-point atom (@rd).

Examples

Source


+sun

Floating-point atom of an unsigned integer atom.

Accepts

An unsigned integer atom (@ud).

Produces

A floating-point atom (@rd).

Examples

Source


+san

Floating-point atom of a signed integer atom.

Accepts

A signed integer atom (@sd).

Produces

A floating-point atom (@rd).

Examples

Source


+toi

The unitized signed integer atom of a rounded floating-point atom.

Accepts

A floating-point atom (@rd).

Produces

A unitized signed integer atom (@sd).

Examples

Source


+drg

The decimal form of a floating-point atom using the Dragon4 algorithm.

Accepts

A floating-point atom (@rd).

Produces

A decimal form (+dn).

Examples

Source


+grd

The floating-point atom of a decimal form. Inverse of +drg.

Accepts

A decimal form (+dn).

Produces

A floating-point atom (@rd).

Examples

Source


+lth

The comparison of two floating-point atoms, less than.

Accepts

A pair of floating-point atoms (@rd).

Produces

A $flag.

Examples

Source


+lte

The comparison of two floating-point atoms, less than or equal to.

Accepts

A pair of floating-point atoms (@rd).

Produces

A $flag.

Examples

Source


+leq

The comparison of two floating-point atoms, less than or equal to. Alias for +lte.

Accepts

A pair of floating-point atoms (@rd).

Produces

A $flag.

Examples

Source


+equ

The comparison of two floating-point atoms, equal to.

Accepts

A pair of floating-point atoms (@rd).

Produces

A $flag.

Examples

Source


+gth

The comparison of two floating-point atoms, greater than.

Accepts

A pair of floating-point atoms (@rd).

Produces

A $flag.

Examples

Source


+gte

The comparison of two floating-point atoms, greater than or equal to.

Accepts

A pair of floating-point atoms (@rd).

Produces

A $flag.

Examples

Source


+geq

The comparison of two floating-point atoms, greater than or equal to. Alias for +gte.

Accepts

A pair of floating-point atoms (@rd).

Produces

A $flag.

Examples

Source


+neq

The comparison of two floating-point atoms, not equal to.

Accepts

A pair of floating-point atoms (@rd).

Produces

A $flag.

Examples

Source


+is-close

The comparison of two floating-point atoms, within a relative tolerance (provided by the +rd door).

Accepts

A pair of floating-point atoms (@rd).

Produces

A $flag.

Examples

Source


+all-close

The comparison of a floating-point atom to a list of floating- point atoms, within a relative tolerance (provided by the +rd door).

Accepts

A pair of floating-point atoms (@rd).

Produces

A $flag.

Examples

Source


+is-int

Returns whether a floating-point value is an integer (no fractional part).

Accepts

A floating-point atom (@rd).

Produces

A $flag.

Examples

Source


+add

The sum of two floating-point atoms.

Accepts

A pair of floating-point atoms (@rd).

Produces

A floating-point atom (@rd).

Examples

Source


+sub

The difference of two floating-point atoms.

Accepts

A pair of floating-point atoms (@rd).

Produces

A floating-point atom (@rd).

Examples

Source


+mul

The product of two floating-point atoms.

Accepts

A pair of floating-point atoms (@rd).

Produces

A floating-point atom (@rd).

Examples

Source


+div

The quotient of two floating-point atoms.

Accepts

A pair of floating-point atoms (@rd).

Produces

A floating-point atom (@rd).

Examples

Source


+fma

The fused multiply-add of three floating-point atoms.

Accepts

A triplet of floating-point atoms (@rd).

Produces

A floating-point atom (@rd).

Examples

Source


+sig

The sign of a floating-point atom.

Accepts

A floating-point atom (@rd).

Produces

A $flag.

Examples

Source


+sgn

The sign of a floating-point atom. Alias for +sig.

Accepts

A floating-point atom (@rd).

Produces

A $flag.

Examples

Source


+neg

The negation of a floating-point atom.

Accepts

A floating-point atom (@rd).

Produces

A floating-point atom (@rd).

Examples

Source


+factorial

The factorial of a floating-point atom. Assumes integer input.

Accepts

A floating-point atom (@rd).

Produces

A floating-point atom (@rd).

Examples

Source


+abs

The absolute value of a floating-point atom.

Accepts

A floating-point atom (@rd).

Produces

A floating-point atom (@rd).

Examples

Source


+exp

The exponential of a floating-point atom.

Accepts

A floating-point atom (@rd).

Produces

A floating-point atom (@rd).

Examples

Source


+sin

The sine of a floating-point atom.

Accepts

A floating-point atom (@rd).

Produces

A floating-point atom (@rd).

Examples

Source


+cos

The cosine of a floating-point atom.

Accepts

A floating-point atom (@rd).

Produces

A floating-point atom (@rd).

Examples

Source


+tan

The tangent of a floating-point atom.

Accepts

A floating-point atom (@rd).

Produces

A floating-point atom (@rd).

Examples

Source


+asin

The inverse sine of a floating-point atom.

Accepts

A floating-point atom (@rd).

Produces

A floating-point atom (@rd).

Examples

Source


+acos

The inverse cosine of a floating-point atom.

Accepts

A floating-point atom (@rd).

Produces

A floating-point atom (@rd).

Examples

Source


+atan

The inverse tangent of a floating-point atom.

Accepts

A floating-point atom (@rd).

Produces

A floating-point atom (@rd).

Examples

Source


+atan2

The inverse tangent of a floating-point coordinate.

Accepts

A pair of floating-point atoms (@rd), representing the y and x coordinates.

Produces

A floating-point atom (@rd).

Examples

Source


+pow-n

Returns the power of a floating-point atom to an integer exponent.

Accepts

A pair of floating-point atoms (@rd), where the first is the base and the second is the exponent.

Produces

A floating-point atom (@rd).

Examples

Source

+log

The natural logarithm of a floating-point atom.

Accepts

A floating-point atom (@rd).

Produces

A floating-point atom (@rd).

Examples

Source

+log-10

The base-10 logarithm of a floating-point atom.

Accepts

A floating-point atom (@rd).

Produces

A floating-point atom (@rd).

Examples

Source

+log-2

The base-2 logarithm of a floating-point atom.

Accepts

A floating-point atom (@rd).

Produces

A floating-point atom (@rd).

Examples

Source

+pow

The power of a floating-point atom to a floating-point exponent.

Accepts

A pair of floating-point atoms (@rd), where the first is the base and the second is the exponent.

Produces

A floating-point atom (@rd).

Examples

Source

+sqrt

The square root of a floating-point atom. Alias for +sqt.

Accepts

A floating-point atom (@rd).

Produces

A floating-point atom (@rd).

Examples

Source

+sqt

The square root of a floating-point atom.

Accepts

A floating-point atom (@rd).

Produces

A floating-point atom (@rd).

Examples

Source

+cbrt

The cube root of a floating-point atom. Alias for +cbt.

Accepts

A floating-point atom (@rd).

Produces

A floating-point atom (@rd).

Examples

Source

+cbt

The cube root of a floating-point atom.

Accepts

A floating-point atom (@rd).

Produces

A floating-point atom (@rd).

Examples

Source

+arg

The argument of a floating-point atom (real argument = absolute value).

Accepts

A floating-point atom (@rd).

Produces

A floating-point atom (@rd).

Examples

Source

+round

The rounding of a floating-point atom to a given number of decimal places.

Accepts

A pair of floating-point atoms (@rd and @ud), where the first is the value to round and the second is the number of decimal places.

Produces

A floating-point atom (@rd).

Examples

Source

+round-places

Rounds a floating-point atom to a specified number of decimal places.

Accepts

A pair of floating-point atoms (@rd and @ud), where the first is the value to round and the second is the number of decimal places.

Produces

A floating-point atom (@rd).

Examples

Discussion

This is exceptionally sensitive to off-by-one floating-point rounding error.

Source

+round-bankers

The floating-point atom rounded to the nearest integer, with ties rounded to the nearest even integer.

Accepts

A floating-point atom (@rd).

Produces

A floating-point atom (@rd).

Examples

Source


+rh

Half-precision IEEE 754 floating-point arithmetic.

A container core for operations related to half-precision binary floats.

+rh has four rounding modes: round to nearest (%n), round up (%u), round down (%d), and round to zero (%z). The default rounding mode is %z. If you need a different rounding mode, you'd do something like =/ rh-n ~(. rh [%n rtol]) and then call the arms of your modified version instead.

+rh supports a relative tolerance for precision of operations, which is set by the rtol parameter. The default value is _.~~1e-2, but you can change it by passing a different value in the rh door.

Source


+tau

The value τ=2π\tau = 2 \pi (OEIS A019692), radian angle measure of a full turn.

Produces

The value of tau τ\tau or 2 pi π\pi, radian angle measure of a full turn, represented as a single-precision floating-point atom.

Examples

Source

+pi

The value pi (OEIS A000796), radian angle measure of a half turn.

Produces

The value of pi π\pi, radian angle measure of a half turn, represented as a single-precision floating-point atom.

Examples

Source

+e

The value e (Euler's constant) (OEIS A001113).

Produces

The value of e, represented as a half-precision floating-point atom.

Examples

Source

+phi

The value phi (golden ratio) (OEIS A001622).

Produces

The value of phi, represented as a half-precision floating-point atom.

Examples

Source

+sqt2

The value sqrt(2) (OEIS A002193).

Produces

The value of sqrt(2), represented as a half-precision floating-point atom.

Examples

Source

+invsqt2

The value 1/sqrt(2) (OEIS A010503).

Produces

The value of 1/sqrt(2), represented as a half-precision floating-point atom.

Examples

Source

+log2

The value log(2) (OEIS A002162).

Produces

The value of log(2), represented as a half-precision floating-point atom.

Examples

Source

+invlog2

The value 1/log(2).

Produces

The value of 1/log(2), represented as a half-precision floating-point atom.

Examples

Source

+log10

The value log(10) (OEIS A002392).

Produces

The value of log(10), represented as a half-precision floating-point atom.

Examples

Source

+huge

The value of the largest representable number.

Produces

The value of the largest representable number, represented as a half-precision floating-point atom.

Examples

Source

+tiny

The value of the smallest representable normal number.

Produces

The value of the smallest representable normal number, represented as a half-precision floating-point atom.

Examples

Source

+sea

Floating-point atom representation.

Accepts

A floating-point atom (@rh).

Produces

A $fn representation of the floating-point atom.

Examples

Source

+bit

The floating-point atom representation of a $fn.

Accepts

A $fn representation of a floating-point atom.

Produces

A floating-point atom (@rh).

Examples

Source

+sun

Floating-point atom of an unsigned integer.

Accepts

An unsigned integer atom (@ud).

Produces

A floating-point atom (@rh).

Examples

Source

+san

The floating-point atom of a signed integer.

Accepts

A signed integer atom (@sd).

Produces

A floating-point atom (@rh).

Examples

Source

+toi

The unitized signed integer atom of a rounded floating-point atom.

Accepts

A floating-point atom (@rh).

Produces

A unitized signed integer atom (@sd).

Examples

Source

+drg

The decimal form of a floating-point atom using the Dragon4 algorithm.

Accepts

A floating-point atom (@rh).

Produces

A decimal form (+dn).

Examples

Source

+grd

The floating-point atom of a decimal form. Inverse of +drg.

Accepts

A decimal form (+dn).

Produces

A floating-point atom (@rh).

Examples

Source

+lth

The comparison of two floating-point atoms, less than.

Accepts

A pair of floating-point atoms (@rh).

Produces

A $flag.

Examples

Source


+lte

The comparison of two floating-point atoms, less than or equal to.

Accepts

A pair of floating-point atoms (@rh).

Produces

A $flag.

Examples

Source


+leq

The comparison of two floating-point atoms, less than or equal to. Alias for +lte.

Accepts

A pair of floating-point atoms (@rh).

Produces

A $flag.

Examples

Source


+equ

The comparison of two floating-point atoms, equal to.

Accepts

A pair of floating-point atoms (@rh).

Produces

A $flag.

Examples

Source


+gth

The comparison of two floating-point atoms, greater than.

Accepts

A pair of floating-point atoms (@rh).

Produces

A $flag.

Examples

Source


+gte

The comparison of two floating-point atoms, greater than or equal to.

Accepts

A pair of floating-point atoms (@rh).

Produces

A $flag.

Examples

Source


+geq

The comparison of two floating-point atoms, greater than or equal to. Alias for +gte.

Accepts

A pair of floating-point atoms (@rh).

Produces

A $flag.

Examples

Source


+neq

The comparison of two floating-point atoms, not equal to.

Accepts

A pair of floating-point atoms (@rh).

Produces

A $flag.

Examples

Source


+is-close

The comparison of two floating-point atoms, within a relative tolerance (provided by the +rh door).

Accepts

A pair of floating-point atoms (@rh).

Produces

A $flag.

Examples

Source


+all-close

The comparison of a floating-point atom to a list of floating-point atoms, within a relative tolerance (provided by the +rh door).

Accepts

A pair of floating-point atoms (@rh).

Produces

A $flag.

Examples

Source


+is-int

Returns whether a floating-point value is an integer (no fractional part).

Accepts

A floating-point atom (@rh).

Produces

A $flag.

Examples

Source


+add

The sum of two floating-point atoms.

Accepts

A pair of floating-point atoms (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+sub

The difference of two floating-point atoms.

Accepts

A pair of floating-point atoms (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+mul

The product of two floating-point atoms.

Accepts

A pair of floating-point atoms (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+div

The quotient of two floating-point atoms.

Accepts

A pair of floating-point atoms (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+fma

The fused multiply-add of three floating-point atoms.

Accepts

A triplet of floating-point atoms (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+sig

The sign of a floating-point atom.

Accepts

A floating-point atom (@rh).

Produces

A $flag.

Examples

Source


+sgn

The sign of a floating-point atom. Alias for +sig.

Accepts

A floating-point atom (@rh).

Produces

A $flag.

Examples

Source


+neg

The negation of a floating-point atom.

Accepts

A floating-point atom (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+factorial

The factorial of a floating-point atom. Assumes integer input.

Accepts

A floating-point atom (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+abs

The absolute value of a floating-point atom.

Accepts

A floating-point atom (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+exp

The exponential of a floating-point atom.

Accepts

A floating-point atom (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+sin

The sine of a floating-point atom.

Accepts

A floating-point atom (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+cos

The cosine of a floating-point atom.

Accepts

A floating-point atom (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+tan

The tangent of a floating-point atom.

Accepts

A floating-point atom (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+asin

The inverse sine of a floating-point atom.

Accepts

A floating-point atom (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+acos

The inverse cosine of a floating-point atom.

Accepts

A floating-point atom (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+atan

The inverse tangent of a floating-point atom.

Accepts

A floating-point atom (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+atan2

The inverse tangent of a floating-point coordinate.

Accepts

A pair of floating-point atoms (@rh), representing the y and x coordinates.

Produces

A floating-point atom (@rh).

Examples

Source


+pow-n

Returns the power of a floating-point atom to an integer exponent.

Accepts

A pair of floating-point atoms (@rh), where the first is the base and the second is the exponent.

Produces

A floating-point atom (@rh).

Examples

Source


+log

The natural logarithm of a floating-point atom.

Accepts

A floating-point atom (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+log-10

The base-10 logarithm of a floating-point atom.

Accepts

A floating-point atom (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+log-2

The base-2 logarithm of a floating-point atom.

Accepts

A floating-point atom (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+pow

The power of a floating-point atom to a floating-point exponent.

Accepts

A pair of floating-point atoms (@rh), where the first is the base and the second is the exponent.

Produces

A floating-point atom (@rh).

Examples

Source


+sqrt

The square root of a floating-point atom. Alias for +sqt.

Accepts

A floating-point atom (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+sqt

The square root of a floating-point atom.

Accepts

A floating-point atom (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+cbrt

The cube root of a floating-point atom. Alias for +cbt.

Accepts

A floating-point atom (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+cbt

The cube root of a floating-point atom.

Accepts

A floating-point atom (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+arg

The argument of a floating-point atom (real argument = absolute value).

Accepts

A floating-point atom (@rh).

Produces

A floating-point atom (@rh).

Examples

Source


+rq

Quadruple-precision IEEE 754 floating-point arithmetic.

A container core for operations related to quadruple-precision binary floats.

+rq has four rounding modes: round to nearest (%n), round up (%u), round down (%d), and round to zero (%z). The default rounding mode is %z. If you need a different rounding mode, you'd do something like =/ rq-n ~(. rq [%n rtol]) and then call the arms of your modified version instead.

+rq supports a relative tolerance for precision of operations, which is set by the rtol parameter. The default value is _.~~~1e-20, but you can change it by passing a different value in the rq door.

Source


+tau

The value τ=2π\tau = 2 \pi (OEIS A019692), radian angle measure of a full turn.

Produces

The value of tau τ\tau or 2 pi π\pi, radian angle measure of a full turn, represented as a single-precision floating-point atom.

Examples

Source

+pi

The value pi (OEIS A000796), radian angle measure of a half turn.

Produces

The value of pi π\pi, radian angle measure of a half turn, represented as a single-precision floating-point atom.

Examples

Source

+e

The value e (Euler's constant) (OEIS A001113).

Produces

The value of e, represented as a quad-precision floating-point atom.

Examples

Source

+phi

The value phi (golden ratio) (OEIS A001622).

Produces

The value of phi, represented as a quad-precision floating-point atom.

Examples

Source

+sqt2

The value sqrt(2) (OEIS A002193).

Produces

The value of sqrt(2), represented as a quad-precision floating-point atom.

Examples

Source

+invsqt2

The value 1/sqrt(2) (OEIS A010503).

Produces

The value of 1/sqrt(2), represented as a quad-precision floating-point atom.

Examples

Source

+log2

The value log(2) (OEIS A002162).

Produces

The value of log(2), represented as a quad-precision floating-point atom.

Examples

Source

+invlog2

The value 1/log(2).

Produces

The value of 1/log(2), represented as a quad-precision floating-point atom.

Examples

Source

+log10

The value log(10) (OEIS A002392).

Produces

The value of log(10), represented as a quad-precision floating-point atom.

Examples

Source

+huge

The value of the largest representable number.

Produces

The value of the largest representable number, represented as a quad-precision floating-point atom.

Examples

Source

+tiny

The value of the smallest representable normal number.

Produces

The value of the smallest representable normal number, represented as a quad-precision floating-point atom.

Examples

Source


+sea

Floating-point atom representation.

Accepts

A floating-point atom (@rq).

Produces

The $fn representation of the floating-point atom.

Source


+bit

Floating-point atom representation.

Accepts

The $fn representation of a floating-point atom.

Produces

A floating-point atom (@rq).

Source


+sun

Floating-point atom of an unsigned integer atom.

Accepts

An unsigned integer atom (@ud).

Produces

A floating-point atom (@rq).

Source


+san

Floating-point atom of a signed integer atom.

Accepts

A signed integer atom (@sd).

Produces

A floating-point atom (@rq).

Source


+toi

The unitized signed integer atom of a rounded floating-point atom.

Accepts

A floating-point atom (@rq).

Produces

A unitized signed integer atom (@sd).

Source


+drg

The decimal form of a floating-point atom using the Dragon4 algorithm.

Accepts

A floating-point atom (@rq).

Produces

A decimal form (+dn).

Source


+grd

The floating-point atom of a decimal form. Inverse of +drg.

Accepts

A decimal form (+dn).

Produces

A floating-point atom (@rq).

Source


+lth

The comparison of two floating-point atoms, less than.

Accepts

A pair of floating-point atoms (@rq).

Produces

A $flag.

Source


+lte

The comparison of two floating-point atoms, less than or equal to.

Accepts

A pair of floating-point atoms (@rq).

Produces

A $flag.

Source


+leq

The comparison of two floating-point atoms, less than or equal to. Alias for +lte.

Accepts

A pair of floating-point atoms (@rq).

Produces

A $flag.

Source


+equ

The comparison of two floating-point atoms, equal to.

Accepts

A pair of floating-point atoms (@rq).

Produces

A $flag.

Source


+gth

The comparison of two floating-point atoms, greater than.

Accepts

A pair of floating-point atoms (@rq).

Produces

A $flag.

Source


+gte

The comparison of two floating-point atoms, greater than or equal to.

Accepts

A pair of floating-point atoms (@rq).

Produces

A $flag.

Source


+geq

The comparison of two floating-point atoms, greater than or equal to. Alias for +gte.

Accepts

A pair of floating-point atoms (@rq).

Produces

A $flag.

Source


+neq

The comparison of two floating-point atoms, not equal to.

Accepts

A pair of floating-point atoms (@rq).

Produces

A $flag.

Source


+is-close

The comparison of two floating-point atoms, within a relative tolerance (provided by the +rq door).

Accepts

A pair of floating-point atoms (@rq).

Produces

A $flag.

Source


+all-close

The comparison of a floating-point atom to a list of floating- point atoms, within a relative tolerance (provided by the +rq door).

Accepts

A pair of floating-point atoms (@rq).

Produces

A $flag.

Source


+is-int

Returns whether a floating-point value is an integer (no fractional part).

Accepts

A floating-point atom (@rq).

Produces

A $flag.

Source


+add

The sum of two floating-point atoms.

Accepts

A pair of floating-point atoms (@rq).

Produces

A floating-point atom (@rq).

Source


+sub

The difference of two floating-point atoms.

Accepts

A pair of floating-point atoms (@rq).

Produces

A floating-point atom (@rq).

Source


+mul

The product of two floating-point atoms.

Accepts

A pair of floating-point atoms (@rq).

Produces

A floating-point atom (@rq).

Source


+div

The quotient of two floating-point atoms.

Accepts

A pair of floating-point atoms (@rq).

Produces

A floating-point atom (@rq).

Source


+fma

The fused multiply-add of three floating-point atoms.

Accepts

A triplet of floating-point atoms (@rq).

Produces

A floating-point atom (@rq).

Source


+sig

The sign of a floating-point atom.

Accepts

A floating-point atom (@rq).

Produces

A $flag.

Source


+sgn

The sign of a floating-point atom. Alias for +sig.

Accepts

A floating-point atom (@rq).

Produces

A $flag.

Source


+neg

The negation of a floating-point atom.

Accepts

A floating-point atom (@rq).

Produces

A floating-point atom (@rq).

Source


+factorial

The factorial of a floating-point atom. Assumes integer input.

Accepts

A floating-point atom (@rq).

Produces

A floating-point atom (@rq).

Source


+abs

The absolute value of a floating-point atom.

Accepts

A floating-point atom (@rq).

Produces

A floating-point atom (@rq).

Source


+exp

The exponential of a floating-point atom.

Accepts

A floating-point atom (@rq).

Produces

A floating-point atom (@rq).

Examples

Source


+sin

The sine of a floating-point atom.

Accepts

A floating-point atom (@rq).

Produces

A floating-point atom (@rq).

Examples

Source


+cos

The cosine of a floating-point atom.

Accepts

A floating-point atom (@rq).

Produces

A floating-point atom (@rq).

Examples

Source


+tan

The tangent of a floating-point atom.

Accepts

A floating-point atom (@rq).

Produces

A floating-point atom (@rq).

Examples

Source


+asin

The inverse sine of a floating-point atom.

Accepts

A floating-point atom (@rq).

Produces

A floating-point atom (@rq).

Examples

Source


+acos

The inverse cosine of a floating-point atom.

Accepts

A floating-point atom (@rq).

Produces

A floating-point atom (@rq).

Examples

Source


+atan

The inverse tangent of a floating-point atom.

Accepts

A floating-point atom (@rq).

Produces

A floating-point atom (@rq).

Examples

Source


+atan2

The inverse tangent of a floating-point coordinate.

Accepts

A pair of floating-point atoms (@rq), representing the y and x coordinates.

Produces

A floating-point atom (@rq).

Examples

Source


+pow-n

The power of a floating-point atom to an integer exponent.

Accepts

A pair of floating-point atoms (@rq), representing the base and the exponent.

Produces

A floating-point atom (@rq).

Examples

Source


+log

The natural logarithm of a floating-point atom.

Accepts

A floating-point atom (@rq).

Produces

A floating-point atom (@rq).

Examples

Source


+log-10

The base-10 logarithm of a floating-point atom.

Accepts

A floating-point atom (@rq).

Produces

A floating-point atom (@rq).

Source


+log-2

The base-2 logarithm of a floating-point atom.

Accepts

A floating-point atom (@rq).

Produces

A floating-point atom (@rq).

Source


+pow

The power of a floating-point atom to a floating-point exponent.

Accepts

A pair of floating-point atoms (@rq), representing the base and the exponent.

Produces

A floating-point atom (@rq).

Examples

Source


+sqrt

The square root of a floating-point atom. Alias for +sqt.

Accepts

A floating-point atom (@rq).

Produces

A floating-point atom (@rq).

Examples

Source


+sqt

The square root of a floating-point atom.

Accepts

A floating-point atom (@rq).

Produces

A floating-point atom (@rq).

Examples

Source


+cbrt

The cube root of a floating-point atom. Alias for +cbt.

Accepts

A floating-point atom (@rq).

Produces

A floating-point atom (@rq).

Examples

Source


+cbt

The cube root of a floating-point atom.

Accepts

A floating-point atom (@rq).

Produces

A floating-point atom (@rq).

Examples

Source


+arg

The argument of a floating-point atom (real argument = absolute value).

Accepts

A floating-point atom (@rq).

Produces

A floating-point atom (@rq).

Examples


+reference

A core of reference values in high precision as hard-coded string constants for reference and testing purposes.


+tau

The value τ=2π\tau = 2 \pi (OEIS A019692), radian angle measure of a full turn.

Source


+pi

The value π\pi (OEIS A000796), radian angle measure of a half turn.

Source


+e

The value ee (Euler's number, OEIS A001113).

Source


+phi

The value ϕ=1+52\phi = \frac{1+\sqrt{5}}{2} (the golden ratio, OEIS A001622).

Source


+sqt2

The square root of 2 (OEIS A002193).

Source


+invsqt2

The inverse square root of 2 (OEIS A010503).

Source


+log2

The natural logarithm of 2 (approximately 0.693147, OEIS A002392).

Source


+log10

The natural logarithm of 10 (approximately 2.302585, OEIS A002392).

Source

Last updated