Next: , Previous: Scientific, Up: Numbers


5.5.2.13 Primitive Numeric Functions

Many of Guile's numeric procedures which accept any kind of numbers as arguments, including complex numbers, are implemented as Scheme procedures that use the following real number-based primitives. These primitives signal an error if they are called with complex arguments.

— Scheme Procedure: $abs x

Return the absolute value of x.

— Scheme Procedure: $sqrt x

Return the square root of x.

— Scheme Procedure: $expt x y
— C Function: scm_sys_expt (x, y)

Return x raised to the power of y. This procedure does not accept complex arguments.

— Scheme Procedure: $sin x

Return the sine of x.

— Scheme Procedure: $cos x

Return the cosine of x.

— Scheme Procedure: $tan x

Return the tangent of x.

— Scheme Procedure: $asin x

Return the arcsine of x.

— Scheme Procedure: $acos x

Return the arccosine of x.

— Scheme Procedure: $atan x

Return the arctangent of x in the range −PI/2 to PI/2.

— Scheme Procedure: $atan2 x y
— C Function: scm_sys_atan2 (x, y)

Return the arc tangent of the two arguments x and y. This is similar to calculating the arc tangent of x / y, except that the signs of both arguments are used to determine the quadrant of the result. This procedure does not accept complex arguments.

— Scheme Procedure: $exp x

Return e to the power of x, where e is the base of natural logarithms (2.71828...).

— Scheme Procedure: $log x

Return the natural logarithm of x.

— Scheme Procedure: $sinh x

Return the hyperbolic sine of x.

— Scheme Procedure: $cosh x

Return the hyperbolic cosine of x.

— Scheme Procedure: $tanh x

Return the hyperbolic tangent of x.

— Scheme Procedure: $asinh x

Return the hyperbolic arcsine of x.

— Scheme Procedure: $acosh x

Return the hyperbolic arccosine of x.

— Scheme Procedure: $atanh x

Return the hyperbolic arctangent of x.

C functions for the above are provided by the standard mathematics library. Naturally these expect and return double arguments (see Mathematics).

Scheme Procedure C Function


$abs fabs
$sqrt sqrt
$sin sin
$cos cos
$tan tan
$asin asin
$acos acos
$atan atan
$atan2 atan2
$exp exp
$expt pow
$log log
$sinh sinh
$cosh cosh
$tanh tanh
$asinh asinh
$acosh acosh
$atanh atanh

asinh, acosh and atanh are C99 standard but might not be available on older systems. Guile provides the following equivalents (on all systems).

— C Function: double scm_asinh (double x)
— C Function: double scm_acosh (double x)
— C Function: double scm_atanh (double x)

Return the hyperbolic arcsine, arccosine or arctangent of x respectively.