Post Reply 
(12C) Bhaskara's Sine and Cosine Approximations
02-26-2022, 06:22 PM (This post was last modified: 02-28-2022 06:29 AM by Thomas Klemm.)
Post: #1
(12C) Bhaskara's Sine and Cosine Approximations
Bhaskara's Sine and Cosine Approximations

References
Formulas

\(\sin(x) \approx \frac{16(\pi - x)x}{5 \pi^2 - 4(\pi - x)x}\)

\(\cos(x) \approx \frac{\pi^2 - 4x^2}{\pi^2 + x^2}\)

We can use the substitution \(\pi \to 180^{\circ}\) and get instead for \(x\) in degrees:

\(\sin(x) \approx \frac{4(30 - \frac{x}{6})\frac{x}{6}}{1125 - (30 - \frac{x}{6})\frac{x}{6}}\)

\(\cos(x) \approx \frac{9 - 4[\frac{x}{60}]^2}{9 + [\frac{x}{60}]^2}\)

Python Programs

Code:
def sin(x):
    u = x / 6
    v = (30 - u) * u
    return 4 * v / (1125 - v)

Code:
def cos(x):
    u = x / 60
    v = u ** 2
    return (9 - 4 * v) / (9 + v)

Program

There's a jump table at the beginning, so you can use the following:

GTO 01 for \(\sin(x)\)
GTO 02 for \(\cos(x)\)

Code:
01-     43 33 19 g GTO 19
02-     36         ENTER
03-     06         6
04-     00         0
05-     10         ÷
06-     36         ENTER
07-     20         ×
08-     09         9
09-     34         x≷y
10-     40         +
11-     09         9
12-     43 36    g LSTx
13-     04         4
14-     20         ×
15-     30         −
16-     34         x≷y
17-     10         ÷
18-     43 33 00 g GTO 00
19-     36         ENTER
20-     06         6
21-     10         ÷
22-     03         3
23-     00         0
24-     34         x≷y
25-     30         −
26-     43 36    g LSTx
27-     20         ×
28-     01         1
29-     01         1
30-     02         2
31-     05         5
32-     34         x≷y
33-     30         −
34-     43 36    g LSTx
35-     04         4
36-     20         ×
37-     34         x≷y
38-     10         ÷
39-     43 33 00 g GTO 00

Examples

Sine

What is \(\sin(36^{\circ})\)?

GTO 01
36
R/S

0.587

Cosine

What is \(\cos(36^{\circ})\)?

GTO 02
36
R/S

0.808

Accuracy

For special values (e.g. 30, 60, 90, …) the approximation is exact.
But in general it's only correct to about 3 places.
In the last column is the correct value.

Sine

  0: 0.000 0.000
 10: 0.175 0.174
 20: 0.343 0.342
 30: 0.500 0.500
 40: 0.642 0.643
 50: 0.765 0.766
 60: 0.865 0.866
 70: 0.939 0.940
 80: 0.985 0.985
 90: 1.000 1.000
100: 0.985 0.985
110: 0.939 0.940
120: 0.865 0.866
130: 0.765 0.766
140: 0.642 0.643
150: 0.500 0.500
160: 0.343 0.342
170: 0.175 0.174
180: 0.000 0.000


Cosine

-90: 0.000 0.000
-80: 0.175 0.174
-70: 0.343 0.342
-60: 0.500 0.500
-50: 0.642 0.643
-40: 0.765 0.766
-30: 0.865 0.866
-20: 0.939 0.940
-10: 0.985 0.985
  0: 1.000 1.000
 10: 0.985 0.985
 20: 0.939 0.940
 30: 0.865 0.866
 40: 0.765 0.766
 50: 0.642 0.643
 60: 0.500 0.500
 70: 0.343 0.342
 80: 0.175 0.174
 90: 0.000 0.000


