SOLVE.TST 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. % Demonstration of the REDUCE SOLVE package.
  2. on fullroots; % To get complete solutions.
  3. % Simultaneous linear fractional equations.
  4. solve({(a*x+y)/(z-1)-3,y+b+z,x-y},{x,y,z});
  5. % Use of square-free factorization together with recursive use of
  6. % quadratic and binomial solutions.
  7. solve((x**6-x**3-1)*(x**5-1)**2*x**2);
  8. multiplicities!*;
  9. % A singular equation without and with a consistent inhomogeneous term.
  10. solve(a,x);
  11. solve(0,x);
  12. off solvesingular;
  13. solve(0,x);
  14. % Use of DECOMPOSE to solve high degree polynomials.
  15. solve(x**8-8*x**7+34*x**6-92*x**5+175*x**4-236*x**3+226*x**2-140*x+46);
  16. solve(x**8-88*x**7+2924*x**6-43912*x**5+263431*x**4-218900*x**3+
  17. 65690*x**2-7700*x+234,x);
  18. % Recursive use of inverses, including multiple branches of rational
  19. % fractional powers.
  20. solve(log(acos(asin(x**(2/3)-b)-1))+2,x);
  21. % Square-free factors that are unsolvable, being of fifth degree,
  22. % transcendental, or without a defined inverse.
  23. operator f;
  24. solve((x-1)*(x+1)*(x-2)*(x+2)*(x-3)*(x*log(x)-1)*(f(x)-1),x);
  25. multiplicities!*;
  26. % Factors with more than one distinct top-level kernel, the first factor
  27. % a cubic. (Cubic solution suppressed since it is too messy to be of
  28. % much use).
  29. off fullroots;
  30. solve((x**(1/2)-(x-a)**(1/3))*(acos x-acos(2*x-b))* (2*log x
  31. -log(x**2+x-c)-4),x);
  32. on fullroots;
  33. % Treatment of multiple-argument exponentials as polynomials.
  34. solve(a**(2*x)-3*a**x+2,x);
  35. % A 12th degree reciprocal polynomial that is irreductible over the
  36. % integers, having a reduced polynomial that is also reciprocal.
  37. % (Reciprocal polynomials are those that have symmetric or antisymmetric
  38. % coefficient patterns.) We also demonstrate suppression of automatic
  39. % integer root extraction.
  40. solve(x**12-4*x**11+12*x**10-28*x**9+45*x**8-68*x**7+69*x**6-68*x**5+
  41. 45*x**4-28*x**3+12*x**2-4*x+1);
  42. % The treatment of factors with non-unique inverses by introducing
  43. % unique new real or integer indeterminant kernels.
  44. solve((sin x-a)*(2**x-b)*(x**c-3),x);
  45. % Automatic restriction to principal branches.
  46. off allbranch;
  47. solve((sin x-a)*(2**x-b)*(x**c-3),x);
  48. % Regular system of linear equations.
  49. solve({2*x1+x2+3*x3-9,x1-2*x2+x3+2,3*x1+2*x2+2*x3-7}, {x1,x2,x3});
  50. % Underdetermined system of linear equations.
  51. on solvesingular;
  52. solve({x1-4*x2+2*x3+1,2*x1-3*x2-x3-5*x4+7,3*x1-7*x2+x3-5*x4+8},
  53. {x1,x2,x3,x4});
  54. % Inconsistent system of linear equations.
  55. solve({2*x1+3*x2-x3-2,7*x1+4*x2+2*x3-8,3*x1-2*x2+4*x3-5},
  56. {x1,x2,x3});
  57. % Overdetermined system of linear equations.
  58. solve({x1-x2+x3-12,2*x1+3*x2-x3-13,3*x2+4*x3-5,-3*x1+x2+4*x3+20},
  59. {x1,x2,x3});
  60. % Degenerate system of linear equations.
  61. operator xx,yy;
  62. yy(1) := -a**2*b**3-3*a**2*b**2-3*a**2*b+a**2*(xx(3)-2)-a*b-a*c+a*(xx(2)
  63. -xx(5))-xx(4)-xx(5)+xx(1)-1;
  64. yy(2) := -a*b**3-b**5+b**4*(-xx(4)-xx(5)+xx(1)-5)-b**3*c+b**3*(xx(2)
  65. -xx(5)-3)+b**2*(xx(3)-1);
  66. yy(3) := -a*b**3*c-3*a*b**2*c-4*a*b*c+a*b*(-xx(4)-xx(5)+xx(1)-1)
  67. +a*c*(xx(3)-1)-b**2*c-b*c**2+b*c*(xx(2)-xx(5));
  68. yy(4) := -a**2-a*c+a*(xx(2)-xx(4)-2*xx(5)+xx(1)-1)-b**4-b**3*c-3*b**3
  69. -3*b**2*c-2*b**2-2*b*c+b*(xx(3)-xx(2)-xx(4)+xx(1)-2)
  70. +c*(xx(3)-1);
  71. yy(5) := -2*a-3*b**3-9*b**2-11*b-2*c+3*xx(3)+2*xx(2)-xx(4)-3*xx(5)+xx(1)
  72. -4;
  73. soln := solve({yy(1),yy(2),yy(3),yy(4),yy(5)},
  74. {xx(1),xx(2),xx(3),xx(4),xx(5)});
  75. for i := 1:5 do xx(i) := part(soln,1,i,2);
  76. for i := 1:5 do write yy(i);
  77. % Single equations liftable to polynomial systems.
  78. solve ({a*sin x + b*cos x},{x});
  79. solve ({a*sin(x+1) + b*cos(x+1)},{x});
  80. % Intersection of 2 curves: system with a free parameter.
  81. solve ({sqrt(x^2 + y^2)=r,0=sqrt(x)+ y**3-1},{x,y,r});
  82. solve ({e^x - e^(1/2 * x) - 7},{x});
  83. % Generally not liftable.
  84. % variable inside and outside of sin.
  85. solve({sin x + x - 1/2},{x});
  86. % Variable inside and outside of exponential.
  87. solve({e^x - x**2},{x});
  88. % Variable inside trigonometrical functions with different forms.
  89. solve ({a*sin(x+1) + b*cos(x+2)},{x});
  90. % Undetermined exponents.
  91. solve({x^a - 2},{x});
  92. % Example taken from M.L. Griss, ACM Trans. Math. Softw. 2 (1976) 1.
  93. e1 := x1 - l/(3*k)$
  94. e2 := x2 - 1$
  95. e3 := x3 - 35*b6/(6*l)*x4 + 33*b11/(2*l)*x6 - 715*b15/(14*l)*x8$
  96. e4 := 14*k/(3*l)*x1 - 7*b4/(2*l)*x3 + x4$
  97. e5 := x5 - 891*b11/(40*l)*x6 +3861*b15/(56*l)*x8$
  98. e6 := -88*k/(15*l)*x1 + 22*b4/(5*l)*x3 - 99*b9/(8*l)*x5 +x6$
  99. e7 := -768*k/(5005*b13)*x1 + 576*b4/(5005*b13)*x3 -
  100. 324*b9/(1001*b13)*x5 + x7 - 16*l/(715*b13)*x8$
  101. e8 := 7*l/(143*b15)*x1 + 49*b6/(429*b15)*x4 - 21*b11/(65*b15)*x6 +
  102. x8 - 7*b2/(143*b15)$
  103. solve({e1,e2,e3,e4,e5,e6,e7,e8},{x1,x2,x3,x4,x5,x6,x7,x8});
  104. f1 := x1 - x*x2 - y*x3 + 1/2*x**2*x4 + x*y*x5 + 1/2*y**2*x6 +
  105. 1/6*x**3*x7 + 1/2*x*y*(x - y)*x8 - 1/6*y**3*x9$
  106. f2 := x1 - y*x3 + 1/2*y**2*x6 - 1/6*y**3*x9$
  107. f3 := x1 + y*x2 - y*x3 + 1/2*y**2*x4 - y**2*x5 + 1/2*y**2*x6 +
  108. 1/6*y**3*x7 + 1/2*y**3*x8 - 1/6*y**3*x9$
  109. f4 := x1 + (1 - x)*x2 - x*x3 + 1/2*(1 - x)**2*x4 - y*(1 - x)*x5 +
  110. 1/2*y**2*x6 + 1/6*(1 - x)**3*x7 + 1/2*y*(1 - x - y)*(1 - x)*x8
  111. - 1/6*y**3*x9$
  112. f5 := x1 + (1 - x - y)*x2 + 1/2*(1 - x - y)**2*x4 +
  113. 1/6*(1 - x - y)**3*x7$
  114. f6 := x1 + (1 - x - y)*x3 + 1/2*(1 - x - y)*x6 +
  115. 1/6*(1 - x - y)**3*x9$
  116. f7 := x1 - x*x2 + (1 - y)*x3 + 1/2*x*x4 - x*(1 - y)*x5 +
  117. 1/2*(1 - y)**2*x6 - 1/6*x**3*x7 + 1/2*x*(1 - y)*(1 - y + x)*x8
  118. + 1/6*(1-y)**3*x9$
  119. f8 := x1 - x*x2 + x*x3 + 1/2*x**2*x4 - x**2*x5 + 1/2*x**2*x6 +
  120. 1/6*x**3*x7 - 1/2*x**3*x8 + 1/6*x**3*x9$
  121. f9 := x1 - x*x2 + 1/2*x**2*x4 + 1/6*x**3*x7$
  122. solve({f1,f2,f3,f4,f5,f6,f7,f8,f9},{x1,x2,x3,x4,x5,x6,x7,x8,x9});
  123. solve({f1 - 1,f2,f3,f4,f5,f6,f7,f8,f9},{x1,x2,x3,x4,x5,x6,x7,x8,x9});
  124. % The following examples were discussed in Char, B.W., Fee, G.J.,
  125. % Geddes, K.O., Gonnet, G.H., Monagan, M.B., Watt, S.M., "On the
  126. % Design and Performance of the Maple System", Proc. 1984 Macsyma
  127. % Users' Conference, G.E., Schenectady, NY, 1984, 199-219.
  128. % Problem 1.
  129. solve({ -22319*x0+25032*x1-83247*x2+67973*x3+54189*x4
  130. -67793*x5+81135*x6+22293*x7+27327*x8+96599*x9-15144,
  131. 79815*x0+37299*x1-28495*x2-52463*x3+25708*x4 -55333*x5-
  132. 2742*x6+83127*x7-29417*x8-43202*x9+93314, -29065*x0-77803*x1-
  133. 49717*x2-64748*x3-68324*x4 -50162*x5-64222*x6-
  134. 4716*x7+30737*x8+22971*x9+90348, 62470*x0+59658*x1-
  135. 46120*x2+58376*x3-28208*x4 -74506*x5+28491*x6+21099*x7+29149*x8-
  136. 20387*x9+36254, -98233*x0-26263*x1-63227*x2+34307*x3+92294*x4
  137. +10148*x5+3192*x6+24044*x7-83764*x8-1121*x9+13871,
  138. -20427*x0+62666*x1+27330*x2-78670*x3+9036*x4 +56024*x5-4525*x6-
  139. 50589*x7-62127*x8-32846*x9+38466,
  140. -85609*x0+5424*x1+86992*x2+59651*x3-60859*x4 -55984*x5-
  141. 6061*x6+44417*x7+92421*x8+6701*x9-9459,
  142. -68255*x0+19652*x1+92650*x2-93032*x3-30191*x4 -31075*x5-
  143. 89060*x6+12150*x7-78089*x8-12462*x9+1027, 55526*x0-
  144. 91202*x1+91329*x2-25919*x3-98215*x4 +30554*x5+913*x6-
  145. 35751*x7+17948*x8-58850*x9+66583, 40612*x0+84364*x1-
  146. 83317*x2+10658*x3+37213*x4 +50489*x5+72040*x6-
  147. 21227*x7+60772*x8+95114*x9-68533});
  148. solve({ -22319*x0+25032*x1-83247*x2+67973*x3+54189*x4
  149. -67793*x5+81135*x6+22293*x7+27327*x8+96599*x9-15144,
  150. 79815*x0+37299*x1-28495*x2-52463*x3+25708*x4 -55333*x5-
  151. 2742*x6+83127*x7-29417*x8-43202*x9+93314, -29065*x0-77803*x1-
  152. 49717*x2-64748*x3-68324*x4 -50162*x5-64222*x6-
  153. 4716*x7+30737*x8+22971*x9+90348, 62470*x0+59658*x1-
  154. 46120*x2+58376*x3-28208*x4-74506*x5+28491*x6+21099*x7+29149*x8-
  155. 20387*x9+36254,-98233*x0-26263*x1-63227*x2+34307*x3+92294*x4
  156. +10148*x5+3192*x6+24044*x7-83764*x8-1121*x9+13871,
  157. -20427*x0+62666*x1+27330*x2-78670*x3+9036*x4 +56024*x5-4525*x6-
  158. 50589*x7-62127*x8-32846*x9+38466,
  159. -85609*x0+5424*x1+86992*x2+59651*x3-60859*x4 -55984*x5-
  160. 6061*x6+44417*x7+92421*x8+6701*x9-9459,
  161. -68255*x0+19652*x1+92650*x2-93032*x3-30191*x4 -31075*x5-
  162. 89060*x6+12150*x7-78089*x8-12462*x9+1027, 55526*x0-
  163. 91202*x1+91329*x2-25919*x3-98215*x4 +30554*x5+913*x6-
  164. 35751*x7+17948*x8-58850*x9+66583, 40612*x0+84364*x1-
  165. 83317*x2+10658*x3+37213*x4 +50489*x5+72040*x6-
  166. 21227*x7+60772*x8+95114*x9-68533});
  167. % The next two problems give the current routines some trouble and
  168. % have therefore been commented out.
  169. % Problem 2.
  170. comment
  171. solve({ 81*x30-96*x21-45, -36*x4+59*x29+26,
  172. -59*x26+5*x3-33, -81*x19-92*x23-21*x17-9, -46*x29-
  173. 13*x22+22*x24+83, 47*x4-47*x14-15*x26-40, 83*x30+70*x17+56*x10-
  174. 31, 10*x27-90*x9+52*x21+52, -33*x20-97*x26+20*x6-76,
  175. 97*x16+41*x8-13*x12+66, 16*x16-52*x10-73*x28+49, -28*x1-53*x24-
  176. x27-67, -22*x26-29*x24+73*x10+8, 88*x18+61*x19-98*x9-55, 99*x28-
  177. 91*x26+26*x21-95, -6*x18+25*x7-77*x2+99, 28*x13-50*x17-52*x14-64,
  178. -50*x20+26*x11+93*x2+77, -70*x8+74*x19-94*x26+86, -18*x18-2*x16-
  179. 79*x23+91, 36*x26-13*x11-53*x25-5, 10*x7+57*x16-85*x10-14,
  180. -3*x27+44*x4+52*x22-1, 21*x11+20*x25-30*x4-83, 70*x2-97*x19-
  181. 41*x26-50, -51*x8+95*x12-85*x26+45, 83*x30+41*x12+50*x2+53,
  182. -4*x26+69*x8-58*x5-95, 59*x27-78*x30-66*x23+16, -10*x20-36*x11-
  183. 60*x1-59});
  184. % Problem 3.
  185. comment
  186. solve({ 115*x40+566*x41-378*x42+11401086415/6899901,
  187. 560*x0-45*x1-506*x2-11143386403/8309444, -621*x1-
  188. 328*x2+384*x3+1041841/64675, -856*x2+54*x3+869*x4-41430291/24700,
  189. 596*x3-608*x4-560*x5-10773384/11075,
  190. -61*x4+444*x5+924*x6+4185100079/11278780, 67*x5-95*x6-
  191. 682*x7+903866812/6618863, 196*x6+926*x7-930*x8-
  192. 2051864151/2031976, -302*x7-311*x8-890*x9-14210414139/27719792,
  193. 121*x8-781*x9-125*x10-4747129093/39901584, 10*x9+555*x10-
  194. 912*x11+32476047/3471829, -151*x38+732*x39-
  195. 397*x40+327281689/173242, 913*x10-259*x11-982*x12-
  196. 18080663/5014020, 305*x11+9*x12-357*x13+1500752933/1780680,
  197. 179*x12-588*x13+665*x14+8128189/51832, 406*x13+843*x14-
  198. 833*x15+201925713/97774, 107*x14+372*x15+505*x16-
  199. 5161192791/3486415, 720*x15-212*x16+607*x17-31529295571/7197760,
  200. 951*x16-685*x17+148*x18+1034546543/711104, -654*x17-
  201. 899*x18+543*x19+1942961717/1646560,
  202. -448*x18+673*x19+702*x20+856422818/1286375, 396*x19-
  203. 196*x20+218*x21-4386267866/21303625, -233*x20-796*x21-373*x22-
  204. 85246365829/57545250, 921*x21-368*x22+730*x23-
  205. 93446707622/51330363, -424*x22+378*x23+727*x24-
  206. 6673617931/3477462, -633*x23+565*x24-208*x25+8607636805/4092942,
  207. 971*x24+170*x25-865*x26-25224505/18354, 937*x25+333*x26-463*x27-
  208. 339307103/1025430, 494*x26-8*x27-50*x28+57395804/34695,
  209. 530*x27+631*x28-193*x29-8424597157/680022,
  210. -435*x28+252*x29+916*x30+196828511/19593, 327*x29+403*x30-
  211. 845*x31+8458823325/5927971, 246*x30+881*x31-
  212. 394*x32+13624765321/156546826, 946*x31+169*x32-43*x33-
  213. 53594199271/126093183, -146*x32+503*x33-
  214. 363*x34+66802797635/15234909, -132*x33-
  215. 686*x34+376*x35+8167530636/902635, -38*x34-188*x35-
  216. 583*x36+1814153743/1124240, 389*x35+562*x36-688*x37-
  217. 12251043951/5513560, -769*x37-474*x38-89*x39-2725415872/1235019,
  218. -625*x36-122*x37+468*x38+7725682775/4506736,
  219. 839*x39+936*x40+703*x41+1912091857/1000749,
  220. -314*x41+102*x42+790*x43+7290073150/8132873, -905*x42-
  221. 454*x43+524*x44-10110944527/4538233, 379*x43+518*x44-328*x45-
  222. 2071620692/519645, 284*x44-979*x45+690*x46-915987532/16665,
  223. 198*x45-650*x46-763*x47+548801657/11220, 974*x46+12*x47+410*x48-
  224. 3831097561/51051, -498*x47-135*x48-230*x49-18920705/9282,
  225. 665*x48+156*x49+34*x0-27714736/156585, -519*x49-366*x0-730*x1-
  226. 2958446681/798985});
  227. % Problem 4.
  228. % This one needs the Cramer code --- it takes forever otherwise.
  229. on cramer;
  230. solve({ -b*k8/a+c*k8/a, -b*k11/a+c*k11/a,
  231. -b*k10/a+c*k10/a+k2,
  232. -k3-b*k9/a+c*k9/a, -b*k14/a+c*k14/a, -b*k15/a+c*k15/a,
  233. -b*k18/a+c*k18/a-k2, -b*k17/a+c*k17/a, -b*k16/a+c*k16/a+k4,
  234. -b*k13/a+c*k13/a-b*k21/a+c*k21/a+b*k5/a-c*k5/a,
  235. b*k44/a-c*k44/a, -b*k45/a+c*k45/a, -b*k20/a+c*k20/a,
  236. -b*k44/a+c*k44/a, b*k46/a-c*k46/a,
  237. b**2*k47/a**2-2*b*c*k47/a**2+c**2*k47/a**2,
  238. k3, -k4, -b*k12/a+c*k12/a-a*k6/b+c*k6/b,
  239. -b*k19/a+c*k19/a+a*k7/c-b*k7/c, b*k45/a-c*k45/a,
  240. -b*k46/a+c*k46/a, -k48+c*k48/a+c*k48/b-c**2*k48/(a*b),
  241. -k49+b*k49/a+b*k49/c-b**2*k49/(a*c), a*k1/b-c*k1/b,
  242. a*k4/b-c*k4/b, a*k3/b-c*k3/b+k9, -k10+a*k2/b-c*k2/b,
  243. a*k7/b-c*k7/b, -k9, k11, b*k12/a-c*k12/a+a*k6/b-c*k6/b,
  244. a*k15/b-c*k15/b, k10+a*k18/b-c*k18/b,
  245. -k11+a*k17/b-c*k17/b, a*k16/b-c*k16/b,
  246. -a*k13/b+c*k13/b+a*k21/b-c*k21/b+a*k5/b-c*k5/b,
  247. -a*k44/b+c*k44/b, a*k45/b-c*k45/b,
  248. a*k14/c-b*k14/c+a*k20/b-c*k20/b, a*k44/b-c*k44/b,
  249. -a*k46/b+c*k46/b, -k47+c*k47/a+c*k47/b-c**2*k47/(a*b),
  250. a*k19/b-c*k19/b, -a*k45/b+c*k45/b, a*k46/b-c*k46/b,
  251. a**2*k48/b**2-2*a*c*k48/b**2+c**2*k48/b**2,
  252. -k49+a*k49/b+a*k49/c-a**2*k49/(b*c), k16, -k17,
  253. -a*k1/c+b*k1/c, -k16-a*k4/c+b*k4/c, -a*k3/c+b*k3/c,
  254. k18-a*k2/c+b*k2/c, b*k19/a-c*k19/a-a*k7/c+b*k7/c,
  255. -a*k6/c+b*k6/c, -a*k8/c+b*k8/c, -a*k11/c+b*k11/c+k17,
  256. -a*k10/c+b*k10/c-k18, -a*k9/c+b*k9/c,
  257. -a*k14/c+b*k14/c-a*k20/b+c*k20/b,
  258. -a*k13/c+b*k13/c+a*k21/c-b*k21/c-a*k5/c+b*k5/c,
  259. a*k44/c-b*k44/c, -a*k45/c+b*k45/c, -a*k44/c+b*k44/c,
  260. a*k46/c-b*k46/c, -k47+b*k47/a+b*k47/c-b**2*k47/(a*c),
  261. -a*k12/c+b*k12/c, a*k45/c-b*k45/c, -a*k46/c+b*k46/c,
  262. -k48+a*k48/b+a*k48/c-a**2*k48/(b*c),
  263. a**2*k49/c**2-2*a*b*k49/c**2+b**2*k49/c**2, k8, k11, -k15,
  264. k10-k18, -k17, k9, -k16, -k29, k14-k32, -k21+k23-k31,
  265. -k24-k30, -k35, k44, -k45, k36, k13-k23+k39, -k20+k38,
  266. k25+k37, b*k26/a-c*k26/a-k34+k42, -2*k44, k45, k46,
  267. b*k47/a-c*k47/a, k41, k44, -k46, -b*k47/a+c*k47/a,
  268. k12+k24, -k19-k25, -a*k27/b+c*k27/b-k33, k45, -k46,
  269. -a*k48/b+c*k48/b, a*k28/c-b*k28/c+k40, -k45, k46,
  270. a*k48/b-c*k48/b, a*k49/c-b*k49/c, -a*k49/c+b*k49/c,
  271. -k1, -k4, -k3, k15, k18-k2, k17, k16, k22, k25-k7,
  272. k24+k30, k21+k23-k31, k28, -k44, k45, -k30-k6, k20+k32,
  273. k27+b*k33/a-c*k33/a, k44, -k46, -b*k47/a+c*k47/a, -k36,
  274. k31-k39-k5, -k32-k38, k19-k37, k26-a*k34/b+c*k34/b-k42,
  275. k44, -2*k45, k46, a*k48/b-c*k48/b, a*k35/c-b*k35/c-k41,
  276. -k44, k46, b*k47/a-c*k47/a, -a*k49/c+b*k49/c, -k40, k45,
  277. -k46, -a*k48/b+c*k48/b, a*k49/c-b*k49/c, k1, k4, k3, -k8,
  278. -k11, -k10+k2, -k9, k37+k7, -k14-k38, -k22, -k25-k37, -k24+k6,
  279. -k13-k23+k39, -k28+b*k40/a-c*k40/a, k44, -k45, -k27, -k44,
  280. k46, b*k47/a-c*k47/a, k29, k32+k38, k31-k39+k5, -k12+k30,
  281. k35-a*k41/b+c*k41/b, -k44, k45, -k26+k34+a*k42/c-b*k42/c,
  282. k44, k45, -2*k46, -b*k47/a+c*k47/a, -a*k48/b+c*k48/b,
  283. a*k49/c-b*k49/c, k33, -k45, k46, a*k48/b-c*k48/b,
  284. -a*k49/c+b*k49/c },
  285. {k1, k2, k3, k4, k5, k6, k7, k8, k9, k10, k11, k12, k13, k14,
  286. k15, k16, k17, k18, k19, k20, k21, k22, k23, k24, k25, k26,
  287. k27, k28, k29, k30, k31, k32, k33, k34, k35, k36, k37, k38,
  288. k39, k40, k41, k42, k43, k44, k45, k46, k47, k48, k49});
  289. off cramer;
  290. % Problem 5.
  291. solve ({2*a3*b3+a5*b3+a3*b5, a5*b3+2*a5*b5+a3*b5,
  292. a5*b5, a2*b2, a4*b4, a5*b1+b5+a4*b3+a3*b4,
  293. a5*b3+a5*b5+a3*b5+a3*b3, a0*b2+b2+a4*b2+a2*b4+c2+a2*b0+a2*b1,
  294. a0*b0+a0*b1+a0*b4+a3*b2+b0+b1+b4+a4*b0+a4*b1+a2*b5+a4*b4+c1+c4
  295. +a5*b2+a2*b3+c0,
  296. -1+a3*b0+a0*b3+a0*b5+a5*b0+b3+b5+a5*b4+a4*b3+a4*b5+a3*b4+a5*b1
  297. +a3*b1+c3+c5,
  298. b4+a4*b1, a5*b3+a3*b5, a2*b1+b2, a4*b5+a5*b4, a2*b4+a4*b2,
  299. a0*b5+a5*b0+a3*b4+2*a5*b4+a5*b1+b5+a4*b3+2*a4*b5+c5,
  300. a4*b0+2*a4*b4+a2*b5+b4+a4*b1+a5*b2+a0*b4+c4,
  301. c3+a0*b3+2*b3+b5+a4*b3+a3*b0+2*a3*b1+a5*b1+a3*b4,
  302. c1+a0*b1+2*b1+a4*b1+a2*b3+b0+a3*b2+b4});
  303. % Problem 6.
  304. solve({2*a3*b3+a5*b3+a3*b5, a5*b3+2*a5*b5+a3*b5,
  305. a4*b4, a5*b3+a5*b5+a3*b5+a3*b3, b1, a3*b3, a2*b2, a5*b5,
  306. a5*b1+b5+a4*b3+a3*b4, a0*b2+b2+a4*b2+a2*b4+c2+a2*b0+a2*b1,
  307. b4+a4*b1, b3+a3*b1, a5*b3+a3*b5, a2*b1+b2, a4*b5+a5*b4,
  308. a2*b4+a4*b2, a0*b0+a0*b1+a0*b4+a3*b2+b0+b1+b4+a4*b0+a4*b1
  309. +a2*b5+a4*b4+c1+c4+a5*b2+a2*b3+c0,-1+a3*b0+a0*b3+a0*b5+a5*b0
  310. +b3+b5+a5*b4+a4*b3+a4*b5+a3*b4+a5*b1+a3*b1+c3+c5,
  311. a0*b5+a5*b0+a3*b4+2*a5*b4+a5*b1+b5+a4*b3+2*a4*b5+c5,
  312. a4*b0+2*a4*b4+a2*b5+b4+a4*b1+a5*b2+a0*b4+c4,
  313. c3+a0*b3+2*b3+b5+a4*b3+a3*b0+2*a3*b1+a5*b1+a3*b4,
  314. c1+a0*b1+2*b1+a4*b1+a2*b3+b0+a3*b2+b4});
  315. % Example cited by Bruno Buchberger
  316. % in R.Janssen: Trends in Computer Algebra,
  317. % Springer, 1987
  318. % Geometry of a simple robot,
  319. % l1,l2 length of arms
  320. % ci,si cos and sin of rotation angles
  321. solve( { c1*c2 -cf*ct*cp + sf*sp,
  322. s1*c2 - sf*ct*cp - cf*sp,
  323. s2 + st*cp,
  324. -c1*s2 - cf*ct*sp + sf*cp,
  325. -s1*s2 + sf*ct*sp - cf*cp,
  326. c2 - st*sp,
  327. s1 - cf*st,
  328. -c1 - sf*st,
  329. ct,
  330. l2*c1*c2 - px,
  331. l2*s1*c2 - py,
  332. l2*s2 + l1 - pz,
  333. c1**2 + s1**2 -1,
  334. c2**2 + s2**2 -1,
  335. cf**2 + sf**2 -1,
  336. ct**2 + st**2 -1,
  337. cp**2 + sp**2 -1},
  338. {c1,c2,s1,s2,py,cf,ct,cp,sf,st,sp});
  339. % Steady state computation of a prototypical chemical
  340. % reaction network (the "Edelstein" network)
  341. solve(
  342. { alpha * c1 - beta * c1**2 - gamma*c1*c2 + epsilon*c3,
  343. -gamma*c1*c2 + (epsilon+theta)*c3 -eta *c2,
  344. gamma*c1*c2 + eta*c2 - (epsilon+theta) * c3},
  345. {c3,c2,c1});
  346. solve(
  347. {( - 81*y1**2*y2**2 + 594*y1**2*y2 - 225*y1**2 + 594*y1*y2**2 - 3492*
  348. y1*y2 - 750*y1 - 225*y2**2 - 750*y2 + 14575)/81,
  349. ( - 81*y2**2*y3**2 + 594*y2**2*y3 - 225*y2**2 + 594*y2*y3**2 - 3492*
  350. y2*y3 - 750*y2 - 225*y3**2 - 750*y3 + 14575)/81,
  351. ( - 81*y1**2*y3**2 + 594*y1**2*y3 - 225*y1**2 + 594*y1*y3**2 - 3492*
  352. y1*y3 - 750*y1 - 225*y3**2 - 750*y3 + 14575)/81,
  353. (2*(81*y1**2*y2**2*y3 + 81*y1**2*y2*y3**2 - 594*y1**2*y2*y3 - 225*y1
  354. **2*y2 - 225*y1**2*y3 + 1650*y1**2 + 81*y1*y2**2*y3**2 - 594*y1*
  355. y2**2*y3 - 225*y1*y2**2 - 594*y1*y2*y3**2 + 2592*y1*y2*y3 + 2550
  356. *y1*y2 - 225*y1*y3**2 + 2550*y1*y3 - 3575*y1 - 225*y2**2*y3 +
  357. 1650*y2**2 - 225*y2*y3**2 + 2550*y2*y3 - 3575*y2 + 1650*y3**2 -
  358. 3575*y3 - 30250))/81}, {y1,y2,y3,y4});
  359. % Another nice nonlinear system.
  360. solve({y=x+t^2,x=y+u^2},{x,y,u,t});
  361. % Example from Stan Kameny (relation between Gamma function values)
  362. % containing surds in the coefficients.
  363. solve({x54=x14/4,x54*x34=sqrt pi/sqrt 2*x32,x32=x12/2,
  364. x12=sqrt pi, x14*x34=pi*sqrt 2});
  365. % A system given by J. Hietarinta with complex coefficients.
  366. on complex;
  367. apu := {2*a - a6,2*b*c3 - 1,i - 2*x + 1,2*x**2 - 2*x + 1,n1 + 1}$
  368. solve apu;
  369. clear apu;
  370. off complex;
  371. % More examples that can now be solved.
  372. solve({e^(x+y)-1,x-y},{x,y});
  373. solve({e^(x+y)+sin x,x-y},{x,y}); % no algebraic solution exists.
  374. solve({e^(x+y)-1,x-y**2},{x,y});
  375. solve(e^(y^2) * e^y -1,y);
  376. solve(e^(y^2 +y)-1,y);
  377. solve(e^(y^2)-1,y);
  378. solve(e^(y^2+1)-1,y);
  379. solve({e^(x+y+z)-1,x-y**2=1,x**2-z=2},{x,y,z});
  380. solve(e^(y^4+3y^2+y)-1,y);
  381. % Transcendental equations proposed by Roger Germundsson
  382. % <roger@isy.liu.se>
  383. eq1 := 2*asin(x) + asin(2*x) - PI/2;
  384. eq2 := 2*asin(x) - acos(3*x);
  385. eq3 := acos(x) - atan(x);
  386. eq4 := acos(2*x**2 - 4*x -x) - 2*asin(x);
  387. eq5 := 2*atan(x) - atan( 2*x/(1-x**2) );
  388. sol1 := solve(eq1,x);
  389. sol2 := solve(eq2,x);
  390. sol3 := solve(eq3,x);
  391. sol4 := solve(eq4,x);
  392. sol5 := solve(eq5,x); % This solution should be the open interval
  393. % (-1,1).
  394. % Example 52 of M. Wester: the function has no real zero although
  395. % REDUCE 3.5 and Maple tend to return 3/4.
  396. if solve(sqrt(x^2 +1) - x +2,x) neq {} then rederr "Illegal result";
  397. % Using a root_of expression as an algebraic number.
  398. solve(x^5 - x - 1,x);
  399. w:=rhs first ws;
  400. w^5;
  401. w^5-w;
  402. clear w;
  403. end;