sin(x) & cos(x) for x = 10²² in radians
|
10-05-2023, 03:08 PM
Post: #34
|
|||
|
|||
RE: sin(x) & cos(x) for x = 10²² in radians
(10-03-2023 07:56 PM)Ajaja Wrote: In Python operator ^ means XOR. You should use here 10**22 or just 1e22. 10^22 = 0x1.0f0cf064dd592p+73 It is the biggest pow-of-10 that can be exactly store in IEEE double. (10^23 need 54 bits) Perhaps this is the reason for picking it, to compare both decimal and binary machines. (10-05-2023 01:33 PM)dm319 Wrote: Do you think the hp-20s uses a similar look up table? Very likely. Of course, there are ways to do this without table. We don't need pi ... we just keep throwing precisions to it lua> qd = require'qd' -- quad double, precision = 4*53 bits lua> t = 1e22 / qd.pow(5,40) -- about 1e-6 lua> tt = t*t lua> s = t*(1 - tt/6*(1 - tt/20*(1 - tt/42*(1 - tt/72*(1 - tt/110))))) lua> s -- ≈ sin(10^22 / 5^40) 1.0995116277757784620007025274123330676478201219099885281501104800e-06 Now, map 40 times, sin(x) --> sin(5x) lua> m5 = fn'x: x*(5-x*x*(4+16*(1-x)*(1+x)))' lua> for i=1,40 do s = m5(s) end lua> s -- ≈ sin(10^22) -8.5220084976718880177270589375302936826176863529279677310847219854e-01 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)