File r34.1/xlog/complex.log artifact e4559d5fd6 part of check-in 5f584e9b52


Sat May 30 16:09:17 PDT 1992
REDUCE 3.4.1, 15-Jul-92 ...

1: 1: 
2: 2: 
3: 3: 
Time: 0 ms

4: 4: % Test of Complex Number mode in REDUCE.

on complex;



(31+i)/74;


 31 + I
--------
   74


ws/(b+1);


   31 + I
------------
 74*(B + 1)
  % this now comes out right!

w:=(x+3*i)**2;


      2
W := X  + 6*I*X - 9


on gcd;



(x**3-7*x**2+x-7)/(x**2+(3+i)*x+3*i);


  2
 X  - (7 + I)*X + 7*I
----------------------
        X + 3


off gcd;



sqrt(x**4+14*i*x**3-51*x**2-14*i*x+1);


 2
X  + 7*I*X - 1


% All rounded tests are done twice:  first, they are done at the default
% precision, in which all rounded operations use standard floating point
% logic.  Then precision is increased, causing all rounded operations to
% use extended precision bigfloat arithmetic.  This is necessary to
% exercise and test the bigfloat-based arithmetic functions.

prec0 := precision 0;


PREC0 := 12
  % to determine the nominal default precision.

% Tests using default precision:

on rounded;


*** Domain mode COMPLEX changed to COMPLEX-ROUNDED 


(3.25 + 8.5i) + (6.75 - 8.5i);


10.0


(3.25 + 8.5i) - (6.0 - 9.5i);


-2.75 + 18.0*I


(1.0 + 10.0*i)*(-6.5 + 2.5*i);


-31.5 - 62.5*I


(1.2 - 3.4*i)*(-5.6 + 7.8*i);


19.8 + 28.4*I


(19.8 + 28.4*i)/(-5.6 + 7.8*i);


1.2 - 3.4*I


e;


2.71828182846


pi;


3.14159265359


17*i**2;


-17


(-7.0 + 24.0*i)**(1/2);


3.0 + 4.0*I


sqrt(-7.0 + 24.0*i);


3.0 + 4.0*I


sqrt(-10.12 - 8.16*i);


-1.2 + 3.4*I


sin(0.0 + 0.0*i);


0


sin(1.0 + 0.0*i);


0.841470984808


sin(1.0 + 1.0*i);


1.29845758142 + 0.634963914785*I


cos(0.0 + 0.0*i);


1


cos(1.0 - 0.0*i);


0.540302305868


cos(1.0 + 1.0*i);


0.833730025131 - 0.988897705763*I


tan(0.0 + 0.0*i);


0


tan(1.0 + 0.0*i);


1.55740772465


tan(1.0 + 1.0*i);


0.27175258532 + 1.08392332734*I


asin(1.0 + 1.0*i);


0.666239432493 + 1.06127506191*I


acos(1.0 + 1.0*i);


0.904556894302 - 1.06127506191*I


atan(1.0 + 1.0*i);


1.0172219679 + 0.402359478109*I


log(1.0 + 1.0*i);


0.34657359028 + 0.785398163397*I


asin 2;


1.57079632679 - 1.31695789692*I


sin ws;


2.0


acos 2;


1.31695789692*I


cos ws;


2.0


atan(1+i);


1.0172219679 + 0.402359478109*I


tan ws;


1 + I


log(2+i);


0.804718956217 + 0.463647609001*I


exp ws;


2.0 + I


e**(i*pi);


 - 1


e**i;


0.540302305868 + 0.841470984808*I


z := sqrt i;


Z := 0.707106781187 + 0.707106781187*I


z**2;


I


off rounded;


*** Domain mode COMPLEX-ROUNDED changed to COMPLEX 


%-----------------end of normal floating point tests--------------------

precision(prec0+6);


12
 % arbitrary precision increase -> bigfloat functions

%----------------------start of bigfloat tests--------------------------

on rounded;


*** Domain mode COMPLEX changed to COMPLEX-ROUNDED 


(3.25 + 8.5i) + (6.75 - 8.5i);


10.0


(3.25 + 8.5i) - (6.0 - 9.5i);


-2.75 + 18.0*I


(1.0 + 10.0*i)*(-6.5 + 2.5*i);


-31.5 - 62.5*I


(1.2 - 3.4*i)*(-5.6 + 7.8*i);


19.8 + 28.4*I


(19.8 + 28.4*i)/(-5.6 + 7.8*i);


1.2 - 3.4*I


e;


2.718 28182 84590 4524


pi;


3.141 59265 35897 9324


17*i**2;


-17


(-7.0 + 24.0*i)**(1/2);


3.0 + 4.0*I


sqrt(-7.0 + 24.0*i);


3.0 + 4.0*I


sqrt(-10.12 - 8.16*i);


-1.2 + 3.4*I


sin(0.0 + 0.0*i);


0


sin(1.0 + 0.0*i);


0.841 47098 48078 96507 


sin(1.0 + 1.0*i);


