Next: , Previous: , Up: iklib numerics   [Index]


6.32.6 Additional math functions

The following bindings are exported by the library (vicare).

Arithmetic functions

Function: add1 num
Function: sub1 num

Add or subtract ‘1’ to num, which can be any number.

Function: square num

Return the square of num: num times num.

Function: cube num

Return the cube of num: num times num times num.

Function: cbrt num

Return the cubic root of num.

Function: quotient N1 N2
Function: remainder N1 N2
Function: quotient+remainder N1 N2

quotient+remainder returns two values: the quotient and the remainder of the number–theoretic integer division between the operands; quotient returns the quotient; remainder returns the remainder. N1 and N2 must be exact or inexact integers (fixnums, bignums, flonums); N2 must be non–zero.

The operations are defined as for quotient and remainder from (rnrs r5rs (6)).

Note that considering:

(quotient+remainder X Y)

according to R6RS:

(define (sign n)
  (cond ((negative? n) -1)
        ((positive? n) 1)
        (else 0)))

(define (quotient n1 n2)
  (* (sign n1) (sign n2) (div (abs n1) (abs n2))))

(define (remainder n1 n2)
  (* (sign n1) (mod (abs n1) (abs n2))))

(define (modulo n1 n2)
  (* (sign n2) (mod (* (sign n2) n1) (abs n2))))

so we have:

sign(quotient)  = sign(X) * sign(Y)
sign(remainder) = sign(X)
Function: sign X

Return a number object representing the sign of X, which must be a real number. When X is a:

fixnum
bignum

Return a fixnum representing the sign of X: +1 for positive, -1 for negative, 0 for zero.

flonum

Return a flonum representing the sign of X: +1.0 for positive, including +0.0 and +inf.0; -1 for negative, including -0.0 and -inf.0; +nan.0 for not–a–number.

ratnum

Return a fixnum representing the sign of the numerator of rn: +1 for positive, -1 for negative, 0 for zero.

Function: factorial I

Return the factorial of the non–negative integer I (which can be exact or inexact).

Hyperbolic functions

The num operand must be a real or complex number.

Function: sinh num
Function: cosh num
Function: tanh num

Hyperbolic functions.

Function: asinh num
Function: acosh num
Function: atanh num

Inverse hyperbolic functions.

Complex number functions

Function: complex-conjugate num

Return the complex conjugate of the number object num.


Next: , Previous: , Up: iklib numerics   [Index]