blob: d39339ea1c560229ffbea2456ce158db57621dc8 (
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
|
// 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"
/*
* asin(arg) and acos(arg) return the arcsin, arccos,
* respectively of their arguments.
*
* Arctan is called after appropriate range reduction.
*/
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 = Pi/2 - Atan(temp/x);
} else {
temp = Atan(x/temp);
}
if sign {
temp = -temp;
}
return temp;
}
func Acos(arg float64) float64 {
if arg > 1 || arg < -1 {
return sys.NaN();
}
return Pi/2 - Asin(arg);
}
|