1.298 45758 14159 7729 + 0.634 96391 47847 36108 *I


cos(0.0 + 0.0*i);


1


cos(1.0 - 0.0*i);


0.540 30230 58681 39717 


cos(1.0 + 1.0*i);


0.833 73002 51311 49049  - 0.988 89770 57628 65096 *I


tan(0.0 + 0.0*i);


0


tan(1.0 + 0.0*i);


1.557 40772 46549 0223


tan(1.0 + 1.0*i);


0.271 75258 53195 11717  + 1.083 92332 73386 9454*I


asin(1.0 + 1.0*i);


0.666 23943 24925 15255  + 1.061 27506 19050 3565*I


acos(1.0 + 1.0*i);


0.904 55689 43023 81364  - 1.061 27506 19050 3565*I


atan(1.0 + 1.0*i);


1.017 22196 78978 5137 + 0.402 35947 81085 25094 *I


log(1.0 + 1.0*i);


0.346 57359 02799 72655  + 0.785 39816 33974 4831*I


asin 2;


1.570 79632 67948 9662 - 1.316 95789 69248 1671*I


sin ws;


2.0


acos 2;


1.316 95789 69248 1671*I


cos ws;


2.0


atan(1+i);


1.017 22196 78978 5137 + 0.402 35947 81085 25094 *I


tan ws;


1 + I


log(2+i);


0.804 71895 62170 50187  + 0.463 64760 90008 06116 *I


exp ws;


2.0 + I


e**(i*pi);


 - 1


e**i;


0.540 30230 58681 39717  + 0.841 47098 48078 96507 *I


z := sqrt i;


Z := 0.707 10678 11865 47524  + 0.707 10678 11865 47524 *I


z**2;


I


off rounded;


*** Domain mode COMPLEX-ROUNDED changed to COMPLEX 


% ---------------------------------------------------------------------

% The following examples are independent of precision.

precision prec0;


18
 % restores default precision.

% on rationalize;  % no longer needed, since it doesn't affect complex.

s:= 1.1+2.3i;


      11 + 23*I
S := -----------
         10


s/4;


 11 + 23*I
-----------
    40
  % this would have had a common factor of 4.

x:= a+1.1+2.3i;


      10*A + (11 + 23*I)
X := --------------------
              10


y:= b+1.2+1.3i;


      10*B + (12 + 13*I)
Y := --------------------
              10


z:= x/y;


      100*A*B + (120 - 130*I)*A + (110 + 230*I)*B + (431 + 133*I)
Z := -------------------------------------------------------------
                              2
                         100*B  + 240*B + 313


z/4;


 100*A*B + (120 - 130*I)*A + (110 + 230*I)*B + (431 + 133*I)
-------------------------------------------------------------
                          2
                  4*(100*B  + 240*B + 313)
  % this would have had a common polynomial factor b^2 + ...

z*7/4;


 7*(100*A*B + (120 - 130*I)*A + (110 + 230*I)*B + (431 + 133*I))
-----------------------------------------------------------------
                            2
                    4*(100*B  + 240*B + 313)


s/(c^2+c+1);


    11 + 23*I
-----------------
      2
 10*(C  + C + 1)
  % this would have had a common factor of c^2+c+1

clear x;



zz:= x^2+(1.1+2.3i)*x+1.2+1.3i;


           2
       10*X  + (11 + 23*I)*X + (12 + 13*I)
ZZ := -------------------------------------
                       10


ss:=1.23456789x^2+1.3579i*x+5.6789;


                  2
       123456789*X  + 135790000*I*X + 567890000
SS := ------------------------------------------
                      100000000


% off rationalize;  % not needed now.

z:= x+1.1+2.3i;


      10*X + (11 + 23*I)
Z := --------------------
              10


on rationalize;



z;


 10*X + (11 + 23*I)
--------------------
         10
               % same as previous answer.

off rationalize;



1.23456789x^2+2.3456i*x+7.89;


            2
 123456789*X  + 234560000*I*X + 789000000
------------------------------------------
                100000000


on factor;



x**2+1;


(X + I)*(X - I)


x**4-1;


(X + I)*(X - I)*(X + 1)*(X - 1)


x**4+(i+2)*x**3+(2*i+5)*x**2+(2*i+6)*x+6;


  2
(X  + I*X + 3)*(X + (1 + I))*(X + 1 - I)


(2*i+3)*x**4+(3*i-2)*x**3-2*(i+1)*x**2+i*x-1;


              2        2
I*((2 - 3*I)*X  - I)*(X  + I*X - 1)


% Multivariate examples:

x**2+y**2;


 (10*B + 10*I*X + (12 + 13*I))*(10*B - 10*I*X + (12 + 13*I))
-------------------------------------------------------------
                             100


off factor;



factorize(x**2+1);


{X - I,X + I}


end;

5: 5: 
Time: 5253 ms  plus GC time: 136 ms
6: 6: 
Quitting
Sat May 30 16:09:24 PDT 1992


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