# The transcendentals Module¶

The transcendentals module, exported from the common-dylan library, provides a set of generic functions for ANSI C-like behavior over real numbers. The restrictions and error cases described in this document are intended to be the same as they are in ANSI C.

The single module, transcendentals, exports these generic functions and methods.

Because implementation of these functions might be by a standard library for transcendentals accessed by a foreign function interface, the exact precision and algorithms (and hence, the exact results) for all of these functions is explicitly unspecified. Note, however, that a program expects the following, even in libraries that are implemented by calling foreign libraries:

• Domain and range errors should be signalled as Dylan errors.

• Floating point precision contagion must obey Dylan rules (that is, functions called on single precision values return single precision results, and functions on double precision values return double precision results)

## Reference¶

This section contains a reference entry for each item exported from the common-dylan library’s transcendentals module.

`^` Generic function
Summary

Returns its first argument, raised to the power indicated by its second argument.

Signature

^ b x => y

Parameters
Values
Discussion

Returns `b` raised to the power `x`. If `b` is `0` and `x` is not positive, an error is signalled. If `b` is negative and `x` is not an integer, an error is signalled.

If `b` and `x` are both integers, the result is an integer. If `x` is negative, an error is signalled.

The floating point precision is given by the precision of `b`.

`acos` Generic function
Summary

Returns the arc cosine of its argument.

Signature

acos x => y

Parameters
• x – an instance of type `<real>`. The angle, in radians. If `x` is not in the range `[-1,+1]`, an error is signalled.

Values
Discussion

Returns the arc cosine of its argument. The floating point precision of the result is given by the precision of `x`.

`acosh` Generic function
Summary

Returns the hyperbolic arc cosine of its argument.

Signature

acosh x => y

Parameters
Values
Discussion

Returns the hyperbolic arc cosine of its argument. The floating point precision of the result is given by the precision of `x`.

`asin` Generic function
Summary

Returns the arc sine of its argument.

Signature

asin x => y

Parameters
• x – An instance of type `<real>`. The angle, in radians. If `x` is not in the range [-1,+1], an error is signalled.

Values
Discussion

Returns the arc sine of its argument. The floating point precision of the result is given by the precision of `x`.

`asinh` Generic function
Summary

Returns the hyperbolic arc sine of its argument.

Signature

asinh x => y

Parameters
Values
Discussion

Returns the hyperbolic arc sine of its argument. The floating point precision of the result is given by the precision of `x`.

`atan` Generic function
Summary

Returns the arc tangent of its argument.

Signature

atan x => y

Parameters
• x – An instance of type `<real>`. The angle, in radians. If `x` is not in the range [-1,+1], an error is signalled.

Values
Discussion

Returns the arc tangent of its argument. The floating point precision of the result is given by the precision of x.

`atan2` Generic function
Summary

Returns the arc tangent of one angle divided by another.

Signature

atan2 x y => z

Parameters
Values
Discussion

Returns the arc tangent of `x` divided by `y`. `x` may be zero if `y` is not zero. The signs of `x` and `y` are used to derive what quadrant the angle falls in.

The floating point precision of the result is given by the precision of `x`/`y`.

`atanh` Generic function
Summary

Returns the hyperbolic arc tangent of its argument.

Signature

atanh x => y

Parameters
Values
Discussion

Returns the hyperbolic arc tangent of its argument. The floating point precision of the result is given by the precision of `x`.

`cos` Generic function
Summary

Returns the cosine of its argument.

Signature

cos x => y

Parameters
Values
Discussion

Returns the cosine of its argument. The floating point precision of the result is given by the precision of `x`.

`cosh` Generic function
Summary

Returns the hyperbolic cosine of its argument.

Signature

cosh x => y

Parameters
Values
Discussion

Returns the hyperbolic cosine of its argument. The floating point precision of the result is given by the precision of `x`.

`\$double-e` Constant
summary

The value of e, the base of natural logarithms, as a double precision floating point number.

type

<double-float>

superclasses

`<float>`

description

The value of e, the base of natural logarithms, as a double precision floating point number.

`\$double-pi` Constant
Summary

The value of π as a double precision floating point number.

Type

<double-float>

Superclasses

`<float>`

Discussion

The value of π as a double precision floating point number.

`exp` Generic function
Summary

Returns e, the base of natural logarithms, raised to the power indicated by its argument.

Signature

exp x => y

Parameters
Values
Discussion

Returns e, the base of natural logarithms, raised to the power `x`. The floating point precision is given by the precision of `x`.

`hypot` Generic function
Summary

Returns the Euclidian distance.

Signature

hypot x, y => z

Parameters
Values
Discussion

Returns the Euclidian distance without unnecessary overflow or underflow.

The floating point precision is given by the precision of `x`.

`isqrt` Generic function
Summary

Returns the integer square root of its argument.

Signature

isqrt x => y

Parameters
Values
Discussion

Returns the integer square root of `x`, that is the greatest integer less than or equal to the exact positive square root of `x`. If `x` < `0`, an error is signalled.

`log` Generic function
Summary

Returns the natural logarithm of its argument.

Signature

log x => y

Parameters
Values
Discussion

Returns the natural logarithm of `x` to the base e. If x <= 0 <= 1, an error is signalled. The floating point precision of the result is given by the precision of `x`.

`logn` Function
Summary

Returns the logarithm of its argument to the given base.

Signature

logn x b => y

Parameters
Values
Discussion

Returns the logarithm of `x` to the base `b`. If x <= 0 <= 1, an error is signalled. The floating point precision of the result is given by the precision of `x`.

`ilog2` Function
Summary

Returns the base two logarithm of its argument, truncated to an integer.

Signature

ilog2 x => y

Parameters
Values
Discussion

Returns the integer base two logarithm of `x`, that is the greatest integer less than or equal to the exact base two logarithm of `x`.

`sin` Generic function
Summary

Returns the sine of its argument.

Signature

sin x => y

Parameters
Values
Discussion

Returns the sine of its argument. The floating point precision of the result is given by the precision of `x`.

`sincos` Generic function
Summary

Returns both the sine and the cosine of its argument.

Signature

sincos x => (s, c)

Parameters
Values
Discussion

Returns both the sine and the cosine of its argument. The floating point precision of the results is given by the precision of `x`.

`\$single-e` Constant
Summary

The value of e, the base of natural logarithms, as a single precision floating point number.

Type

<single-float>

Superclasses

`<float>`

Discussion

The value of e, the base of natural logarithms, as a single precision floating point number.

`\$single-pi` Constant
Summary

The value of π as a single precision floating point number.

Type

<single-float>

Superclasses

`<float>`

Discussion

The value of π as a single precision floating point number.

`sinh` Generic function
Summary

Returns the hyperbolic sine of its argument.

Signature

sinh x => y

Parameters
Values
Discussion

Returns the hyperbolic sine of its argument. The floating point precision of the result is given by the precision of `x`.

`sqrt` Generic function
Summary

Returns the square root of its argument.

Signature

sqrt x => y

Parameters
Values
Discussion

Returns the square root of x. If x is less than zero an error is signalled. The floating point precision of the result is given by the precision of `x`.

`tan` Generic function
Summary

Returns the tangent of its argument.

Signature

tan x => y

Parameters
Values
Discussion

Returns the tangent of its argument. The floating point precision of the result is given by the precision of `x`.

`tanh` Generic function
Summary

Returns the hyperbolic tangent of its argument.

Signature

tanh x => y

Parameters
Discussion

Returns the hyperbolic tangent of its argument. The floating point precision of the result is given by the precision of `x`.