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

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

수학에서 sin 함수의 역함수는 arcsin 으로 표기되는데,

Go 언어에서는 math.Asin() 함수로 구현되어 있다.

/*
 * Filename: testArcSine.go
 *
 * Execute: go run testArcSine.go
 *
 *  Or
 *
 * Compile: go build testArcSine.go
 * Execute: testArcSine
 *
 * Date: 2013. 1. 1.
 * Copyright (c) pkim _AT_ scripts.pe.kr
 */
 
package main

import (
    "fmt"
    "math"
)

func asinh(x float64) float64 {
    y := math.Log(x + math.Sqrt(x*x + 1))
    return y
}

func acosh(x float64) float64 {
    y := math.Log(x + math.Sqrt(x*x - 1))
    return y
}

func main() {
 
    x := -0.9
    y := math.Asin(x)
    fmt.Printf("y = asin(%g) = %.9f\n", x, y)
    fmt.Printf("sin(y) = sin(%.9f) = %g\n", y, math.Sin(y))
    fmt.Printf("\n")

    x = 1.1
    u := acosh(x)
    fmt.Printf("u = acosh(%g) = %.10f\n", x, u)
 
    v := asinh(x)
    fmt.Printf("v = asinh(%g) = %.10f\n", x, v)
 
    fmt.Printf("cosh(u) = cosh(%.10f) = %g\n", u, math.Cosh(u))
    fmt.Printf("sinh(v) = sinh(%.10f) = %g\n", v, math.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
*/

 

 

 

Posted by Scripter
,