The math extensions provide mathematical functions such as trigonometry, logarithms, rounding and related utilities. These extensions may or may not be present depending on the platform and configuration of LispBM.
Computes the sine of a given angle (in radians). The form of a sin expression is (sin expr).
| Example | Result |
|
|
|
|
|
|
Computes the cosine of a given angle (in radians). The form of a cos expression is (cos expr).
| Example | Result |
|
|
|
|
|
|
Computes the tangent of a given angle (in radians). The form of a tan expression is (tan expr).
| Example | Result |
|
|
|
|
|
|
Computes the arcsine of a value, returning an angle in radians. The form of an asin expression is (asin expr). The argument should be in the range [-1, 1].
| Example | Result |
|
|
|
|
|
|
Computes the arccosine of a value, returning an angle in radians. The form of an acos expression is (acos expr). The argument should be in the range [-1, 1].
| Example | Result |
|
|
|
|
|
|
Computes the arctangent of a value, returning an angle in radians. The form of an atan expression is (atan expr).
| Example | Result |
|
|
|
|
|
|
Computes the arctangent of y/x, using the signs of both arguments to determine the correct quadrant. Returns an angle in radians in the range [-pi, pi]. The form of an atan2 expression is (atan2 y x).
| Example | Result |
|
|
|
|
|
|
Raises a base to a given exponent. The form of a pow expression is (pow base exponent).
| Example | Result |
|
|
|
|
|
|
Computes the exponential function e raised to the power of the argument. The form of an exp expression is (exp expr).
| Example | Result |
|
|
|
|
|
|
Computes the square root of a number. The form of a sqrt expression is (sqrt expr).
| Example | Result |
|
|
|
|
|
|
Computes the natural logarithm (base e) of a number. The form of a log expression is (log expr).
| Example | Result |
|
|
|
|
|
|
Computes the base-10 logarithm of a number. The form of a log10 expression is (log10 expr).
| Example | Result |
|
|
|
|
|
|
Rounds a number down to the nearest integer, returning a float. The form of a floor expression is (floor expr).
| Example | Result |
|
|
|
|
|
|
Rounds a number up to the nearest integer, returning a float. The form of a ceil expression is (ceil expr).
| Example | Result |
|
|
|
|
|
|
Rounds a number to the nearest integer, returning a float. Halfway cases are rounded away from zero. The form of a round expression is (round expr).
| Example | Result |
|
|
|
|
|
|
Converts degrees to radians. When called with a single argument the form is (deg2rad expr). When called with multiple arguments, each is converted and the results are returned as a list.
| Example | Result |
|
|
|
|
|
|
Converts radians to degrees. When called with a single argument the form is (rad2deg expr). When called with multiple arguments, each is converted and the results are returned as a list.
| Example | Result |
|
|
|
|
|
|
is-nan checks whether a floating-point value is NaN (not a number). Returns t if the value is NaN and nil otherwise. The form of an is-nan expression is (is-nan expr). Only float and double values can be NaN; any other number type returns nil. NaN can arise from operations such as (sqrt -1.0) or (asin 2.0). Note that division by zero is an error in LispBM and does not produce NaN.
| Example | Result |
|
|
|
|
|
|
is-inf checks whether a floating-point value is infinite. Returns t if the value is positive or negative infinity, nil otherwise. The form of an is-inf expression is (is-inf expr). Only float and double values can be infinite; any other number type returns nil. Infinity can arise from operations such as (exp 1000.0) or (log 0.0). Note that division by zero is an error in LispBM and does not produce infinity.
| Example | Result |
|
|
|
|
|
|
This document was generated by LispBM version 0.36.0