F# 언어로 역삼각함수, 역쌍곡선함수 값을 구하는 예제
역삼각함수란 삼각함수의 역함수를 의미하고,
역쌍곡선함수란 쌍곡선함수의 역함수를 의미한다.
수학에서 sin 함수의 역함수는 arcsin 으로 표기되는데,
F# 언어에서는 .NET 의 System.Math.Asin(double) 함수를 사용한다.
* Filename: testArcSine.fs
*
* Compile: fsc testArcSine.fs
* Execute: testArcSine
*
* Date: 2013. 1. 2.
* Copyright (c) pkim _AT_ scripts.pe.kr
*)
#light
let sin(x: double) : double =
System.Math.Sin(x)
let asin(x: double) : double =
System.Math.Asin(x)
let sinh(x: double) : double =
System.Math.Sinh(x)
let cosh(x: double) : double =
System.Math.Cosh(x)
let asinh(x: double) : double =
System.Math.Log(x + sqrt(x*x + 1.0))
let acosh(x: double) : double =
System.Math.Log(x + sqrt(x*x - 1.0))
let mutable x = -0.9
let mutable y = asin(x)
printfn "y = asin(%.1g) = %.9f" x y
printfn "sin(y) = sin(%.9f) = %.1g" y (sin y)
printfn ""
x <- 1.1
let mutable u = acosh(x)
printfn "u = acosh(%3.2g) = %.10f" x u
let mutable v = asinh(x)
printfn "v = asinh(%3.2g) = %.10f" x v
printfn "cosh(u) = cosh(%.10f) = %3.2g" u (cosh u)
printfn "sinh(v) = sinh(%.10f) = %3.2g" v (sinh v)
(*
Output:
y = asin(-0.9) = -1.119769515
sin(y) = sin(-1.119769515) = -0.9
u = acosh(1.1) = 0.4435682544
v = asinh(1.1) = 0.9503469298
cosh(u) = cosh(0.4435682544) = 1.1
sinh(v) = sinh(0.9503469298) = 1.1
*)