aboutsummaryrefslogtreecommitdiff
path: root/bc_funcs/trig.bc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bc_funcs/trig.bc66
1 files changed, 33 insertions, 33 deletions
diff --git a/bc_funcs/trig.bc b/bc_funcs/trig.bc
index c127753..9a4fcb3 100644
--- a/bc_funcs/trig.bc
+++ b/bc_funcs/trig.bc
@@ -1,33 +1,33 @@
define sin(x) {
- auto b, s, r, a, q, i
-
- if (x < 0)
- return (-sin(-x))
-
- b = ibase
- ibase = A
- s = scale
- scale = 1.1 * s + 2
- a = atan(1)
- scale = 0
- q = (x / a + 2) / 4
- x -= 4 * q * a
-
- if (q % 2)
- x = -x
-
- scale = s + 2
- r = a = x
- q = -x * x
-
- for (i = 3; a; i += 2) {
- a *= q / (i * (i - 1))
- r += a
- }
-
- scale = s
- ibase = b
- return (r / 1)
+ auto b, s, r, a, q, i
+
+ if (x < 0)
+ return (-sin(-x))
+
+ b = ibase
+ ibase = A
+ s = scale
+ scale = 1.1 * s + 2
+ a = atan(1)
+ scale = 0
+ q = (x / a + 2) / 4
+ x -= 4 * q * a
+
+ if (q % 2)
+ x = -x
+
+ scale = s + 2
+ r = a = x
+ q = -x * x
+
+ for (i = 3; a; i += 2) {
+ a *= q / (i * (i - 1))
+ r += a
+ }
+
+ scale = s
+ ibase = b
+ return (r / 1)
}
define cos(x) {
@@ -53,7 +53,7 @@ define atan(x) {
n = -1
x = -x
}
-
+
if (scale < 65) {
if (x == 1) {
r = .7853981633974483096156608458198757210492923498437764552437361480/n
@@ -74,11 +74,11 @@ define atan(x) {
scale += 5
a = atan(.2)
}
-
+
scale = s + 3
while (x > .2) {
- m++
+ m += 1
x = (x - .2) / (1 + .2 * x)
}
@@ -95,4 +95,4 @@ define atan(x) {
scale = s
ibase = b
return ((m * a + r) / n)
-} \ No newline at end of file
+}