Up | Next | Prev | PrevTail | Tail |
This module provides facilities for the numerical evaluation and algebraic simplification of expressions involving trigonometrical functions with arguments given in degrees rather than in radians. The degree-valued inverse functions are also provided.
This module provides facilities for the numerical evaluation and algebraic simplification of expressions involving trigonometrical functions with arguments given in degrees rather than in radians. The degree-valued inverse functions are also provided.
Any user at all familiar with the normal trig functions in REDUCE should have no
trouble in using the facilities of this module. The names of the degree-based functions are
those of the normal trig functions with the letter d appended, for example sind
, cosd
and tand
denote the sine, cosine and tangent repectively and their corresponding inverse
functions are asind
, acosd
and atand
. The secant, cosecant and cotangent functions
and their inverses are also supported and, indeed, are treated more as first class objects
than their corresponding radian-based functions which are often converted to expressions
involving sine and cosine by some of the standard REDUCE simplifications
rules.
Below I give a brief description of the facilities available together with a few examples
of their use. More examples and the output that they should produce may be
found in the test files trigd-num.tst
and trigd-simp.tst
and their
corresponding log files with extension .rlg
which may be found in the directory
packages/misc
of the REDUCE distribution along with the source code of the
module.
These degree-based functions are probably best regarded as functions defined for real values only, but complex arguments are supported for completeness. The numerical evaluation routines are fairly comprehensive for both real and complex arguments. However, few simplifications occur for trigd functions with complex arguments.
The range of the principal values returned by the inverse functions is consistent with
those of the corresponding radian-valued functions. More precisely, for asind
,
atand
and acscd
the (closure of the) range is \([-90, 90]\) whilst for acosd
, acotd
and asecd
the (closure of the) range is \([0, 180]\). In addition the operator atan2d
is
the degree valued version of the two argument inverse tangent function which
returns an angle in the half-open interval \((-180, 180]\) in the correct quadrant depending
on the signs of its two arguments. For \(x>0\), atan2d(y, x)
returns the same
numerical value as atand(y/x)
. If \(x=0\) then \(\pm 90\) is returned depending on the sign of
\(y\).
It might be thought that the facilities provided in this module could be easily provided by defining suitable rule lists to convert between the radian and degree-based versions of the trig functions. For example:
1: operator sind, asind$ 2: d2r_list := {sind(~x) => sin(x*pi/180), asind(~x) => 180*asin(x)/pi}$ 3: r2d_list := {sin(~x) => sind(180x/pi), asin(~x) => pi*sind(x)/180}$ 4: sind(x+360) where d2r_list$ 5: ws where r2d_list; sind(x) 6: sind(360) where d2r_list; 0
However, this approach seldom works — try it! The result produced by step 4 defeats the current
rule51
used to simplify expressions of the form \(\sin (x+2\pi )\) although it does manage step 6. The rule list
approach is more reliable if differentiation, integration or numerical evaluation of
expressions involving sind
etc. is required. However it is not particularly convenient
even if the rules and operator declarations are stored in a file so that they may be loaded
at will.
This module aims to overcome these deficiences by providing the degree-based trig functions as first class objects of the system just like their radian-based cousins. The aim is to provide facilities for numerical evaluation, symbolic simplification and differentiation totally analgous to those for the the basic trig functions and their inverses. It is hoped that the module will be of value to students and teachers at secondary school level as well as being sufficiently powerful and flexible to be of genuine utility in fields where angles measured in degrees (and arc minutes and seconds) are in common usage. For more advanced situations (involving integration, complex arguments and values etc.), users are urged to use the standard trig functions already provided by the system.
As in other parts of REDUCE, basic simplification of expressions involving the trigd
functions takes place automatically (bracketted terms are multiplied out, like terms are
gathered together, zero terms removed from sums and so on). The system knows and
automatically applies the basic properties of the functions to simplify the input.
For example sind(0)
is replaced by 0 and sind(-X)
by sind(X)
. If the
switch rounded
is off
all arithmetic is exact and transcendental functions
such as sind
are not evaluated numerically even if their arguments are purely
numerical.
The built-in simplification rules are totally analogous to those of the standard trig functions namely:
Replacement of a function application by its value if a simple analytical
value is known. For example cosd(60) => 1/2
and acscd(1) =>
90
. Currently the only argument values where simplification takes place
correspond to angles that are integral multiples of \(15^\circ \).
Use of the odd and even properties of the trig. functions so that for example
sind(-x) => -sind(x)
, cosd(-x) => cosd(x)
and acosd(-x) => 180 - acosd(x)
.
Argument shifts by integral multiples of \(180^\circ \) so that any residual numerical argument lies in the range \(-90^\circ \ldots 90^\circ \). Thus
sind(x+540) => -sind(x), cosd(x+350) => cosd(x-10).
Removal of argument shifts of \(\pm 90^\circ \) so that for example sind(x-90) => -cosd(x)
and cotd(x+90) => -tand(x)
.
Replacement of tand(x)
by sind(x)/cosd(x)
and e.g., secd(x)
by
1/cosd(x)
and the like, but only when the final result is simpler than the
original.
Basic properties relating a function and it inverse so that for example
sind(asind(x)) => x
.
A few basic rules for atan2d
when the signs of its arguments can be determined.
For example atan2d(y, 0)
is replaced by \(\pm 90\) depending on the sign of
\(y\).
Extra rules can be added by the user for example addition formulae, double angle rules and tangent half-angle formulae as and when required as described in chapter 11.
Rules are provided for the symbolic differentiation of all the trig functions and their inverses. These rules are sufficient fot the power series of the trig functions and their inverses to be found using either the TPS or TAYLOR packages in the standard way.
When the switch rounded
is on
and the arguments of the operators evaluate to
numbers, then the floating point value of the expression is calculated to the currently
specified precision
in the normal way. The bigfloat capabilities are the same as for
the standard trig functions.
If these functions are supplied with complex numerical arguments, numerical evaluation
will NOT be performed when the switch rounded
is on
, but the switch complex
is
off
— the input expression will be returned basically unaltered. Similarly inputs such as
asind(2)
or asecd(0.5)
are not evaluated numerically. The values of these
expressions are, of course, complex.
If the switch complex
is also on
, numerical evaluation is performed. For
example:
1: load_package trigd$ 2: on rounded; 3: asecd(2); 60.0 4: asecd(0.5); asecd(0.5) 5: on complex; *** Domain mode rounded changed to complex-rounded 6: asecd(0.5); 75.4561292902*i
The function atan2d
(like atan2
) is only defined if BOTH its arguments are real. If
they are also numerical, it will be evaluated whenever rounded
is on
. Attempting to
evaluate it with complex numerical arguments will cause either the unaltered expression
to be returned or an error to be raised when the switch complex
is off
or on
respectively.
Note the sine of an angle specified in degrees, minutes and seconds cannot be calculated
by calling sind
directly with a dms list (i.e. as a list of length 3). Instead one must first
convert the dms values to degrees using a call to dms2deg
and then call sind
on the
result. Applied directly to a list (of any length) any trigd
function wil be applied to
each member of the list separately just like most other REDUCE operators. Here is an
example illustrating tese points:
1: load_package trigd$ 2: on rounded; 3: sind dms2deg {60, 45, 30}; 0.872567064923 4: sind {60,45, 30}; {0.866025403784,0.707106781187,0.5} 5: off rounded; 6: sind{60, 45, 30}; sqrt(3) sqrt(2) 1 {---------,---------,---} 2 2 2
Of course the results will be formatted much more attractively on a terminal supporting nice graphics.
The behaviour of the numerical evaluation routines for inverse trig functions with complex arguments at branch points could be improved; these values are undefined and attempting to evaluate such a function at one of its branch points ought to raise an error, however sometimes the input expression will be returned unaltered. It is hoped to improve this behaviour in due course.
Currently there are no facilities analogous to those provided in the module TRIGSIMP
for the standard trig. functions. There users have a wide range of standard simplification
formulae available for use and can control which are to be used depending on the
requirements of their particular application: whether to eliminate sin
in favour
of cos
or vice-versa or to get rid of both in favour of tan
of half-angles; or
whether to use the trigonometrical addition formulae in order to transform trig
functions whose arguments are sums into a form where the arguments are single
terms or whether to perform the inverse transformations. It is hoped to make the
TRIGSIMP
faciliites available for use with the TRIGD
functions in the near
future.
Integration is not directly supported although the approach using rule-lists to convert the
TRIGD
functions to standard trig ones should work well. Introducing direct supp<ort for
integration will not therefore be a priority.
For the standard sine function there is a rule for imaginary arguments namely:
sin(i*x) => i*sinh(x)
. The corresponding rule for the degree version is
sind(i*x) => i*sinh(x*pi/180)
. However, currently such rules are NOT
implemented by the system. They may be implemented in future, but it is not a high
priority as it is felt that the radian-based trig functions are best suited for such symbolic
calculations.
There are NO D versions of the hyperbolic functions — that would be a step too
far! And should the new functions be called sinhd
and so on? Or perhaps
sindh
52
etc?
Up | Next | Prev | PrevTail | Front |