335 lines
53 KiB
Plaintext
335 lines
53 KiB
Plaintext
Copyright (c) 1986 Xerox Corporation. All rights reserved.
|
||
|
||
2
|
||
|
||
7.5 Other Arithmetic Functions
|
||
1
|
||
|
||
(EXPT A N) [Function]
|
||
1
|
||
|
||
Returns A^N. If A is an integer and N is a positive integer, returns an integer, e.g, (EXPT 3 4) => 81, otherwise returns a floating point number. If A is negative and N fractional, an error is generated, ILLEGAL EXPONENTIATION. If N is floating and either too large or too small, an error is generated, VALUE OUT OF RANGE EXPT.
|
||
1
|
||
|
||
(SQRT N) [Function]
|
||
1
|
||
|
||
Returns the square root of N as a floating point number. N may be fixed or floating point. Generates an error if N is negative.
|
||
1
|
||
|
||
(LOG X) [Function]
|
||
1
|
||
|
||
Returns the natural logarithm of X as a floating point number. X can be integer or floating point.
|
||
1
|
||
|
||
(ANTILOG X) [Function]
|
||
1
|
||
|
||
Returns the floating point number whose logarithm is X. X can be integer or floating point. Example:
|
||
(ANTILOG 1) = e => 2.71828...
|
||
1
|
||
|
||
(SIN X RADIANSFLG) [Function]
|
||
1
|
||
|
||
Returns the sine of X as a floating point number. X is in degrees unless RADIANSFLG=T.
|
||
1
|
||
|
||
(COS X RADIANSFLG) [Function]
|
||
1
|
||
|
||
Similar to SIN.
|
||
1
|
||
|
||
(TAN X RADIANSFLG) [Function]
|
||
1
|
||
|
||
Similar to SIN.
|
||
1
|
||
|
||
(ARCSIN X RADIANSFLG) [Function]
|
||
1
|
||
|
||
X is a number between -1 and 1 (or an error is generated). The value of ARCSIN is a floating point number, and is in degrees unless RADIANSFLG=T. In other words, if (ARCSIN X RADIANSFLG)=Z then (SIN Z RADIANSFLG)=X. The range of the value of ARCSIN is -90 to +90 for degrees, -~PI~/2 to ~PI~/2 for radians.
|
||
1
|
||
|
||
(ARCCOS X RADIANSFLG) [Function]
|
||
1
|
||
|
||
Similar to ARCSIN. Range is 0 to 180, 0 to ~PI~.
|
||
1
|
||
|
||
(ARCTAN X RADIANSFLG) [Function]
|
||
1
|
||
|
||
Similar to ARCSIN. Range is 0 to 180, 0 to ~PI~.
|
||
1
|
||
|
||
(ARCTAN2 Y X RADIANSFLG) [Function]
|
||
1
|
||
|
||
Computes (ARCTAN (FQUOTIENT Y X) RADIANSFLG), and returns a corresponding value in the range -180 to 180 (or -~PI~ to ~PI~), i.e. the result is in the proper quadrant as determined by the signs of X and Y.
|
||
1
|
||
|
||
(RAND LOWER UPPER) [Function]
|
||
1
|
||
|
||
Returns a pseudo-random number between LOWER and UPPER inclusive, i.e., RAND can be used to generate a sequence of random numbers. If both limits are integers, the value of RAND is an integer, otherwise it is a floating point number. The algorithm is completely deterministic, i.e., given the same initial state, RAND produces the same sequence of values. The internal state of RAND is initialized using the function RANDSET described below.
|
||
1
|
||
|
||
(RANDSET X) [Function]
|
||
1
|
||
|
||
Returns the internal state of RAND. If X=NIL, just returns the current state. If X=T, RAND is initialized using the clocks, and RANDSET returns the new state. Otherwise, X is interpreted as a previous internal state, i.e., a value of RANDSET, and is used to reset RAND. For example,
|
||
_ (SETQ OLDSTATE (RANDSET))
|
||
...
|
||
_ (for X from 1 to 10 do (PRIN1 (RAND 1 10)))
|
||
2847592748NIL
|
||
_ (RANDSET OLDSTATE)
|
||
...
|
||
_ (for X from 1 to 10 do (PRIN1 (RAND 1 10)))
|
||
2847592748NIL
|
||
1
|
||
|
||
|