Attached File(s)
.zip  bashkara-12c.zip (Size: 450 bytes / Downloads: 6)
Find all posts by this user
Quote this message in a reply
07-29-2022, 12:13 PM
Post: #2
RE: (12C) Bhaskara's Sine and Cosine Approximations
Inverse Sine and Cosine Approximations

Inverse Cosine Function

The approximation for \(\cos(x)\) allows to find an approximation for \(\cos^{-1}(x)\) as well:

\(\cos^{-1}(x) \approx 180 \sqrt{\frac{1 - x}{4 + x}}\)

Program

Code:
01-     01         1
02-     34         x≷y
03-     30         −
04-     43 36    g LSTx
05-     04         4
06-     40         +
07-     10         ÷
08-     43 21    g √x
09-     01         1
10-     08         8
11-     00         0
12-     20         ×
13-     43 33 00 g GTO 00

Examples

In parentheses you can find the correct value.

0
R/S
90.000

0.5
R/S
60.000

1
R/S
0.000

0.5 √x
R/S
44.900 (45)

0.75 √x
R/S
29.867 (30)

5 √x 1 + 4 ÷
R/S
35.871 (36)

Accuracy

For special values (e.g. 0, 0.5, 1) the approximation is exact.
But in general the relative error is within a few ‰.

Inverse Sine Function

To calculate \(\sin^{-1}(x)\) we can simply use:

\(\sin^{-1}(x)=90-\cos^{-1}(x)\)
Find all posts by this user
Quote this message in a reply
07-29-2022, 05:13 PM
Post: #3
RE: (12C) Bhaskara's Sine and Cosine Approximations
(07-29-2022 12:13 PM)Thomas Klemm Wrote:  The approximation for \(\cos(x)\) allows to find an approximation for \(\cos^{-1}(x)\) as well:

\(\cos^{-1}(x) \approx 180 \sqrt{\frac{1 - x}{4 + x}}\)

To calculate \(\sin^{-1}(x)\) we can simply use:

\(\sin^{-1}(x)=90-\cos^{-1}(x)\)

We don't have estimate formula for asin(x), because sin(x) were defined from estimated cos(x)
In other words, OP sin estimate formula is not needed; it is same as cos(90° - x°)

---

We can define angle unit, ht = half-turn, to aid in memorization.
With 1 ht = pi radian = 180 degree, we have:

cos(x ht) ≈ (1-4x²) / (1+x²)
acos(x) ≈ √( (1-x) / (4+x) ) ht

Example:

cos(45°) ≈ cos(1/4 ht) = (1-4/16) / (1+1/16) = 12/17 ≈ 0.7059
acos(0.7059) ≈ √(0.2941 / 4.7059) ht ≈ 0.2500 ht = 45.00°
Find all posts by this user
Quote this message in a reply
07-30-2022, 10:51 AM
Post: #4
RE: (12C) Bhaskara's Sine and Cosine Approximations
(07-29-2022 05:13 PM)Albert Chan Wrote:  We don't have estimate formula for asin(x), because sin(x) were defined from estimated cos(x)
In other words, OP sin estimate formula is not needed; it is same as cos(90° - x°)

Agreed. Instead we can use:
Code:
01-     43 33 07 g GTO 07
02-     36         ENTER
03-     09         9
04-     00         0
05-     34         x≷y
06-     30         −
07-     06         6
08-     00         0
09-     10         ÷
10-     36         ENTER
11-     20         ×
12-     09         9
13-     34         x≷y
14-     40         +
15-     09         9
16-     43 36    g LSTx
17-     04         4
18-     20         ×
19-     30         −
20-     34         x≷y
21-     10         ÷
22-     43 33 00 g GTO 00

However the jump table is now switched:

GTO 01 for \(\cos(x)\)
GTO 02 for \(\sin(x)\)

Quote:cos(45°) ≈ cos(1/4 ht) = (1-4/16) / (1+1/16) = 12/17 ≈ 0.7059

IIRC I used 9 and 60 instead of 1 and 180 to save one precious step.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)