Nyquist / XLISP 2.0  -  Contents | Tutorials | Examples | Reference

asin


Type:   -   Lisp function (closure)
Source:   -  

Syntax

(asin expr)
expr - floating point number/expression
returns - the arcsine of the number

Note: The 'asin' function is not imlemented in Nyquist. Here is a Lisp implementation of 'asin', using the atan function:

(defun asin (x)
  (cond ((not (numberp x)) (error "bad argument type" x))
        ((= x 1) (/ pi 2.0))
        ((= x -1) (/ pi -2.0))
        ((< -1 x 1) (atan (/ x (sqrt (1+ (* x (- x)))))))
        (t (error "argument out of range" x))))

Description

The 'asin' function returns the arc sine of a floating point expression. The result is a floating point number in radians. If the argument is less than -1 or greater than +1, the arc sine is a complex number. Complex numbers are not available in XLISP. In this case the 'asin' function signals an 'argument out of range' error.

Examples

(asin 0.0)   => 0.0
(asin 1.0)   => 1.5708
(asin -1.0)  => -1.5708
(asin 0)     => error: bad integer operation

See also:

  Back to Top


Nyquist / XLISP 2.0  -  Contents | Tutorials | Examples | Reference