Post Reply 
smallest |cos(x)| ?
10-11-2021, 01:16 PM
Post: #13
RE: smallest |cos(x)| ?
(10-08-2021 07:54 PM)Albert Chan Wrote:  
(10-08-2021 02:16 PM)Werner Wrote:  instead of doing (k+0.5)*pi, which has 2 rounding errors (one for pi, one for *), do:
->RAD(180*k + 90), which has only one ...

"Bad" PI does not matter. (Besides, ->RAD might use the same PI)
Consider 34th digit of stored PI = 3, but should be 2.884...

x = (k+0.5)*PI
rel_error(x) = rel_error(PI) ≈ (0.116 ULP) / (PI*10^33 ULP) ≈ 3.686E-35

If x has |cos(x)| minimized, x scaled to 34 digits, is very close to integer.
Say, combined relative error = 3.7E-35 (as long as error < 5E-35, we are safe)

ulp_error(x) < 10^34 ULP * 3.7E-35 = 0.37 ULP

If we assume multiply has correct rounding, 0.37 ULP will have removed.
Searching for min(|cos(x)|, my OP eps() code can be replaced with plain cos(x) Smile

Somehow, this is not true.. the division by 2 (or mult. by 0.5 ..) may introduce an error of one ULP, due to unbiased rounding, as is the case for k=0.
For the following values of k , (k+0.5)*pi is not the same as k*180+90 ->RAD, and the latter is correct:
k=0, 2, 8, 15, 18, 25, ..
consequently, (k+0.5)*pi does not yield the lowest |cos(x)|, but the ->RAD version does.

Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
Post Reply 


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)