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