1% Test of algebraic number package. 2 3defpoly sqrt2**2-2; 4 51/(sqrt2+1); 6 7(x**2+2*sqrt2*x+2)/(x+sqrt2); 8 9on gcd; 10 11(x**3+(sqrt2-2)*x**2-(2*sqrt2+3)*x-3*sqrt2)/(x**2-2); 12 13off gcd; 14 15sqrt(x**2-2*sqrt2*x*y+2*y**2); 16 17off arnum; %to start a new algebraic extension. 18 19 20defpoly cbrt5**3-5; 21 22on rationalize; 23 241/(x-cbrt5); 25 26off rationalize; 27 28off arnum; %to start a new algebraic extension. 29 30 31%The following examples are taken from P.S. Wang Math. Comp. 30, 32% 134,(1976),p.324. 33 34on factor; 35 36defpoly i**2+1=0; 37 38w0 := x**2+1; 39 40w1 := x**4-1; 41 42w2 := x**4+(i+2)*x**3+(2*i+5)*x**2+(2*i+6)*x+6; 43 44w3 := (2*i+3)*x**4+(3*i-2)*x**3-2*(i+1)*x**2+i*x-1; 45 46off arnum; 47 48 49defpoly a**2-5; 50 51w4 := x**2+x-1; 52 53off arnum; 54 55 56defpoly a**2+a+2; 57 58w5 := x**4+3*x**2+4; 59 60off arnum; 61 62 63defpoly a**3+2=0; 64 65w6:=64*x**6-4; 66 67off arnum; 68 69 70defpoly a**4+a**3+a**2+a+1=0; 71 72w7:=16*x**4+8*x**3+4*x**2+2*x+1; 73 74off arnum, factor; 75 76 77defpoly sqrt5**2-5,cbrt3**3-3; 78 79cbrt3**3; 80 81sqrt5**2; 82 83cbrt3; 84 85sqrt5; 86 87sqrt(x**2+2*(sqrt5-cbrt3)*x+5-2*sqrt5*cbrt3+cbrt3**2); 88 89on rationalize; 90 911/(x+sqrt5-cbrt3); 92 93off arnum, rationalize; 94 95 96split_field(x**3+2); 97 98for each j in ws product (x-j); 99 100split_field(x**3+4*x**2+x-1); 101 102for each j in ws product (x-j); 103 104split_field(x**3-3*x+7); 105 106for each j in ws product (x-j); 107 108split_field(x**3+4*x**2+x-1); 109 110for each j in ws product (x-j); 111 112split_field(x**3-x**2-x-1); 113 114for each j in ws product (x-j); 115 116% A longer example. 117 118off arnum; 119 120defpoly a**6+3*a**5+6*a**4+a**3-3*a**2+12*a+16; 121 122factorize(x**3-3); 123 124end; 125