blob: a4a7e67cae5f17a4188e4641026e25b0d6bb3e4b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package math
import math "math"
/*
* asin(arg) and acos(arg) return the arcsin, arccos,
* respectively of their arguments.
*
* Arctan is called after appropriate range reduction.
*/
const
(
pio2 = .15707963267948966192313216e1
)
export func
asin(arg float64)float64
{
var temp, x float64;
var sign bool;
sign = false;
x = arg;
if x < 0 {
x = -x;
sign = true;
}
if arg > 1 {
return sys.NaN();
}
temp = sqrt(1 - x*x);
if x > 0.7 {
temp = pio2 - atan(temp/x);
} else {
temp = atan(x/temp);
}
if sign {
temp = -temp;
}
return temp;
}
export func
acos(arg float64)float64
{
if(arg > 1 || arg < -1) {
return sys.NaN();
}
return pio2 - asin(arg);
}
|