tur/math
thin wrappers around libm functions (sin, cos, sqrt, ...).
All functions forward to libc/libm with no capability requirements.
Since: Phase B1
sqrt
(sqrt [x :float] :float)
square root of a float (double precision).
| x | non-negative float value |
The square root of x.
(sqrt 2.0) ; => 1.41421
Since: Phase B1
fabs
(fabs [x :float] :float)
absolute value of a float.
| x | float value |
The absolute value of x.
(fabs -3.5) ; => 3.5
Since: Phase B1
floor
(floor [x :float] :float)
largest integer not greater than x.
| x | float value |
Floor of x as a float.
(floor 3.7) ; => 3
Since: Phase B1
ceil
(ceil [x :float] :float)
smallest integer not less than x.
| x | float value |
Ceiling of x as a float.
(ceil 3.2) ; => 4
Since: Phase B1
pow
(pow [x :float y :float] :float)
x raised to the power y.
| x | base value | |
| y | exponent |
x^y as a float.
(pow 2.0 10.0) ; => 1024
Since: Phase B1
exp
(exp [x :float] :float)
e raised to the power x.
| x | float exponent |
e^x.
(exp 1.0) ; => 2.71828
Since: Phase N2
log
(log [x :float] :float)
natural logarithm of a float.
| x | positive float value |
ln(x).
(log 2.718281828459045) ; => 1
Since: Phase N2
sin
(sin [x :float] :float)
sine of an angle in radians.
| x | angle in radians |
sin(x).
(sin 0.5) ; => 0.479426
Since: Phase N2
cos
(cos [x :float] :float)
cosine of an angle in radians.
| x | angle in radians |
cos(x).
(cos 0.5) ; => 0.877583
Since: Phase N2
atan2
(atan2 [y :float x :float] :float)
principal arc tangent of y/x, using the signs of both arguments to place the result in the correct quadrant.
| y | ordinate | |
| x | abscissa |
The angle in radians in (-pi, pi].
(atan2 1.5 0.0) ; => 1.5708
Since: Phase N2
int->float
(int->float [n :int] :float)
convert an integer to a float via numeric cast.
| n | integer value |
The integer converted to a double-precision float.
(int->float 42) ; => 42
Since: Phase B1
float->int
(float->int [x :float] :int)
truncate a float to an integer.
| x | float value |
The float truncated toward zero as an int.
(float->int 3.9) ; => 3
Since: Phase B1
printf-float6
(printf-float6 [x :float] :nil)
print a float to stdout with 6 decimal places followed by a newline; mirrors the output format of the C benchmarks.
| x | float value to print |
Since: Phase B1
PI
(def PI 3.141592653589793)
mathematical constant pi.
tan
(tan [x :float] :float)
tangent of a float (radians).
| x | angle in radians |
tan(x).
(tan 0.0) ; => 0
Since: r7rs-lang-plan R5
asin
(asin [x :float] :float)
arc sine of a float.
| x | a value in [-1, 1] |
asin(x), in radians.
(asin 1.0) ; => 1.5708
Since: r7rs-lang-plan R5
acos
(acos [x :float] :float)
arc cosine of a float.
| x | a value in [-1, 1] |
acos(x), in radians.
(acos 1.0) ; => 0
Since: r7rs-lang-plan R5
atan
(atan [x :float] :float)
arc tangent of a float (one argument; see atan2 for two).
| x | any float |
atan(x), in radians.
(atan 1.0) ; => 0.785398
Since: r7rs-lang-plan R5
trunc
(trunc [x :float] :float)
round a float toward zero.
| x | any float |
The integral float nearest x in the direction of zero.
(trunc -7.1) ; => -7
Since: r7rs-lang-plan R5
rint
(rint [x :float] :float)
round a float to the nearest integral float, ties to even.
This is the rounding R7RS round specifies: (rint 7.5) is 8, (rint 6.5) is 6. floor and ceil are the directed roundings; trunc goes toward zero.
| x | any float |
The nearest integral float, ties to even.
(rint 6.5) ; => 6
Since: r7rs-lang-plan R5