RSOLVE.TST 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. % Test file for i_solve and r_solve operators.
  2. % Author: F.J.Wright@Maths.QMW.ac.uk
  3. % Version 1.051, 16 Jan 1995
  4. i_solve((x - 10)*(x + 20)*(x - 30)*(x + 40)*(x - 50));
  5. % {x=-20,x=-40,x=50,x=30,x=10}
  6. i_solve(x^4 - 1, x);
  7. % {x=1,x=-1}
  8. i_solve(x^4 + 1);
  9. % {}
  10. r_solve((x^2 - 1)*(x^2 - 9));
  11. % {x=1,x=-3,x=3,x=-1}
  12. r_solve(9x^2 - 1);
  13. % 1 - 1
  14. % {x=---,x=------}
  15. % 3 3
  16. r_solve(9x^2 - 4, x);
  17. % - 2 2
  18. % {x=------,x=---}
  19. % 3 3
  20. r_solve(9x^2 + 16, x);
  21. % {}
  22. r_solve((9x^2 - 16)*(x^2 - 9), x);
  23. % - 4 4
  24. % {x=------,x=3,x=-3,x=---}
  25. % 3 3
  26. % First two examples from Loos' paper:
  27. % ===================================
  28. r_solve(6x^4 - 11x^3 - x^2 - 4);
  29. % - 2
  30. % {x=------,x=2}
  31. % 3
  32. r_solve(2x^3 + 12x^2 + 13x + 15);
  33. % {x=-5}
  34. % Remaining four CORRECTED examples from Loos' paper:
  35. % ==================================================
  36. r_solve(2x^4 - 4x^3 + 3x^2 - 5x - 2);
  37. % {x=2}
  38. r_solve(6x^5 + 11x^4 - x^3 + 5x - 6);
  39. % - 3 2
  40. % {x=------,x=---}
  41. % 2 3
  42. r_solve(x^5 - 5x^4 + 2x^3 - 25x^2 + 21x + 270);
  43. % {x=3,x=5,x=-2}
  44. r_solve(2x^6 + x^5 - 9x^4 - 6x^3 - 5x^2 - 7x + 6);
  45. % 1
  46. % {x=---,x=-2}
  47. % 2
  48. % Degenerate equations:
  49. % ====================
  50. i_solve 0;
  51. % {}
  52. i_solve(0, x);
  53. % {x=arbint(1)}
  54. r_solve(a = a, x);
  55. % {x=arbrat(2)}
  56. r_solve(x^2 - 1, y);
  57. % {}
  58. % Test of options and multiplicity:
  59. % ================================
  60. i_solve(x^4 - 1, x, noeqs);
  61. % {1,-1}
  62. i_solve((x^4 - 1)^3, x);
  63. % {x=1,x=-1}
  64. root_multiplicities;
  65. % {3,3}
  66. on multiplicities;
  67. i_solve((x^4 - 1)^3, x);
  68. % {x=1,x=1,x=1,x=-1,x=-1,x=-1}
  69. root_multiplicities;
  70. % {}
  71. i_solve((x^4 - 1)^3, x, separate);
  72. % {x=1,x=-1}
  73. root_multiplicities;
  74. % {3,3}
  75. off multiplicities;
  76. i_solve((x^4 - 1)^3, x, multiplicities);
  77. % {x=1,x=1,x=1,x=-1,x=-1,x=-1}
  78. root_multiplicities;
  79. % {}
  80. i_solve((x^4 - 1)^3, x, expand, noeqs);
  81. % {1,1,1,-1,-1,-1}
  82. root_multiplicities;
  83. % {}
  84. i_solve((x^4 - 1)^3, x, together);
  85. % {{x=1,3},{x=-1,3}}
  86. root_multiplicities;
  87. % {}
  88. i_solve((x^4 - 1)^3, x, together, noeqs);
  89. % {{1,3},{-1,3}}
  90. root_multiplicities;
  91. % {}
  92. i_solve((x^4 - 1)^3, x, nomul);
  93. % {x=-1,x=1}
  94. root_multiplicities;
  95. % {}
  96. % Test of error handling:
  97. % ======================
  98. on errcont;
  99. r_solve();
  100. % ***** r/i_solve called with no equations
  101. r_solve(x^2 - a, x);
  102. % 2
  103. % ***** - a + x invalid as univariate polynomial over Z
  104. r_solve(x^2 - 1, x, foo);
  105. % ***** foo invalid as optional r/i_solve argument
  106. r_solve({x^2 - 1}, x);
  107. % 2
  108. % ***** {x - 1} invalid as univariate polynomial over Z
  109. on complex;
  110. i_solve((x-1)*(x-i), x);
  111. % 2
  112. % ***** - i*x + i + x - x invalid as univariate polynomial over Z
  113. end$