Post Reply 
mini challenge: find the smallest cosine of an integer
10-24-2021, 09:53 PM (This post was last modified: 10-11-2023 05:37 PM by Albert Chan.)
Post: #20
RE: mini challenge: find the smallest cosine of an integer
To complete symmetry, this is min(|cos(x)|) for Free-42 binary, if angle reduction code is correct.

eps.bat Wrote:@spigot -C "2*2^%1/pi mod 2" | awk -vFS="/" -ve="*0x1p%1" "$2>=2^53 {print 1.5708/$2, q1 e; exit} {q1=$2}"

Just a change of constants needed for eps.bat
This take less than 1 minute, x upto 971+53 = 1024 bits integer.

c:\> (for /L %I in (-52,1,971) do @(eps %I)) | gsort -g | head
4.69203e-19 6381956970095103*0x1p797
6.19292e-19 3205513981387887*0x1p-46
6.20075e-19 6411027962775774*0x1p-47
9.38406e-19 6381956970095103*0x1p798
1.23858e-18 3205513981387887*0x1p-45
...

The list is suggestion only, confirmation necessary. First does give minimum |cos(x)|
see Accurate trigonometric functions for large arguments

>>> from gmpy2 import *
>>> x = mul_2exp(6381956970095103,797) # = 0x1.6ac5b262ca1ffp+849
>>> x
mpfr('5.3193726483265414e+255')
>>> cos(x)
mpfr('-4.6871659242546277e-19')
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: mini challenge: find the smallest cosine of an integer - Albert Chan - 10-24-2021 09:53 PM



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