.\" Automatically generated by Pandoc 2.9.2.1 .\" .TH "elvish-math" "7" "Jul 18, 2021" "Elvish 0.15.0" "Miscellaneous Information Manual" .hy .SH Introduction .PP The \f[C]math:\f[R] module provides mathematical functions and constants. .PP Function usages are given in the same format as in the reference doc for the builtin module. In particular, all the commands in this module conform to the pattern of commands that operate on numbers. .SH Variables .SS $math:e .IP .nf \f[C] $math:e \f[R] .fi .PP The value of \f[C]e\f[R] (https://en.wikipedia.org/wiki/E_(mathematical_constant)): 2.718281\&.... This variable is read-only. .SS $math:pi .IP .nf \f[C] $math:pi \f[R] .fi .PP The value of \f[C]\[*p]\f[R] (https://en.wikipedia.org/wiki/Pi): 3.141592\&.... This variable is read-only. .SH Functions .SS math:abs .IP .nf \f[C] math:abs $number \f[R] .fi .PP Computes the absolute value \f[C]$number\f[R]. Examples: .IP .nf \f[C] \[ti]> math:abs 1.2 \[u25B6] (float64 1.2) \[ti]> math:abs -5.3 \[u25B6] (float64 5.3) \f[R] .fi .SS math:acos .IP .nf \f[C] math:acos $number \f[R] .fi .PP Outputs the arccosine of \f[C]$number\f[R], in radians (not degrees). Examples: .IP .nf \f[C] \[ti]> math:acos 1 \[u25B6] (float64 1) \[ti]> math:acos 1.00001 \[u25B6] (float64 NaN) \f[R] .fi .SS math:acosh .IP .nf \f[C] math:acosh $number \f[R] .fi .PP Outputs the inverse hyperbolic cosine of \f[C]$number\f[R]. Examples: .IP .nf \f[C] \[ti]> math:acosh 1 \[u25B6] (float64 0) \[ti]> math:acosh 0 \[u25B6] (float64 NaN) \f[R] .fi .SS math:asin .IP .nf \f[C] math:asin $number \f[R] .fi .PP Outputs the arcsine of \f[C]$number\f[R], in radians (not degrees). Examples: .IP .nf \f[C] \[ti]> math:asin 0 \[u25B6] (float64 0) \[ti]> math:asin 1 \[u25B6] (float64 1.5707963267948966) \[ti]> math:asin 1.00001 \[u25B6] (float64 NaN) \f[R] .fi .SS math:asinh .IP .nf \f[C] math:asinh $number \f[R] .fi .PP Outputs the inverse hyperbolic sine of \f[C]$number\f[R]. Examples: .IP .nf \f[C] \[ti]> math:asinh 0 \[u25B6] (float64 0) \[ti]> math:asinh inf \[u25B6] (float64 +Inf) \f[R] .fi .SS math:atan .IP .nf \f[C] math:atan $number \f[R] .fi .PP Outputs the arctangent of \f[C]$number\f[R], in radians (not degrees). Examples: .IP .nf \f[C] \[ti]> math:atan 0 \[u25B6] (float64 0) \[ti]> math:atan $math:inf \[u25B6] (float64 1.5707963267948966) \f[R] .fi .SS math:atanh .IP .nf \f[C] math:atanh $number \f[R] .fi .PP Outputs the inverse hyperbolic tangent of \f[C]$number\f[R]. Examples: .IP .nf \f[C] \[ti]> math:atanh 0 \[u25B6] (float64 0) \[ti]> math:atanh 1 \[u25B6] (float64 +Inf) \f[R] .fi .SS math:ceil .IP .nf \f[C] math:ceil $number \f[R] .fi .PP Computes the ceiling of \f[C]$number\f[R]. Read the Go documentation (https://godoc.org/math#Ceil) for the details of how this behaves. Examples: .IP .nf \f[C] \[ti]> math:ceil 1.1 \[u25B6] (float64 2) \[ti]> math:ceil -2.3 \[u25B6] (float64 -2) \f[R] .fi .SS math:cos .IP .nf \f[C] math:cos $number \f[R] .fi .PP Computes the cosine of \f[C]$number\f[R] in units of radians (not degrees). Examples: .IP .nf \f[C] \[ti]> math:cos 0 \[u25B6] (float64 1) \[ti]> math:cos 3.14159265 \[u25B6] (float64 -1) \f[R] .fi .SS math:cosh .IP .nf \f[C] math:cosh $number \f[R] .fi .PP Computes the hyperbolic cosine of \f[C]$number\f[R]. Example: .IP .nf \f[C] \[ti]> math:cosh 0 \[u25B6] (float64 1) \f[R] .fi .SS math:floor .IP .nf \f[C] math:floor $number \f[R] .fi .PP Computes the floor of \f[C]$number\f[R]. Read the Go documentation (https://godoc.org/math#Floor) for the details of how this behaves. Examples: .IP .nf \f[C] \[ti]> math:floor 1.1 \[u25B6] (float64 1) \[ti]> math:floor -2.3 \[u25B6] (float64 -3) \f[R] .fi .SS math:is-inf .IP .nf \f[C] math:is-inf &sign=0 $number \f[R] .fi .PP Tests whether the number is infinity. If sign > 0, tests whether \f[C]$number\f[R] is positive infinity. If sign < 0, tests whether \f[C]$number\f[R] is negative infinity. If sign == 0, tests whether \f[C]$number\f[R] is either infinity. .IP .nf \f[C] \[ti]> math:is-inf 123 \[u25B6] $false \[ti]> math:is-inf inf \[u25B6] $true \[ti]> math:is-inf -inf \[u25B6] $true \[ti]> math:is-inf &sign=1 inf \[u25B6] $true \[ti]> math:is-inf &sign=-1 inf \[u25B6] $false \[ti]> math:is-inf &sign=-1 -inf \[u25B6] $true \f[R] .fi .SS math:is-nan .IP .nf \f[C] math:is-nan $number \f[R] .fi .PP Tests whether the number is a NaN (not-a-number). .IP .nf \f[C] \[ti]> math:is-nan 123 \[u25B6] $false \[ti]> math:is-nan (float64 inf) \[u25B6] $false \[ti]> math:is-nan (float64 nan) \[u25B6] $true \f[R] .fi .SS math:log .IP .nf \f[C] math:log $number \f[R] .fi .PP Computes the natural (base \f[I]e\f[R]) logarithm of \f[C]$number\f[R]. Examples: .IP .nf \f[C] \[ti]> math:log 1.0 \[u25B6] (float64 1) \[ti]> math:log -2.3 \[u25B6] (float64 NaN) \f[R] .fi .SS math:log10 .IP .nf \f[C] math:log10 $number \f[R] .fi .PP Computes the base 10 logarithm of \f[C]$number\f[R]. Examples: .IP .nf \f[C] \[ti]> math:log10 100.0 \[u25B6] (float64 2) \[ti]> math:log10 -1.7 \[u25B6] (float64 NaN) \f[R] .fi .SS math:log2 .IP .nf \f[C] math:log2 $number \f[R] .fi .PP Computes the base 2 logarithm of \f[C]$number\f[R]. Examples: .IP .nf \f[C] \[ti]> math:log2 8 \[u25B6] (float64 3) \[ti]> math:log2 -5.3 \[u25B6] (float64 NaN) \f[R] .fi .SS math:max .IP .nf \f[C] math:max $number... \f[R] .fi .PP Outputs the maximum number in the arguments. If there are no arguments an exception is thrown. If any number is NaN then NaN is output. .PP Examples: .IP .nf \f[C] \[ti]> put ?(math:max) \[u25B6] ?(fail \[aq]arity mismatch: arguments here must be 1 or more values, but is 0 values\[aq]) \[ti]> math:max 3 \[u25B6] (float 3) \[ti]> math:max 3 5 2 \[u25B6] (float 5) \[ti]> range 100 | math:max (all) \[u25B6] (float 99) \f[R] .fi .SS math:min .IP .nf \f[C] math:min $number... \f[R] .fi .PP Outputs the minimum number in the arguments. If there are no arguments an exception is thrown. If any number is NaN then NaN is output. .PP Examples: .IP .nf \f[C] \[ti]> put ?(math:min) \[u25B6] ?(fail \[aq]arity mismatch: arguments here must be 1 or more values, but is 0 values\[aq]) \[ti]> math:min 3 \[u25B6] (float 3) \[ti]> math:min 3 5 2 \[u25B6] (float 2) \[ti]> range 100 | math:min (all) \[u25B6] (float 0) \f[R] .fi .SS math:pow .IP .nf \f[C] math:pow $base $exponent \f[R] .fi .PP Output the result of raising \f[C]$base\f[R] to the power of \f[C]$exponent\f[R]. Examples: .IP .nf \f[C] \[ti]> math:pow 3 2 \[u25B6] (float64 9) \[ti]> math:pow -2 2 \[u25B6] (float64 4) \f[R] .fi .PP \[at]cf math:pow10 .SS math:pow10 .IP .nf \f[C] math:pow10 $exponent \f[R] .fi .PP Output the result of raising ten to the power of \f[C]$exponent\f[R] which must be an integer. Note that \f[C]$exponent > 308\f[R] results in +Inf and \f[C]$exponent < -323\f[R] results in zero. Examples: .IP .nf \f[C] \[ti]> math:pow10 2 \[u25B6] (float64 100) \[ti]> math:pow10 -3 \[u25B6] (float64 0.001) \f[R] .fi .PP \[at]cf math:pow .SS math:round .IP .nf \f[C] math:round $number \f[R] .fi .PP Outputs the nearest integer, rounding half away from zero. .IP .nf \f[C] \[ti]> math:round -1.1 \[u25B6] (float64 -1) \[ti]> math:round 2.5 \[u25B6] (float64 3) \f[R] .fi .SS math:round-to-even .IP .nf \f[C] math:round-to-even $number \f[R] .fi .PP Outputs the nearest integer, rounding ties to even. Examples: .IP .nf \f[C] \[ti]> math:round-to-even -1.1 \[u25B6] (float64 -1) \[ti]> math:round-to-even 2.5 \[u25B6] (float64 2) \f[R] .fi .SS math:sin .IP .nf \f[C] math:sin $number \f[R] .fi .PP Computes the sine of \f[C]$number\f[R] in units of radians (not degrees). Examples: .IP .nf \f[C] \[ti]> math:sin 0 \[u25B6] (float64 0) \[ti]> math:sin 3.14159265 \[u25B6] (float64 3.5897930298416118e-09) \f[R] .fi .SS math:sinh .IP .nf \f[C] math:sinh $number \f[R] .fi .PP Computes the hyperbolic sine of \f[C]$number\f[R]. Example: .IP .nf \f[C] \[ti]> math:sinh 0 \[u25B6] (float64 0) \f[R] .fi .SS math:sqrt .IP .nf \f[C] math:sqrt $number \f[R] .fi .PP Computes the square-root of \f[C]$number\f[R]. Examples: .IP .nf \f[C] \[ti]> math:sqrt 0 \[u25B6] (float64 0) \[ti]> math:sqrt 4 \[u25B6] (float64 2) \[ti]> math:sqrt -4 \[u25B6] (float64 NaN) \f[R] .fi .SS math:tan .IP .nf \f[C] math:tan $number \f[R] .fi .PP Computes the tangent of \f[C]$number\f[R] in units of radians (not degrees). Examples: .IP .nf \f[C] \[ti]> math:tan 0 \[u25B6] (float64 0) \[ti]> math:tan 3.14159265 \[u25B6] (float64 -0.0000000035897930298416118) \f[R] .fi .SS math:tanh .IP .nf \f[C] math:tanh $number \f[R] .fi .PP Computes the hyperbolic tangent of \f[C]$number\f[R]. Example: .IP .nf \f[C] \[ti]> math:tanh 0 \[u25B6] (float64 0) \f[R] .fi .SS math:trunc .IP .nf \f[C] math:trunc $number \f[R] .fi .PP Outputs the integer portion of \f[C]$number\f[R]. .IP .nf \f[C] \[ti]> math:trunc -1.1 \[u25B6] (float64 -1) \[ti]> math:trunc 2.5 \[u25B6] (float64 2) \f[R] .fi