Re: SIND, COSD, TAND functions



glen herrmannsfeldt wrote:
robert.corbett@xxxxxxx wrote:
(snip)

There was a long discussion of this topic on this news group
a while ago. Try evaluating COSD(90.0) and see if you are
happy with the result.

Any chance for SIND, COSD, TAND, and ASIND, ACOSD, and ATAND,
in Fortran 2008?

They should be pretty easy to add.


It's easy to add to the standard. Would it be that easy
to implement? Most hardware these days has in-built
instructions for the trig functions. These are based on
radians. So, getting degree based trig functions to work
well might be problematical. SIND(30.0) should be
exactly one-half (0.5). Can you even be sure that there's
a float value whose SIN (radian based) is exactly one-half?
For some floating-point represenations there migh not be.
Similarly for TAND(45.0): it should be exactly one,
but is there an angle in radians that is both representable
in your float and whose TAN (radians based) rounds
to one?

To be sure, such issues as COSD(90.0) can be resolved
by careful argument reduction *before* converting to
radians: COSD(X) == SIND(X-90.0), so COSD(90.0)
is the same as SIND(0.0), which in turn is the same as
SIN(0.0) (radians-based). But the more such work you
do, the less efficient the degree-based function relative to
their radian-based counterparts.

Dependong on how trig functions are actually implemented
in you hardware there may be other options. And, it's not
harder for hardware implementors to design degree-based
instructions, it's just that few have. Can the Fortran language
standard assume that such things will be done? Or, are you
willing to naively convert to radians and get inexact results?
The "implementation dependend approximation" language
of the standard allows all kind of crimes against precision.
Is that what you want?

--
J. Giles

"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare


.



Relevant Pages

  • Re: Question about "e" exponent
    ... the cartesian coordinates. ... The TI-92 will do trig functions in both radians and degrees. ...
    (comp.dsp)
  • Re: SIN/ASIN Question
    ... I'm currious what everyone would think about an option to switch between degrees ... there's a user option to choose 1904 ... functionality) that a similar setting could be added for trig functions to ... assume arguments in degrees rather than radians. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: SIND, COSD, TAND functions
    ... getting degree based trig functions to work ... No different from doing the conversion youself with Fortran code. ... I tried with COSD in PL/I FOR 90, 30, and 0 degrees. ... but is there an angle in radians that is both representable ...
    (comp.lang.fortran)
  • Re: Change radians - degrees setting
    ... All of Excel's trig functions use radians, not degrees, and there ... Microsoft MVP - Excel ... > How do I change setting for trigonomic functions, ...
    (microsoft.public.excel.misc)
  • Re: SIND, COSD, TAND functions
    ... Do it all in software, probably slower than hardware. ... Convert degrees to approximate radians with unknown ... discontinuity problem of what you've numbered. ... no deficiencies and the other way is to make it so complicated ...
    (comp.lang.fortran)