smallest |cos(x)| ?
|
10-07-2021, 06:40 PM
(This post was last modified: 10-07-2021 10:10 PM by Albert Chan.)
Post: #3
|
|||
|
|||
RE: smallest |cos(x)| ?
Thanks, Werner !
I found another approach. Instead of search min(|cos(x)|), I search min(|x - round(x,34)|), where x = (2k+1)*pi/2 = (k+0.5)*pi Searching k all the way to 100 million, we found a winner: x = 82,425,623.5 pi This required arbitrary precision package, with more digits of pi We use 100 digits of pi, search 1 million of k at a time. The code is a 1 liner eps.bat Wrote:@gawk "BEGIN{n=1e6; while(n--) print}" | rpn =100 pi sp %1 1e6x .5+ x s d =34 - abs [ rp r + s d = - abs $s k1 rpn is a sample program, for MAPM. (+ - * are exact, rounding must be called explicitly) It is not programmable, thus the need for gawk to produce 1 million blank lines. =100 pi sp # p = 100-digits-of-pi %1 1e6x .5+ x s # start = (%1*1e6 + 0.5) * p d =34 - abs # eps1 = abs(start - round(start,34)) [ # start a pipe, for each line of input, perform below commands rp r + s # start += p d = - abs # eps2 = abs(start - round(start,34)) $s k1 # sort (eps1, eps2) in ascending order, then drop the big one c:\> eps 0 8.200102230416340029960966876550294E-35 c:\> eps 82 1.532138639232766081410107492878833E-35 Then, locate x within the million k, and confirm: c:\> rpn =100 pi 953.5x ?68 d =-34 ? 2995.5085951978678528741304659570060000820010223041634002996096687655 2995.508595197867852874130465957006 - abs ?34 8.200102230416340029960966876550294E-35 pi 82425623.5x ?68 d =-34 ? 2.5894773325515822091636756232496249999999998467861360767233918589893E+8 2.589477332551582209163675623249625E+8 - abs ?34 1.532138639232766081410107492878833E-35 |cos(x)| = sin(ε) = ε - ε^3/3! + ... ≈ ε Free42 Decimal: 2995.508595197867852874130465957006 COS → -8.200102230416340029960966876550293e-35 258947733.2551582209163675623249625 COS → 1.532138639232766081410107492878833e-35 Intel Decimal128 angle reduction code is very good |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
smallest |cos(x)| ? - Albert Chan - 10-07-2021, 12:14 PM
RE: smallest |cos(x)| ? - Werner - 10-07-2021, 03:40 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-07-2021 06:40 PM
RE: smallest |cos(x)| ? - Werner - 10-08-2021, 07:02 AM
RE: smallest |cos(x)| ? - Albert Chan - 10-08-2021, 08:17 PM
RE: smallest |cos(x)| ? - ijabbott - 10-09-2021, 01:15 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-09-2021, 02:09 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-09-2021, 05:01 PM
RE: smallest |cos(x)| ? - EdS2 - 10-08-2021, 08:24 AM
RE: smallest |cos(x)| ? - Werner - 10-08-2021, 02:16 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-08-2021, 07:54 PM
RE: smallest |cos(x)| ? - Werner - 10-11-2021, 01:16 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-11-2021, 04:22 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-10-2021, 01:36 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-11-2021, 10:05 PM
|
User(s) browsing this thread: 1 Guest(s)