arnum.tst 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. % Test of algebraic number package.
  2. defpoly sqrt2**2-2;
  3. 1/(sqrt2+1);
  4. (x**2+2*sqrt2*x+2)/(x+sqrt2);
  5. on gcd;
  6. (x**3+(sqrt2-2)*x**2-(2*sqrt2+3)*x-3*sqrt2)/(x**2-2);
  7. off gcd;
  8. sqrt(x**2-2*sqrt2*x*y+2*y**2);
  9. off arnum; %to start a new algebraic extension.
  10. defpoly cbrt5**3-5;
  11. on rationalize;
  12. 1/(x-cbrt5);
  13. off rationalize;
  14. off arnum; %to start a new algebraic extension.
  15. %The following examples are taken from P.S. Wang Math. Comp. 30,
  16. % 134,(1976),p.324.
  17. on factor;
  18. defpoly i**2+1=0;
  19. w0 := x**2+1;
  20. w1 := x**4-1;
  21. w2 := x**4+(i+2)*x**3+(2*i+5)*x**2+(2*i+6)*x+6;
  22. w3 := (2*i+3)*x**4+(3*i-2)*x**3-2*(i+1)*x**2+i*x-1;
  23. off arnum;
  24. defpoly a**2-5;
  25. w4 := x**2+x-1;
  26. off arnum;
  27. defpoly a**2+a+2;
  28. w5 := x**4+3*x**2+4;
  29. off arnum;
  30. defpoly a**3+2=0;
  31. w6:=64*x**6-4;
  32. off arnum;
  33. defpoly a**4+a**3+a**2+a+1=0;
  34. w7:=16*x**4+8*x**3+4*x**2+2*x+1;
  35. off arnum, factor;
  36. defpoly sqrt5**2-5,cbrt3**3-3;
  37. cbrt3**3;
  38. sqrt5**2;
  39. cbrt3;
  40. sqrt5;
  41. sqrt(x**2+2*(sqrt5-cbrt3)*x+5-2*sqrt5*cbrt3+cbrt3**2);
  42. on rationalize;
  43. 1/(x+sqrt5-cbrt3);
  44. off arnum, rationalize;
  45. split!_field(x**3+2);
  46. for each j in ws product (x-j);
  47. split!_field(x**3+4*x**2+x-1);
  48. for each j in ws product (x-j);
  49. split!_field(x**3-3*x+7);
  50. for each j in ws product (x-j);
  51. split!_field(x**3+4*x**2+x-1);
  52. for each j in ws product (x-j);
  53. split!_field(x**3-x**2-x-1);
  54. for each j in ws product (x-j);
  55. % A longer example.
  56. off arnum;
  57. defpoly a**6+3*a**5+6*a**4+a**3-3*a**2+12*a+16;
  58. factorize(x**3-3);
  59. end;