Node:Primitive Numerics, Next:, Previous:Scientific, Up:Numbers

21.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.

 \$abs x Scheme Procedure
 Return the absolute value of x.

 \$sqrt x Scheme Procedure
 Return the square root of x.

 \$expt x y Scheme Procedure scm_sys_expt (x, y) C Function
 Return x raised to the power of y. This procedure does not accept complex arguments.

 \$sin x Scheme Procedure
 Return the sine of x.

 \$cos x Scheme Procedure
 Return the cosine of x.

 \$tan x Scheme Procedure
 Return the tangent of x.

 \$asin x Scheme Procedure
 Return the arcsine of x.

 \$acos x Scheme Procedure
 Return the arccosine of x.

 \$atan x Scheme Procedure
 Return the arctangent of x in the range -PI/2 to PI/2.

 \$atan2 x y Scheme Procedure scm_sys_atan2 (x, y) C Function
 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.

 \$exp x Scheme Procedure
 Return e to the power of x, where e is the base of natural logarithms (2.71828...).

 \$log x Scheme Procedure
 Return the natural logarithm of x.

 \$sinh x Scheme Procedure
 Return the hyperbolic sine of x.

 \$cosh x Scheme Procedure
 Return the hyperbolic cosine of x.

 \$tanh x Scheme Procedure
 Return the hyperbolic tangent of x.

 \$asinh x Scheme Procedure
 Return the hyperbolic arcsine of x.

 \$acosh x Scheme Procedure
 Return the hyperbolic arccosine of x.

 \$atanh x Scheme Procedure
 Return the hyperbolic arctangent of x.

For the hyperbolic arc-functions, the Guile library exports C functions corresponding to these Scheme procedures, but taking and returning arguments of type double rather than the usual SCM.

 double scm_asinh (double x) C Function double scm_acosh (double x) C Function double scm_atanh (double x) C Function
 Return the hyperbolic arcsine, arccosine or arctangent of x respectively.

For all the other Scheme procedures above, except expt and atan2 (whose entries specifically mention an equivalent C function), the equivalent C functions are those provided by the standard mathematics library. The mapping is as follows.

 Scheme Procedure C Function \$abs fabs \$sqrt sqrt \$sin sin \$cos cos \$tan tan \$asin asin \$acos acos \$atan atan \$exp exp \$log log \$sinh sinh \$cosh cosh \$tanh tanh

Naturally, these C functions expect and return double arguments.