Post Reply 
HP-35 style trig functions
01-14-2019, 08:57 AM (This post was last modified: 01-15-2019 07:17 AM by Thomas Klemm.)
Post: #8
RE: HP-35 style trig functions
(01-14-2019 02:34 AM)Druzyek Wrote:  I'm starting to think it is not possible

Since you have plenty of space for lookup-tables you could pre-compute COS and SIN:
Code:
from math import radians, sin, cos

COS = [ [ cos(radians(10**i * j)) for j in range(10)] for i in range(1, -18, -1)]
SIN = [ [ sin(radians(10**i * j)) for j in range(10)] for i in range(1, -18, -1)]

arg = radians(17.188733853924695)
digits = [1, 7, 1, 8, 8, 7, 3, 3, 8, 5, 3, 9, 2, 4, 6, 9, 5]

x, y = 1.0, 0.0
for i, j in enumerate(digits):
    u, v = COS[i][j], SIN[i][j]
    x, y = x * u - y * v, x * v + y * u

print(x, y)
print(cos(arg), sin(arg))

This results in:
Code:
# 0.9553364891256062 0.2955202066613395
# 0.955336489125606 0.29552020666133955

However now 4 multiplications are needed for each digit.
Here you can use degrees for the angle.
But of course you could use radians instead.

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP-35 style trig functions - Druzyek - 01-13-2019, 08:32 PM
RE: HP-35 style trig functions - pier4r - 01-13-2019, 08:37 PM
RE: HP-35 style trig functions - Druzyek - 01-14-2019, 12:56 AM
RE: HP-35 style trig functions - Dan - 01-14-2019, 01:31 AM
RE: HP-35 style trig functions - Druzyek - 01-14-2019, 02:34 AM
RE: HP-35 style trig functions - Dan - 01-15-2019, 03:43 AM
RE: HP-35 style trig functions - Thomas Klemm - 01-14-2019 08:57 AM
RE: HP-35 style trig functions - Druzyek - 01-15-2019, 11:49 PM
RE: HP-35 style trig functions - Druzyek - 08-28-2023, 12:19 AM



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