File r36/xlog/ELEM.LOG artifact 23053315b9 part of check-in a7bd34d54c


REDUCE 3.6, 15-Jul-95, patched to 6 Mar 96 ...


comment

This is a demonstration of the working of elementary functions available
in the Reduce system.  It is not intended as an accuracy test.  Other 
functions become available if certain library packages are loaded.

                            -------

Integer functions that work in all domain modes, independent of switch
NUMVAL, so long as their arguments evaluate to real numbers.

Functions of one argument:
FIX, SGN, ROUND, CEILING, FLOOR

(The following functions are available only in symbolic mode, so they
 are not tested here: ISQRT, ICBRT, ILOG2, IROOTN);


fix a;


fix(a)
  % will be evaluated only if a evaluates to a real number.

a := 27/4;


      27
a := ----
      4


fix a;


6


fix 12.345;


12


sign (-15/2);


-1


round 12.5;


13


ceiling 12.5;


13


floor 12.5;


12


% isqrt 12.5;

% icbrt 12.5;

% ilog2 130.7;

% irootn(72,4);

% irootn(72,3/2); % this will not evaluate.


comment   Functions which require arguments which evaluate to integers:

Function of one argument:  FACTORIAL

Fumction of two arguments:  PERM, CHOOSE;
$



factorial 10;


3628800


perm(5,10);


30240
  % permutations of 5 out of 10.

choose(5,10);


252
  % choose 5 out of 10;


comment

These functions are evaluated in dmodes ROUNDED and COMPLEX-ROUNDED
(ON ROUNDED,COMPLEX) so long as their arguments and values evaluate
to real numbers and NUMVAL (normally ON) is ON.

Variable treated as function of no arguments:  E, PI.

Functions of one argument:
EXP, LOG, LN, LOG10, NORM, ARG, SQRT,
RAD2DEG, RAD2DMS, DEG2RAD, DEG2DMS, DMS2DEG, DMS2RAD,
SIN, ASIN, COS, ACOS, TAN, ATAN, COT, ACOT, SEC, ASEC, CSC, ACSC,
SINH, ASINH, COSH, ACOSH, TANH, ATANH, COTH, ACOTH, SECH, ASECH,
CSCH, ACSCH.

Functions of two arguments:
EXPT, LOGB, HYPOT, ATAN2.

Function evaluation is carried out to the precision specified in the
latest PRECISION statement.

(The following functions are available only in symbolic mode, so they
 are not tested here:
  SIND, ASIND, COSD, ACOSD, TAND, ATAND, COTD, ACOTD, SECD, ASECD,
  CSCD, ACSCD, ATAN2D, CBRT);


on rounded;

 precision 6;


12


a := exp 3;


a := 20.0855


log a;


3.0


ln a;


3.0


log10 1000;


3.0


norm (-12.345);


12.345
  % for real x, this is equivalent to ABS x.

arg (-12.345);


3.14159
  % for real x, this -> if x<0 then pi else 0.0.

sqrt 3;


1.73205


ws**2;


3.0


deg2rad 30;


0.523599


rad2deg ws;


30.0


a := deg2dms 12.345;


a := {12,20,42.0}
 % a will be a list.

dms2deg ws;


12.345


dms2rad a;


0.215461


rad2deg ws;


12.345


asin 0.5;


0.523599


sin ws;


0.5


acos 0.5;


1.0472


cos ws;


0.5


atan 0.5;


0.463648


tan ws;


0.5


acot 0.5;


1.10715


cot ws;


0.5


asec 3;


1.23096


sec ws;


3.0


acsc 3;


0.339837


csc ws;


3.0


asinh 0.5;


0.481212


sinh ws;


0.5


acosh 2;


1.31696


cosh ws;


2.0


atanh 0.5;


0.549306


tanh ws;


0.5


acoth 2;


0.549306


coth ws;


2.0


sech 1;


0.648054


asech ws;


1


csch 1;


0.850918


acsch ws;


1


expt(2,1.234);


2.35218


logb(ws,2);


1.234


hypot(3,4);


5.0


a := -3*pi/4;


a :=  - 2.35619
 % any  -pi<a<=pi should work.

atan2(sin a,cos a);


 - 2.35619


ws - a;


0
  % should be 0.

precision 20;


6
  % functions will be computed to 20 places.

sin 1.5;


0.99749498660405443094


asin ws;


1.5


precision 50;


20
  % fuctions computed to 50 places.

sin 1.5;


0.99749498660405443094172337114148732270665142592212


asin ws;


1.5


precision 6;


50


comment   If argument or value are complex, functions are not computed
when dmode is ROUNDED;
 $



sin(1+i);


sin(i + 1)
  % complex argument.

asin 2;


asin(2)
  % value would be complex.

on complex;


*** Domain mode rounded changed to complex-rounded 
  %now complex arguments and complex results will be handled.

comment   Complex functions of one argument:
EXP, LOG, NORM, ARG, SQRT,
SIN, ASIN, COS, ACOS, TAN, ATAN, COT, ACOT, SEC, ASEC, CSC, ACSC,
SINH, ASINH, COSH. ACOSH, TANH, ATANH, COTH, ACOTH, SECH, ASECH,
CSCH, ACSCH.
(The following functions are available only in symbolic mode, so they
 are not tested here:
  SIND, ASIND, COSD, ACOSD, TAND, ATAND, COTD, ACOTD, SECD, ASECD,
  CSCD, ACSCD.)

Complex function of two variables:  EXPT, LOGB, ATAN2;


e**(pi*i);


 - 1 + 1.22461e-16*i
 % should be -1 (except for computational error.)

log(1+i);


0.346574 + 0.785398*i


exp ws;


1 + i


norm(5*exp(2i));


5.0


arg(5*exp(2i));


2.0


sqrt(1+i);


1.09868 + 0.45509*i


ws**2;


1 + i


asin 2;


1.5708 - 1.31696*i


sin ws;


2.0 - 1.25983e-15*i


acos 2;


1.31696*i


cos ws;


2.0


atan(1+i);


1.01722 + 0.402359*i


tan ws;


1 + i


acot(1+i);


0.553574 - 0.402359*i


cot ws;


1 + i


asec 0.1;


2.99322*i


sec ws;


0.1


acsc 0.1;


1.5708 - 2.99322*i


csc ws;


0.1 + 7.23718e-17*i


sinh(1+i);


0.634964 + 1.29846*i


asinh ws;


1 + i


cosh(1+i);


0.83373 + 0.988898*i


acosh ws;


1 + i


atanh 2;


0.549306 + 1.5708*i


tanh ws;


2.0 + 1.83691e-16*i


acoth 0.3;


0.30952 + 1.5708*i


coth ws;


0.3 - 5.57196e-17*i


asech(1-i);


0.530638 + 1.11852*i


sech ws;


1 - i


acsch(1-i);


0.530638 + 0.452278*i


csch ws;


1 - i


expt(1+i,1-i);


2.80788 + 1.31787*i


logb(ws,1+i);


1 - i


a := 1+i;


a := 1 + i
 % any a such that - pi < repart a <= pi should work.

atan2(sin a,cos a);


1 + i


ws - a;


0
 % should be 0;

end;
(TIME:  elem 300 300)


REDUCE Historical
REDUCE Sourceforge Project | Historical SVN Repository | GitHub Mirror | SourceHut Mirror | NotABug Mirror | Chisel Mirror | Chisel RSS ]