rsolve.rlg 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. Sun Jan 3 23:47:50 MET 1999
  2. REDUCE 3.7, 15-Jan-99 ...
  3. 1: 1:
  4. 2: 2: 2: 2: 2: 2: 2: 2: 2:
  5. 3: 3: % Test file for i_solve and r_solve operators.
  6. % Author: F.J.Wright@Maths.QMW.ac.uk
  7. % Version 1.051, 16 Jan 1995
  8. i_solve((x - 10)*(x + 20)*(x - 30)*(x + 40)*(x - 50));
  9. {x=-20,x=-40,x=50,x=30,x=10}
  10. % {x=-20,x=-40,x=50,x=30,x=10}
  11. i_solve(x^4 - 1, x);
  12. {x=1,x=-1}
  13. % {x=1,x=-1}
  14. i_solve(x^4 + 1);
  15. {}
  16. % {}
  17. r_solve((x^2 - 1)*(x^2 - 9));
  18. {x=1,x=-3,x=3,x=-1}
  19. % {x=1,x=-3,x=3,x=-1}
  20. r_solve(9x^2 - 1);
  21. 1 - 1
  22. {x=---,x=------}
  23. 3 3
  24. % 1 - 1
  25. % {x=---,x=------}
  26. % 3 3
  27. r_solve(9x^2 - 4, x);
  28. - 2 2
  29. {x=------,x=---}
  30. 3 3
  31. % - 2 2
  32. % {x=------,x=---}
  33. % 3 3
  34. r_solve(9x^2 + 16, x);
  35. {}
  36. % {}
  37. r_solve((9x^2 - 16)*(x^2 - 9), x);
  38. - 4 4
  39. {x=------,x=3,x=-3,x=---}
  40. 3 3
  41. % - 4 4
  42. % {x=------,x=3,x=-3,x=---}
  43. % 3 3
  44. % First two examples from Loos' paper:
  45. % ===================================
  46. r_solve(6x^4 - 11x^3 - x^2 - 4);
  47. - 2
  48. {x=------,x=2}
  49. 3
  50. % - 2
  51. % {x=------,x=2}
  52. % 3
  53. r_solve(2x^3 + 12x^2 + 13x + 15);
  54. {x=-5}
  55. % {x=-5}
  56. % Remaining four CORRECTED examples from Loos' paper:
  57. % ==================================================
  58. r_solve(2x^4 - 4x^3 + 3x^2 - 5x - 2);
  59. {x=2}
  60. % {x=2}
  61. r_solve(6x^5 + 11x^4 - x^3 + 5x - 6);
  62. - 3 2
  63. {x=------,x=---}
  64. 2 3
  65. % - 3 2
  66. % {x=------,x=---}
  67. % 2 3
  68. r_solve(x^5 - 5x^4 + 2x^3 - 25x^2 + 21x + 270);
  69. {x=3,x=5,x=-2}
  70. % {x=3,x=5,x=-2}
  71. r_solve(2x^6 + x^5 - 9x^4 - 6x^3 - 5x^2 - 7x + 6);
  72. 1
  73. {x=---,x=-2}
  74. 2
  75. % 1
  76. % {x=---,x=-2}
  77. % 2
  78. % Degenerate equations:
  79. % ====================
  80. i_solve 0;
  81. {}
  82. % {}
  83. i_solve(0, x);
  84. {x=arbint(1)}
  85. % {x=arbint(1)}
  86. r_solve(a = a, x);
  87. {x=arbrat(2)}
  88. % {x=arbrat(2)}
  89. r_solve(x^2 - 1, y);
  90. {}
  91. % {}
  92. % Test of options and multiplicity:
  93. % ================================
  94. i_solve(x^4 - 1, x, noeqs);
  95. {1,-1}
  96. % {1,-1}
  97. i_solve((x^4 - 1)^3, x);
  98. {x=1,x=-1}
  99. % {x=1,x=-1}
  100. root_multiplicities;
  101. {3,3}
  102. % {3,3}
  103. on multiplicities;
  104. i_solve((x^4 - 1)^3, x);
  105. {x=1,x=1,x=1,x=-1,x=-1,x=-1}
  106. % {x=1,x=1,x=1,x=-1,x=-1,x=-1}
  107. root_multiplicities;
  108. {}
  109. % {}
  110. i_solve((x^4 - 1)^3, x, separate);
  111. {x=1,x=-1}
  112. % {x=1,x=-1}
  113. root_multiplicities;
  114. {3,3}
  115. % {3,3}
  116. off multiplicities;
  117. i_solve((x^4 - 1)^3, x, multiplicities);
  118. {x=1,x=1,x=1,x=-1,x=-1,x=-1}
  119. % {x=1,x=1,x=1,x=-1,x=-1,x=-1}
  120. root_multiplicities;
  121. {}
  122. % {}
  123. i_solve((x^4 - 1)^3, x, expand, noeqs);
  124. {1,1,1,-1,-1,-1}
  125. % {1,1,1,-1,-1,-1}
  126. root_multiplicities;
  127. {}
  128. % {}
  129. i_solve((x^4 - 1)^3, x, together);
  130. {{x=1,3},{x=-1,3}}
  131. % {{x=1,3},{x=-1,3}}
  132. root_multiplicities;
  133. {}
  134. % {}
  135. i_solve((x^4 - 1)^3, x, together, noeqs);
  136. {{1,3},{-1,3}}
  137. % {{1,3},{-1,3}}
  138. root_multiplicities;
  139. {}
  140. % {}
  141. i_solve((x^4 - 1)^3, x, nomul);
  142. {x=-1,x=1}
  143. % {x=-1,x=1}
  144. root_multiplicities;
  145. {}
  146. % {}
  147. % Test of error handling:
  148. % ======================
  149. on errcont;
  150. r_solve();
  151. ***** r/i_solve called with no equations
  152. % ***** r/i_solve called with no equations
  153. r_solve(x^2 - a, x);
  154. 2
  155. ***** - a + x invalid as univariate polynomial over Z
  156. % 2
  157. % ***** - a + x invalid as univariate polynomial over Z
  158. r_solve(x^2 - 1, x, foo);
  159. ***** foo invalid as optional r/i_solve argument
  160. % ***** foo invalid as optional r/i_solve argument
  161. r_solve({x^2 - 1}, x);
  162. 2
  163. ***** {x - 1} invalid as univariate polynomial over Z
  164. % 2
  165. % ***** {x - 1} invalid as univariate polynomial over Z
  166. on complex;
  167. i_solve((x-1)*(x-i), x);
  168. 2
  169. ***** - i*x + i + x - x invalid as univariate polynomial over Z
  170. % 2
  171. % ***** - i*x + i + x - x invalid as univariate polynomial over Z
  172. end$
  173. 4: 4: 4: 4: 4: 4: 4: 4: 4:
  174. Time for test: 150 ms
  175. 5: 5:
  176. Quitting
  177. Sun Jan 3 23:47:53 MET 1999