File r38/packages/arnum/arnum.rlg artifact 1986ffc405 part of check-in 3c4d7b69af


Tue Feb 10 12:26:32 2004 run on Linux
% Test of algebraic number package.

defpoly sqrt2**2-2;



1/(sqrt2+1);


sqrt2 - 1


(x**2+2*sqrt2*x+2)/(x+sqrt2);


x + sqrt2


on gcd;



(x**3+(sqrt2-2)*x**2-(2*sqrt2+3)*x-3*sqrt2)/(x**2-2);


  2
 x  - 2*x - 3
--------------
  x - sqrt2


off gcd;



sqrt(x**2-2*sqrt2*x*y+2*y**2);


x - sqrt2*y


off arnum;

  %to start a new algebraic extension.


defpoly cbrt5**3-5;



on rationalize;



1/(x-cbrt5);


  2                  2
 x  + cbrt5*x + cbrt5
-----------------------
         3
        x  - 5


off rationalize;



off arnum;

  %to start a new algebraic extension.


%The following examples are taken from P.S. Wang Math. Comp. 30,
%    134,(1976),p.324.

on factor;



defpoly i**2+1=0;



w0 := x**2+1;


w0 := (x + i)*(x - i)


w1 := x**4-1;


w1 := (x + i)*(x - i)*(x + 1)*(x - 1)


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


        2
w2 := (x  + i*x + 3)*(x + i + 1)*(x - (i - 1))


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


                  2              2     2        3
w3 := (2*i + 3)*(x  + i*x - 1)*(x  - (----*i - ----))
                                       13       13


off arnum;




defpoly a**2-5;



w4 := x**2+x-1;


            1       1          1       1
w4 := (x + ---*a + ---)*(x - (---*a - ---))
            2       2          2       2


off arnum;




defpoly a**2+a+2;



w5 := x**4+3*x**2+4;


w5 := (x + a + 1)*(x + a)*(x - (a + 1))*(x - a)


off arnum;




defpoly a**3+2=0;



w6:=64*x**6-4;


           2    1         1   2    2    1         1   2        1           1
w6 := 64*(x  + ---*a*x + ---*a )*(x  - ---*a*x + ---*a )*(x + ---*a)*(x - ---*a)
                2         4             2         4            2           2


off arnum;




defpoly a**4+a**3+a**2+a+1=0;



w7:=16*x**4+8*x**3+4*x**2+2*x+1;


w7 := 

         1   3    1   2    1       1         1   3        1   2        1
16*(x + ---*a  + ---*a  + ---*a + ---)*(x - ---*a )*(x - ---*a )*(x - ---*a)
         2        2        2       2         2            2            2


off arnum, factor;




defpoly sqrt5**2-5,cbrt3**3-3;


*** Defining polynomial for primitive element:

  6        4       3        2
a1  - 15*a1  - 6*a1  + 75*a1  - 90*a1 - 116



cbrt3**3;


3


sqrt5**2;


5


cbrt3;


     120     5     27     4    2000    3    1170    2    6676        6825
 - (------*a1  + ------*a1  - ------*a1  - ------*a1  + ------*a1 - ------)
     8243         8243         8243         8243         8243        8243


sqrt5;


 120     5     27     4    2000    3    1170    2    14919        6825
------*a1  + ------*a1  - ------*a1  - ------*a1  + -------*a1 - ------
 8243         8243         8243         8243         8243         8243


sqrt(x**2+2*(sqrt5-cbrt3)*x+5-2*sqrt5*cbrt3+cbrt3**2);


     240     5     54     4    4000    3    2340    2    21595        13650
x + ------*a1  + ------*a1  - ------*a1  - ------*a1  + -------*a1 - -------
     8243         8243         8243         8243         8243         8243


on rationalize;



1/(x+sqrt5-cbrt3);


  5     240     5     54     4    4000    3    2340    2    21595        13650
