역삼각함수란 삼각함수의 역함수를 의미하고,

역쌍곡선함수란 쌍곡선함수의 역함수를 의미한다.

수학에서 sin 함수의 역함수는 arcsin 으로 표기되는데, Common Lisp 언어에서는 asin 함수로 이미 구현되어 있다. 마찬가지로 쌍곡선 함수 sihh cosh 들의 역함수들도 각각 asinh, acosh 라는  이름으로 이미 구현되어 있다.

 

#!~/usr/bin/env clisp

;; Filename: testArcSine.lsp
;;
;; Execute: clisp testArcSine.lsp
;;  Or
;; Execute: ./testArcSine.lsp
;;
;; Date: 2013. 9. 12.

#|
def asinh(x):
            y = math.log(x + math.sqrt(x*x + 1))
            return y

def acosh(x):
            y = math.log(x + math.sqrt(x*x - 1))
            return y
|#


(format t "Using the type of float, ~%")
(setf x -0.9)
(setf y (asin x))
(format t "  y = asin(~,1f) = ~,9f~%" x y)
(format t "  sin(y) = sin(~,9f) = ~,1f~%" y (sin y))
           
(setf x 1.1)
(setf u (acosh x))
(setf v (asinh x))
(format t "  u = acosh(~,1f) = ~,9f~%" x u)
(format t "  v = asinh(~,1f) = ~,9f~%" x v)
(format t "  cosh(u) = cosh(~,9f) = ~,1f~%" u (cosh u))
(format t "  sinh(u) = sinh(~,9f) = ~,1f~%" v (sinh v))
(format t "~%")

(format t "Using the type of short-float, ~%")
(setf x -0.9S0)
(setf y (asin x))
(format t "  y = asin(~f) = ~f~%" x y)
(format t "  sin(y) = sin(~f) = ~f~%" y (sin y))
           
(setf x 1.1S0)
(setf u (acosh x))
(setf v (asinh x))
(format t "  u = acosh(~f) = ~f~%" x u)
(format t "  v = asinh(~f) = ~f~%" x v)
(format t "  cosh(u) = cosh(~f) = ~f~%" u (cosh u))
(format t "  sinh(u) = sinh(~f) = ~f~%" v (sinh v))
(format t "~%")
           
(format t "Using the type of double-float, ~%")
(setf x -0.9D0)
(setf y (asin x))
(format t "  y = asin(~f) = ~f~%" x y)
(format t "  sin(y) = sin(~f) = ~f~%" y (sin y))
           
(setf x 1.1D0)
(setf u (acosh x))
(setf v (asinh x))
(format t "  u = acosh(~f) = ~f~%" x u)
(format t "  v = asinh(~f) = ~f~%" x v)
(format t "  cosh(u) = cosh(~f) = ~f~%" u (cosh u))
(format t "  sinh(u) = sinh(~f) = ~f~%" v (sinh v))
(format t "~%")
           
(format t "Using the type of long-float, ~%")
(setf x -0.9L0)
(setf y (asin x))
(format t "  y = asin(~f) = ~f~%" x y)
(format t "  sin(y) = sin(~f) = ~f~%" y (sin y))
           
(setf x 1.1L0)
(setf u (acosh x))
(setf v (asinh x))
(format t "  u = acosh(~f) = ~f~%" x u)
(format t "  v = asinh(~f) = ~f~%" x v)
(format t "  cosh(u) = cosh(~f) = ~f~%" u (cosh u))
(format t "  sinh(u) = sinh(~f) = ~f~%" v (sinh v))
(format t "~%")
           
#|
Output:
Using the type of float,
  y = asin(-0.9) = -1.119769600
  sin(y) = sin(-1.119769600) = -0.9
  u = acosh(1.1) = 0.443568350
  v = asinh(1.1) = 0.950346950
  cosh(u) = cosh(0.443568350) = 1.1
  sinh(u) = sinh(0.950346950) = 1.1

Using the type of short-float,
  y = asin(-0.9) = -1.11978
  sin(y) = sin(-1.11978) = -0.9
  u = acosh(1.1) = 0.443573
  v = asinh(1.1) = 0.95035
  cosh(u) = cosh(0.443573) = 1.1
  sinh(u) = sinh(0.95035) = 1.1

Using the type of double-float,
  y = asin(-0.9) = -1.1197695149986342
  sin(y) = sin(-1.1197695149986342) = -0.9
  u = acosh(1.1) = 0.4435682543851155
  v = asinh(1.1) = 0.9503469298211343
  cosh(u) = cosh(0.4435682543851155) = 1.1
  sinh(u) = sinh(0.9503469298211343) = 1.1

Using the type of long-float,
  y = asin(-0.9) = -1.1197695149986341867
  sin(y) = sin(-1.1197695149986341867) = -0.90000000000000000003
  u = acosh(1.1) = 0.44356825438511518925
  v = asinh(1.1) = 0.95034692982113425026
  cosh(u) = cosh(0.44356825438511518925) = 1.1
  sinh(u) = sinh(0.95034692982113425026) = 1.1
|#

 

 

 

Posted by Scripter
,