Task

If your language has a library or built-in functions for trigonometry, show examples of:

   sine
   cosine
   tangent
   inverses   (of the above)

using the same angle in radians and degrees.

For the non-inverse functions,   each radian/degree pair should use arguments that evaluate to the same angle   (that is, it's not necessary to use the same angle for all three regular functions as long as the two sine calls use the same angle).

For the inverse functions,   use the same number and convert its answer to radians and degrees.

If your language does not have trigonometric functions available or only has some available,   write functions to calculate the functions based on any   known approximation or identity.




rxm.cls                                                    20 March 2014

The distribution of ooRexx contains a function package called rxMath
that provides the computation of trigonometric and some other functions.
Based on the underlying C-library the precision of the returned values
is limited to 16 digits. Close observation show that sometimes the last
one to three digits of the returned values are not correct.
Many years ago I experimented with implementing these functions in Rexx
with its virtually unlimited precision.
The rxm class is intended to provide the same functionality as rxMath
with no limit on the specified or implied precision.

Functions in class rxm and invocation syntax are the same as
in the rxMath library. They are implemented as routines which
perform the checking of argument values and invoke the corresponding
methods. Here is a list of the supported functions and a concise
syntax specification.

The arguments are represented by these letters:

x is the value for which the respective function must be evaluated.
b and c for RxCalcPower are base and exponent, respectively.

p if specified is the desired precision (number of digits) in the result.
  It can be any integer from 1 to 999999.
  See below for the default used.

u if specified, is the unit of x given to the trigonometric functions
  or the unit of the value returned by the Arcus functions.
  It can be 'R', 'D', or 'G' for radians, degrees, or grades, respectively.
  See below for the default used.

Trigonometric functions:

• rxmCos(x[,[p][,u]])
• rxmCotan(x[,[p][,u]])
• rxmSin(x[,[p][,u]])
• rxmTan(x[,[p][,u]])

Arcus functions:

• rxmArcCos(x[,[p][,u]])
• rxmArcSin(x[,[p][,u]])
• rxmArcTan(x[,[p][,u]])

Hyperbolic functions:

• rxmCosH(x[,p])
• rxmSinH(x[,p])
• rxmTanH(x[,p])

• rxmExp(x[,p])      e**x
• rxmLog(x[,p])      Natural logarithm of x
• rxmLog10(x[,p])    Brigg's logarithm of x
• rxmSqrt(x[,p])     Square root of x

• rxmPower(b,c[,p])  b**c

• rxmPi([p])         pi to the specified or default precision

Values used for p and u if these are omitted in the invocation
==============================================================

The directive ::REQUIRES rxm.cls creates an instance of the class
  .local~my.rxm=.rxm~new(16,"D")
which sets the defaults for p=16 and u='D'.
These are used when p or u are omitted in a function invocation.
They can be changed by changing the respective class attributes as follows:
  .locaL~my.rxm~precision=50
  .locaL~my.rxm~type='R'
The current setting of these attributes can be retrieved as follows:
  .locaL~my.rxm~precision()
  .locaL~my.rxm~type()

While I tried to get full compatibility there remain a few
(actually very few) differences:

  rxCalcTan(90) raises the Syntax condition (will be fixed in the next ooRexx release)
  rxCalcexp(x) limits x to 709. or so and returns '+infinity' for larger exponents
