123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707 |
- 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)
|