lisp吧 关注:2,680贴子:12,837
  • 0回复贴,共1

lisp补充反三角函数

只看楼主收藏回复

;;反正弦函数(asin 值)
(defun asin(x)
(cond
((or (> x 1) (< x -1)) nil)
((= x 1) (* pi 0.5))
((= x -1) (* pi -0.5))
(t (atan (/ x (sqrt (- 1 (* x x))))))
)
)
;;反余弦函数(acos 值)
(defun acos(x)
(if (>= x 0)
(asin (sqrt (- 1 (* x x))))
(+ pi (- (asin (sqrt (- 1 (* x x))))))
)
)


IP属地:陕西1楼2019-08-13 16:37回复