(x  - (------*a1  + ------*a1  - ------*a1  - ------*a1  + -------*a1 - -------)
        8243         8243         8243         8243         8243         8243

   4
 *x  - 

   108     5    800     4    1800    3    15433    2    15900        14465    3
 (------*a1  - ------*a1  - ------*a1  + -------*a1  + -------*a1 + -------)*x
   8243         8243         8243         8243          8243         8243

       3           2
  - (a1  - 15*a1)*x  - 

   900     5    3919    4    15000    3    8775    2    148986        154225
 (------*a1  - ------*a1  - -------*a1  - ------*a1  + --------*a1 - --------)*x
   8243         8243         8243          8243          8243          8243

      1919    5    1050    4    18245    3    12528    2    236725        73080
  - (------*a1  + ------*a1  - -------*a1  - -------*a1  + --------*a1 - -------
      8243         8243         8243          8243           8243         8243

          6       4      3       2
     ))/(x  - 15*x  - 6*x  + 75*x  - 90*x - 116)


off arnum, rationalize;




split_field(x**3+2);


*** Splitting field is generated by:

  6
a3  + 108


  1     4    1
{----*a3  + ---*a3,
  36         2

     1     4
  - ----*a3 ,
     18

  1     4    1
 ----*a3  - ---*a3}
  36         2


for each j in ws product (x-j);


 3
x  + 2


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


*** Splitting field is generated by:

  3       2
a4  + 4*a4  + a4 - 1


      2                  2
{a4,a4  + 3*a4 - 2, - (a4  + 4*a4 + 2)}


for each j in ws product (x-j);


 3      2
x  + 4*x  + x - 1


split_field(x**3-3*x+7);


*** Splitting field is generated by:

  6        4        2
a6  - 18*a6  + 81*a6  + 1215


   1     4    5     2    1        2
{-----*a6  - ----*a6  + ---*a6 + ---,
  126         42         2        7

      1     4    5     2    4
  - (----*a6  - ----*a6  + ---),
      63         21         7

   1     4    5     2    1        2
 -----*a6  - ----*a6  - ---*a6 + ---}
  126         42         2        7


for each j in ws product (x-j);


 3
x  - 3*x + 7


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


*** Splitting field is generated by:

  3       2
a7  + 4*a7  + a7 - 1


      2                  2
{a7,a7  + 3*a7 - 2, - (a7  + 4*a7 + 2)}


for each j in ws product (x-j);


 3      2
x  + 4*x  + x - 1


split_field(x**3-x**2-x-1);


*** Splitting field is generated by:

  6       5       4        3        2
a9  - 6*a9  + 7*a9  + 12*a9  - 17*a9  - 6*a9 + 53


      3     4    3     3    1     2    5         17
{ - (----*a9  - ----*a9  - ----*a9  - ----*a9 + ----),
      76         19         38         38        76

  3     4    6     3    1     2    14        17
 ----*a9  - ----*a9  - ----*a9  + ----*a9 + ----,
  38         19         19         19        38

      3     4    3     3    1     2    33        59
  - (----*a9  - ----*a9  - ----*a9  + ----*a9 - ----)}
      76         19         38         38        76


for each j in ws product (x-j);


 3    2
x  - x  - x - 1


% A longer example.

off arnum;



defpoly a**6+3*a**5+6*a**4+a**3-3*a**2+12*a+16;



factorize(x**3-3);


       1   5    1   4    2   3    1   2    2       7
{{x + ---*a  + ---*a  + ---*a  - ---*a  + ---*a + ---,1},
       6        3        3        6        3       3

        1    5    1    4    1   3    7    2    11       4
 {x - (----*a  + ----*a  + ---*a  - ----*a  + ----*a + ---),1},
        12        12        6        12        12       3

        1    5    1   4    1   3    5    2    1
 {x - (----*a  + ---*a  + ---*a  + ----*a  - ---*a + 1),1}}
        12        4        2        12        4


end;


Time for test: 100 ms


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