Source file
src/math/asin.go
1
2
3
4
5 package math
6
7
13
14
15
16
17
18
19 func Asin(x float64) float64 {
20 if haveArchAsin {
21 return archAsin(x)
22 }
23 return asin(x)
24 }
25
26 func asin(x float64) float64 {
27 if x == 0 {
28 return x
29 }
30 sign := false
31 if x < 0 {
32 x = -x
33 sign = true
34 }
35 if x > 1 {
36 return NaN()
37 }
38
39 temp := Sqrt(1 - x*x)
40 if x > 0.7 {
41 temp = Pi/2 - satan(temp/x)
42 } else {
43 temp = satan(x / temp)
44 }
45
46 if sign {
47 temp = -temp
48 }
49 return temp
50 }
51
52
53
54
55
56 func Acos(x float64) float64 {
57 if haveArchAcos {
58 return archAcos(x)
59 }
60 return acos(x)
61 }
62
63 func acos(x float64) float64 {
64 return Pi/2 - Asin(x)
65 }
66
View as plain text