smallest |cos(x)| ?
|
10-11-2021, 04:22 PM
(This post was last modified: 10-13-2021 12:52 AM by Albert Chan.)
Post: #14
|
|||
|
|||
RE: smallest |cos(x)| ?
(10-11-2021 01:16 PM)Werner Wrote: For the following values of k , (k+0.5)*pi is not the same as k*180+90 ->RAD, and the latter is correct: Assuming we already tried k=0,1,2 (i.e, IP(x) of single digit), difference does not matter. We are now searching for exact(x) *close* to round(x,34). For this, only error of concern is inaccuracy of PI, (rel_err < 0.37 ULP) (Here, ULP ≡ 1E-34) If |cos(x)| is minimized, both ways of calculating x will match. If they are different, it is guaranteed |cos(x)| is not minimized. Example, for IP(x) of 2 digits: c:\> spigot -d3 -C "abs(pi/2*1e32 rem 1)" 0/1 1/6 1/7 15/104 7 2 / PI * → 10.99557428756427633461925184147826 7 90 * ->RAD → 10.99557428756427633461925184147826 COS → -9.469009289781287037341230607307734e-35 --- From Free42 core_helpers.cc, deg_to_rad(x) = x / (180 / PI) 180/pi = 57.29577951308232087679815481410517 0332 ... Rounded to 34 digits, this has relerr ≈ 0.0332 / 0.573 ≈ 0.058 ULP This is much more accurate than stored PI (relerr ≈ 0.369 ULP) If it had used flipped constant: pi/180 = 0.01745329251994329576923690768488612 7134 ... relerr ≈ (1-0.7134) / 0.1745 ≈ 1.64 ULP ... very bad Comment: Here, relerr calculations ignored sign, but sign may be important. I use this convention for sign of error: exact = approx + error PI is over-estimated, relerr(PI) = −0.369 ULP 180/PI under-estimated, relerr(180/PI) = +0.058 ULP But, ->RAD() use division of constant, we subtract relerr instead of add. Or, we can think of multiply by inverse of constant, with relerr of −0.058 ULP Since both formula have relerr of same sign, ->RAD() always better. |
|||
« 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: 3 Guest(s)