Post Reply 
You've Got Mail.........DM42L
02-24-2016, 08:17 AM
Post: #30
RE: You've Got Mail.........DM42L
(02-23-2016 12:07 PM)Paul Dale Wrote:  Just committed the range reduction code for the 34S. I kept the 34S's higher precision computation of the trigonometric functions since it supports double precision, although I'm not sure this is actually necessary. Now I can do the two examples with correct rounding. Unless I've made an error converting the code, the 34S should be good for trig now Smile

None of this 1ULP off rubbish Big Grin


Now it is time for bed for me....

Pauli

Thanks!
One more little tidbit, though:
TAN(a) = -TAN(-a)
but not for a=1e-4 ...
Here a similar range reduction needs to happen (also in Free42 this time).

Something like this: (unverified)

Code:
real function TANDEG(real x)

  boolean fNEG := FALSE;

  if x<0
  then do
    x := -x;
    fNEG := TRUE;
  end;

  x := MOD(x,180);            -- [0 180[

  if x > 90                -- TAN(x+90°) = -TAN(90°-x)
  then do
    x := 180 - x;
    fNEG := toggle(fNEG);
  end;

  if x > 80                -- to improve accuracy for x close to 90°
  then do
    x := 90 - x;
    x := TANRAD(x*PI/180);
    x := 1/x;
  end;
  else do;
    x := TANRAD(x*PI/180);
  end;

  if fNEG then x := -x;

  return x;

end;

- there is no separate test for 45°, as apparently TANRAD(PI/4) = 1, exactly
- the reduction to x<=45° is only done when x>80 so as to not do 1/TAN when it would not be necessary.

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
You've Got Mail.........DM42L - d b - 02-19-2016, 09:38 PM
RE: You've Got Mail.........DM42L - JimP - 02-19-2016, 09:50 PM
RE: You've Got Mail.........DM42L - d b - 02-19-2016, 10:24 PM
RE: You've Got Mail.........DM42L - Werner - 02-20-2016, 12:53 PM
RE: You've Got Mail.........DM42L - Werner - 02-23-2016, 07:02 AM
RE: You've Got Mail.........DM42L - Werner - 02-23-2016, 10:08 AM
RE: You've Got Mail.........DM42L - Werner - 02-23-2016, 10:53 AM
RE: You've Got Mail.........DM42L - Werner - 02-23-2016, 11:47 AM
RE: You've Got Mail.........DM42L - Werner - 02-24-2016 08:17 AM
RE: You've Got Mail.........DM42L - Vtile - 03-21-2016, 02:41 AM
RE: You've Got Mail.........DM42L - JeffJ - 05-12-2016, 06:45 PM
RE: You've Got Mail.........DM42L - JeffJ - 08-25-2016, 05:54 PM
RE: You've Got Mail.........DM42L - vido - 08-26-2016, 06:44 PM
RE: You've Got Mail.........DM42L - tycho - 09-03-2016, 10:02 PM
RE: You've Got Mail.........DM42L - vido - 09-03-2016, 10:20 PM
RE: You've Got Mail.........DM42L - tycho - 09-04-2016, 11:15 AM
RE: You've Got Mail.........DM42L - tycho - 09-05-2016, 01:40 PM
RE: You've Got Mail.........DM42L - Otto55 - 11-05-2016, 10:40 PM
RE: You've Got Mail.........DM42L - Jlouis - 11-20-2016, 02:08 AM



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