123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427 |
- Sun Aug 18 16:14:07 2002 run on Windows
- % 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: 2955 ms, plus GC time: 140 ms
|