Windows installer: Update help text for the maxima_longnames program.
[maxima/cygwin.git] / tests / rtest16.mac
blob0a8f0d2dbb3aa5785258b997e143dcec1da6e192
1 (kill (all), values);
2 [];
4 /* make sure things work after a reset().  ID: 1986726 and ID: 2787047
5  *
6  * display2d is a resetable option variable. We save the value of display2d
7  * and restore it after the reset. This allows to run the testsuite in both
8  * display modes.
9  */
10 (save:display2d, done);
11 done$
12 (reset(),0);
14 (display2d:save, done);
15 done$
17 /* From A. Reiner.  Fixed in buildq.lisp rev. 1.4.
18    Exposed a bug caused by the dynamical scope of VARLIST. */
19 buildq([foo:sin(baz+bar)],1);
22 buildq([foo:[sin(baz+bar),sin(baz-bar)]],+splice(foo));
23 sin(baz+bar)+sin(baz-bar)$
25 /* Verify that extended functionality of rhs/lhs works as advertised */
27 (kill (x, y, aa, bb, cc), infix("@@"), 0);
30 map (lhs, [aa < bb, aa <= bb, aa = bb, aa # bb, equal (aa, bb), notequal (aa, bb), aa >= bb, aa > bb]);
31 [aa, aa, aa, aa, aa, aa, aa, aa];
33 map (rhs, [aa < bb, aa <= bb, aa = bb, aa # bb, equal (aa, bb), notequal (aa, bb), aa >= bb, aa > bb]);
34 [bb, bb, bb, bb, bb, bb, bb, bb];
36 map (lhs, [foo(x) := 2*x, bar(y) ::= 3*y, '(aa : bb), '(aa :: bb), ?marrow(aa, bb)]);
37 ['(foo(x)), '(bar(y)), aa, aa, aa];
39 map (rhs, [foo(x) := 2*x, bar(y) ::= 3*y, '(aa : bb), '(aa :: bb), ?marrow(aa, bb)]);
40 [2*x, 3*y, bb, bb, bb];
42 [lhs (aa @@ bb), lhs (aa @@ bb @@ cc), rhs (aa @@ bb), rhs (aa @@ bb @@ cc)];
43 [aa, aa @@ bb, bb, cc];
45 map (lhs, [aa + bb, aa - bb, aa * bb, aa / bb, sin(aa), log(aa)]);
46 [aa + bb, aa - bb, aa * bb, aa / bb, sin(aa), log(aa)];
48 map (rhs, [aa + bb, aa - bb, aa * bb, aa / bb, sin(aa), log(aa)]);
49 [0, 0, 0, 0, 0, 0];
51 kill ("@@");
52 done;
54 /* Verify that grind treats nouns correctly. string calls MSIZE in src/grind.lisp.
55  */
57 kill (all);
58 done;
60 string ('(integrate(f(x), x) + integrate(g(x), x, minf, inf) + diff(u, x) + sum(h(x), x, 1, n)));
61 "sum(h(x),x,1,n)+integrate(g(x),x,minf,inf)+integrate(f(x),x)+diff(u,x)";
63 string ('integrate(f(x), x) + 'integrate(g(x), x, minf, inf) + 'diff(u, x) + 'sum(h(x), x, 1, n));
64 "'sum(h(x),x,1,n)+'integrate(g(x),x,minf,inf)+'integrate(f(x),x)+'diff(u,x,1)";
66 /* GREAT puts nounified atoms before others, it appears ... */
67 string (%a%a + %b%b + nounify(%c%c) + nounify(%d%d) + %e%e + %f%f);
68 "%d%d+%c%c+%f%f+%e%e+%b%b+%a%a";
70 string (sin(x) * cos(x) + tan(x));
71 "tan(x)+cos(x)*sin(x)";
73 string ('foo(x, y, z) / bar(a, b, c) + 'baz(%pi - 'quux(%e ^ mumble(%i))));
74 "'foo(x,y,z)/bar(a,b,c)+'baz(%pi-'quux(%e^mumble(%i)))";
76 /* It's conceivable that someday nounified arithmetic operators would be treated differently by grind.
77  * If/when that happens, revise this example accordingly.
78  */
79 string ('"+"(a, b, '"."(c, d), '"^"(e, f)));
80 "'?mplus(a,b,'?mnctimes(c,d),'?mexpt(e,f))";
82 /* Bug 626721 */
83 logarc(atan2(y,x));
84 -%i*log((%i*y+x)/sqrt(x^2+y^2));
85 rectform(ev(%,x=-1,y=1));
86 3*%pi/4; 
89  * Bug [ 1661490 ] An integral gives a wrong result.
90  */
91 (assume(a>0, b>0, sqrt(sqrt(b^2+a^2)-a)*(sqrt(b^2+a^2)+a)^(3/2)-b^2>0),0);
93 radcan(integrate(exp(-(a+%i*b)*x^2),x,minf,inf)/(sqrt(%pi)/sqrt(a+%i*b)));
97  * [ 1663704 ] integrate(sin(r*x)^7/x^4,x,0,inf) -> r^3*false
98  *
99  * Should return the integral instead of producing false.
100  */
101 integrate(sin(a*x)^7/x^4,x,0,inf);
102 'integrate(sin(a*x)^7/x^4,x,0,inf);
104 /* we have assumed a>0 */
105 integrate(%e^(-a*r)*sin(k*r),r,0,inf);
106 k/(k^2+a^2);
109  * Bug [ 1854888 ] hgfred([5],[5], 1) doesn't simplify
110  */
111 hgfred([5],[5],1);
115  * Bug [ 1858964 ] hgfred([7],[-1], x) --/--> error
116  */
117 hgfred([7],[-1],x);
118 und;
121  * Bug [ 1858939 ] hgfred([-1],[-2],x) --> error
122  */
123 hgfred([-1],[-2],x);
124 /* Because of revision 1.110 of hyp.lisp gen_laguerre simplifies
125    -gen_laguerre(1,-3,x)/2; */
126 1+x/2;
129  * Tests for the :: operator
130  */
131 a:b;
134 a::3;
140 p:concat('p,1);
143 p::5;
149 kill(all);
150 done$
152 /* Bug [ 1860250 ] erf(-inf) --> -erf(inf) */
154 erf(-inf);
157 erf(inf);
160 erf(-x) + erf(x);
163 erf(a-b) + erf(b-a);
166 /* Bug [ 1950653 ] bessel_j not simplified 
167  * A few additional related tests added too.
168  */
170 bessel_j(1/2,%pi),besselexpand:true;
172 bessel_y(1/2,%pi/2),besselexpand:true;
175 /* Bug [ 2149714 ] fpprintprec does not work correctly
178 fpprec:16;
181 block([fpprintprec:5], string(1.23b0));
182 "1.23b0";
184 block([fpprintprec:5], string(1.2345b0));
185 "1.2345b0";
187 block([fpprintprec:5], string(1.23456789b0));
188 "1.2346b0";
190 block([fpprintprec:25], string(1.2345678901234567890123456789b0));
191 "1.234567890123457b0";
193 /* verify that fpprintprec behavior matches its description */
195 block ([L1 : [["1.2E-10","1.2E-9","1.2E-8","1.2E-7","1.2E-6","1.2E-5","1.2E-4","0.0012","0.012","0.12","1.2","1.2E+1","1.2E+2",
196   "1.2E+3","1.2E+4","1.2E+5","1.2E+6","1.2E+7","1.2E+8","1.2E+9","1.2E+10"],
197  ["1.23E-10","1.23E-9","1.23E-8","1.23E-7","1.23E-6","1.23E-5","1.23E-4","0.00123","0.0123","0.123","1.23","12.3",
198   "1.23E+2","1.23E+3","1.23E+4","1.23E+5","1.23E+6","1.23E+7","1.23E+8","1.23E+9","1.23E+10"],
199  ["1.234E-10","1.234E-9","1.234E-8","1.234E-7","1.234E-6","1.234E-5","1.234E-4","0.001234","0.01234","0.1234","1.234",
200   "12.34","123.4","1.234E+3","1.234E+4","1.234E+5","1.234E+6","1.234E+7","1.234E+8","1.234E+9","1.234E+10"],
201  ["1.2344E-10","1.2344E-9","1.2344E-8","1.2344E-7","1.2344E-6","1.2344E-5","1.2344E-4","0.0012344","0.012344",
202   "0.12344","1.2344","12.344","123.44","1234.4","1.2344E+4","1.2344E+5","1.2344E+6","1.2344E+7","1.2344E+8",
203   "1.2344E+9","1.2344E+10"],
204  ["1.23443E-10","1.23443E-9","1.23443E-8","1.23443E-7","1.23443E-6","1.23443E-5","1.23443E-4","0.00123443","0.0123443",
205   "0.123443","1.23443","12.3443","123.443","1234.43","12344.3","1.23443E+5","1.23443E+6","1.23443E+7","1.23443E+8",
206   "1.23443E+9","1.23443E+10"],
207  ["1.234432E-10","1.234432E-9","1.234432E-8","1.234432E-7","1.234432E-6","1.234432E-5","1.234432E-4","0.001234432",
208   "0.01234432","0.1234432","1.234432","12.34432","123.4432","1234.432","12344.32","123443.2","1.234432E+6",
209   "1.234432E+7","1.234432E+8","1.234432E+9","1.234432E+10"],
210  ["1.2344321E-10","1.2344321E-9","1.2344321E-8","1.2344321E-7","1.2344321E-6","1.2344321E-5","1.2344321E-4",
211   "0.0012344321","0.012344321","0.12344321","1.2344321","12.344321","123.44321","1234.4321","12344.321","123443.21",
212   "1234432.1","1.2344321E+7","1.2344321E+8","1.2344321E+9","1.2344321E+10"],
213  ["1.23443211E-10","1.23443211E-9","1.23443211E-8","1.23443211E-7","1.23443211E-6","1.23443211E-5","1.23443211E-4",
214   "0.00123443211","0.0123443211","0.123443211","1.23443211","12.3443211","123.443211","1234.43211","12344.3211",
215   "123443.211","1234432.11","1.23443211E+7","1.23443211E+8","1.23443211E+9","1.23443211E+10"],
216  ["1.234432112E-10","1.234432112E-9","1.234432112E-8","1.234432112E-7","1.234432112E-6","1.234432112E-5",
217   "1.234432112E-4","0.001234432112","0.01234432112","0.1234432112","1.234432112","12.34432112","123.4432112",
218   "1234.432112","12344.32112","123443.2112","1234432.112","1.234432112E+7","1.234432112E+8","1.234432112E+9",
219   "1.234432112E+10"],
220  ["1.2344321123E-10","1.2344321123E-9","1.2344321123E-8","1.2344321123E-7","1.2344321123E-6","1.2344321123E-5",
221   "1.2344321123E-4","0.0012344321123","0.012344321123","0.12344321123","1.2344321123","12.344321123","123.44321123",
222   "1234.4321123","12344.321123","123443.21123","1234432.1123","1.2344321123E+7","1.2344321123E+8","1.2344321123E+9",
223   "1.2344321123E+10"],
224  ["1.23443211234E-10","1.23443211234E-9","1.23443211234E-8","1.23443211234E-7","1.23443211234E-6","1.23443211234E-5",
225   "1.23443211234E-4","0.00123443211234","0.0123443211234","0.123443211234","1.23443211234","12.3443211234",
226   "123.443211234","1234.43211234","12344.3211234","123443.211234","1234432.11234","1.23443211234E+7",
227   "1.23443211234E+8","1.23443211234E+9","1.23443211234E+10"],
228  ["1.234432112344E-10","1.234432112344E-9","1.234432112344E-8","1.234432112344E-7","1.234432112344E-6",
229   "1.234432112344E-5","1.234432112344E-4","0.001234432112344","0.01234432112344","0.1234432112344","1.234432112344",
230   "12.34432112344","123.4432112344","1234.432112344","12344.32112344","123443.2112344","1234432.112344",
231   "1.234432112344E+7","1.234432112344E+8","1.234432112344E+9","1.234432112344E+10"],
232  ["1.2344321123443E-10","1.2344321123443E-9","1.2344321123443E-8","1.2344321123443E-7","1.2344321123443E-6",
233   "1.2344321123443E-5","1.2344321123443E-4","0.0012344321123443","0.012344321123443","0.12344321123443",
234   "1.2344321123443","12.344321123443","123.44321123443","1234.4321123443","12344.321123443","123443.21123443",
235   "1234432.1123443","1.2344321123443E+7","1.2344321123443E+8","1.2344321123443E+9","1.2344321123443E+10"],
236  ["1.23443211234432E-10","1.23443211234432E-9","1.23443211234432E-8","1.23443211234432E-7","1.23443211234432E-6",
237   "1.23443211234432E-5","1.23443211234432E-4","0.00123443211234432","0.0123443211234432","0.123443211234432",
238   "1.23443211234432","12.3443211234432","123.443211234432","1234.43211234432","12344.3211234432","123443.211234432",
239   "1234432.11234432","1.23443211234432E+7","1.23443211234432E+8","1.23443211234432E+9","1.23443211234432E+10"],
240  ["1.234432112344321E-10","1.234432112344321E-9","1.234432112344321E-8","1.234432112344321E-7","1.234432112344321E-6",
241   "1.234432112344321E-5","1.234432112344321E-4","0.001234432112344321","0.01234432112344321","0.1234432112344321",
242   "1.234432112344321","12.34432112344321","123.4432112344321","1234.432112344321","12344.32112344321",
243   "123443.2112344321","1234432.112344321","1.234432112344321E+7","1.234432112344321E+8","1.234432112344321E+9",
244   "1.234432112344321E+10"],
245  ["1.234432112344321E-10","1.234432112344321E-9","1.234432112344321E-8","1.234432112344321E-7","1.234432112344321E-6",
246   "1.234432112344321E-5","1.234432112344321E-4","0.001234432112344321","0.01234432112344321","0.1234432112344321",
247   "1.234432112344321","12.34432112344321","123.4432112344321","1234.432112344321","12344.32112344321",
248   "123443.2112344321","1234432.112344321","1.234432112344321E+7","1.234432112344321E+8","1.234432112344321E+9",
249   "1.234432112344321E+10"],
250  ["1.234432112344321E-10","1.234432112344321E-9","1.234432112344321E-8","1.234432112344321E-7","1.234432112344321E-6",
251   "1.234432112344321E-5","1.234432112344321E-4","0.001234432112344321","0.01234432112344321","0.1234432112344321",
252   "1.234432112344321","12.34432112344321","123.4432112344321","1234.432112344321","12344.32112344321",
253   "123443.2112344321","1234432.112344321","1.234432112344321E+7","1.234432112344321E+8","1.234432112344321E+9",
254   "1.234432112344321E+10"],
255  ["1.234432112344321E-10","1.234432112344321E-9","1.234432112344321E-8","1.234432112344321E-7","1.234432112344321E-6",
256   "1.234432112344321E-5","1.234432112344321E-4","0.001234432112344321","0.01234432112344321","0.1234432112344321",
257   "1.234432112344321","12.34432112344321","123.4432112344321","1234.432112344321","12344.32112344321",
258   "123443.2112344321","1234432.112344321","1.234432112344321E+7","1.234432112344321E+8","1.234432112344321E+9",
259   "1.234432112344321E+10"],
260  ["1.234432112344321E-10","1.234432112344321E-9","1.234432112344321E-8","1.234432112344321E-7","1.234432112344321E-6",
261   "1.234432112344321E-5","1.234432112344321E-4","0.001234432112344321","0.01234432112344321","0.1234432112344321",
262   "1.234432112344321","12.34432112344321","123.4432112344321","1234.432112344321","12344.32112344321",
263   "123443.2112344321","1234432.112344321","1.234432112344321E+7","1.234432112344321E+8","1.234432112344321E+9",
264   "1.234432112344321E+10"]],
265  L2 : block ([foo : 1.2344321123443211234],
266              makelist (block ([fpprintprec : m], makelist (string (foo*10^n), n, -10, 10)), m, 2, 20))],
267  map (lambda ([s1, s2], if sequalignore (s1, s2) then true else s2 # s1), flatten (L1), flatten (L2)),
268  delete (true, %%));
271 /* SF bug #3213: "fpprintprec do not round bfloat correctly." */
273 (reset (fpprec, bftrunc),
274  fpprintprec:4,
275  string (1.23456789b0));
276 "1.235b0";
278 /* default fpprintprec => print all digits */
280 (reset (fpprintprec), 0);
283 string (bfloat (1000000000000*(1 + 8/9)));
284 "1.888888888888889b12";
286 string (bfloat ((1 + 8/9)/1000000000000)), fpprec=50;
287 "1.8888888888888888888888888888888888888888888888889b-12";
289 string (bfloat (1000000000000*(1 + 8/9))), fpprec=10;
290 "1.888888889b12";
292 string (bfloat ((1 + 8/9)/1000000000000)), fpprec=2;
293 "1.9b-12";
295 /* expect to see bigfloat ending in 5 to round to even */
297 map (string, map (bfloat, 1 + [1, 2, 3, 4, 5, 6, 7]/8)), fpprintprec=3;
298 ["1.12b0", "1.25b0", "1.38b0", "1.5b0", "1.62b0", "1.75b0", "1.88b0"];
300 map (string, map (bfloat, 100 + makelist (i/64, i, 1, 63))), fpprintprec=8;
301 ["1.0001562b2", "1.0003125b2", "1.0004688b2", "1.000625b2", "1.0007812b2", "1.0009375b2", "1.0010938b2", "1.00125b2",
302  "1.0014062b2", "1.0015625b2", "1.0017188b2", "1.001875b2", "1.0020312b2", "1.0021875b2", "1.0023438b2", "1.0025b2",
303  "1.0026562b2", "1.0028125b2", "1.0029688b2", "1.003125b2", "1.0032812b2", "1.0034375b2", "1.0035938b2", "1.00375b2",
304  "1.0039062b2", "1.0040625b2", "1.0042188b2", "1.004375b2", "1.0045312b2", "1.0046875b2", "1.0048438b2", "1.005b2",
305  "1.0051562b2", "1.0053125b2", "1.0054688b2", "1.005625b2", "1.0057812b2", "1.0059375b2", "1.0060938b2", "1.00625b2",
306  "1.0064062b2", "1.0065625b2", "1.0067188b2", "1.006875b2", "1.0070312b2", "1.0071875b2", "1.0073438b2", "1.0075b2",
307  "1.0076562b2", "1.0078125b2", "1.0079688b2", "1.008125b2", "1.0082812b2", "1.0084375b2", "1.0085938b2", "1.00875b2",
308  "1.0089062b2", "1.0090625b2", "1.0092188b2", "1.009375b2", "1.0095312b2", "1.0096875b2", "1.0098438b2"];
310 /* bftrunc=false => don't strip trailing 0's */
312 map (string, map (bfloat, 1 + [1, 2, 3, 4, 5, 6, 7]/8)), fpprintprec=3, bftrunc=false;
313 ["1.12b0", "1.25b0", "1.38b0", "1.50b0", "1.62b0", "1.75b0", "1.88b0"];
315 map (string, map (bfloat, 100 + makelist (i/64, i, 1, 63))), fpprintprec=8, bftrunc=false;
316 ["1.0001562b2", "1.0003125b2", "1.0004688b2", "1.0006250b2", "1.0007812b2", "1.0009375b2", "1.0010938b2", "1.0012500b2",
317  "1.0014062b2", "1.0015625b2", "1.0017188b2", "1.0018750b2", "1.0020312b2", "1.0021875b2", "1.0023438b2", "1.0025000b2",
318  "1.0026562b2", "1.0028125b2", "1.0029688b2", "1.0031250b2", "1.0032812b2", "1.0034375b2", "1.0035938b2", "1.0037500b2",
319  "1.0039062b2", "1.0040625b2", "1.0042188b2", "1.0043750b2", "1.0045312b2", "1.0046875b2", "1.0048438b2", "1.0050000b2",
320  "1.0051562b2", "1.0053125b2", "1.0054688b2", "1.0056250b2", "1.0057812b2", "1.0059375b2", "1.0060938b2", "1.0062500b2",
321  "1.0064062b2", "1.0065625b2", "1.0067188b2", "1.0068750b2", "1.0070312b2", "1.0071875b2", "1.0073438b2", "1.0075000b2",
322  "1.0076562b2", "1.0078125b2", "1.0079688b2", "1.0081250b2", "1.0082812b2", "1.0084375b2", "1.0085938b2", "1.0087500b2",
323  "1.0089062b2", "1.0090625b2", "1.0092188b2", "1.0093750b2", "1.0095312b2", "1.0096875b2", "1.0098438b2"];
325 /* fpprintprec <= fpprec */
327 every (lambda ([s], s="5.6b2"), map (string, makelist (bfloat (5000/9), fpprec, fpprintprec, 40))), fpprintprec=2;
328 true;
330 every (lambda ([s], s="5.56b-4"), map (string, makelist (bfloat (5/9000), fpprec, fpprintprec, 40))), fpprintprec=3;
331 true;
333 every (lambda ([s], s="5.556b2"), map (string, makelist (bfloat (5000/9), fpprec, fpprintprec, 40))), fpprintprec=4;
334 true;
336 every (lambda ([s], s="5.5556b-4"), map (string, makelist (bfloat (5/9000), fpprec, fpprintprec, 40))), fpprintprec=5;
337 true;
339 every (lambda ([s], s="5.55556b2"), map (string, makelist (bfloat (5000/9), fpprec, fpprintprec, 40))), fpprintprec=6;
340 true;
342 every (lambda ([s], s="5.555556b-4"), map (string, makelist (bfloat (5/9000), fpprec, fpprintprec, 40))), fpprintprec=7;
343 true;
345 every (lambda ([s], s="5.5555556b2"), map (string, makelist (bfloat (5000/9), fpprec, fpprintprec, 40))), fpprintprec=8;
346 true;
348 /* fpprintprec >= fpprec */
350 /* bfloat generally produces a number which is not exactly the same as its argument.
351  * When bfloat returns a bigger number, it should round up when formatted,
352  * and when it's smaller, it should round down.
353  * When bfloat returns an exact result, in this case it should round up (to 6).
354  * Consider this when figuring out the correct output for these examples.
355  */
357 (fpprec : 2, 
358  mybf : bfloat(5/9000),
359  is (rationalize (mybf) >= (5*sum(10^i, i, 0, fpprec)/10^(fpprec + 1))/1000));
360 true;
362 every (lambda ([s], s="5.6b-4"), map (string, makelist (mybf, fpprintprec, fpprec, 40)));
363 true;
365 (fpprec : 3,
366  mybf : bfloat(5000/9),
367  is (rationalize (mybf) >= (5*sum(10^i, i, 0, fpprec)/10^(fpprec + 1))*1000));
368 true;
370 every (lambda ([s], s="5.56b2"), map (string, makelist (mybf, fpprintprec, fpprec, 40)));
371 true;
373 (fpprec : 4,
374  mybf : bfloat(5/9000),
375  is (rationalize (mybf) >= (5*sum(10^i, i, 0, fpprec)/10^(fpprec + 1))/1000));
376 true;
378 every (lambda ([s], s="5.556b-4"), map (string, makelist (mybf, fpprintprec, fpprec, 40)));
379 true;
381 (fpprec : 5,
382  mybf : bfloat(5000/9),
383  is (rationalize (mybf) >= (5*sum(10^i, i, 0, fpprec)/10^(fpprec + 1))*1000));
384 false;
386 every (lambda ([s], s="5.5555b2"), map (string, makelist (mybf, fpprintprec, fpprec, 40)));
387 true;
389 (fpprec : 10,
390  mybf : bfloat(5/9000),
391  is (rationalize (mybf) >= (5*sum(10^i, i, 0, fpprec)/10^(fpprec + 1))/1000));
392 true;
394 every (lambda ([s], s="5.555555556b-4"), map (string, makelist (mybf, fpprintprec, fpprec, 40)));
395 true;
397 (fpprec : 20,
398  mybf : bfloat(5000/9),
399  is (rationalize (mybf) >= (5*sum(10^i, i, 0, fpprec)/10^(fpprec + 1))*1000));
400 true;
402 every (lambda ([s], s="5.5555555555555555556b2"), map (string, makelist (mybf, fpprintprec, fpprec, 40)));
403 true;
405 (fpprec : 40,
406  mybf : bfloat(5/9000),
407  is (rationalize (mybf) >= (5*sum(10^i, i, 0, fpprec)/10^(fpprec + 1))/1000));
408 false;
410 every (lambda ([s], s="5.555555555555555555555555555555555555555b-4"), map (string, makelist (mybf, fpprintprec, fpprec, 40)));
411 true;
413 (reset (fpprec), 0);
417  * Bug 2142758: integrate(sqrt(2-2*x^2)*(sqrt(2)*x^2+sqrt(2))/(4-4*x^2),x,0,1)
418  */
419 integrate(sqrt(2-2*x^2)*(sqrt(2)*x^2+sqrt(2))/(4-4*x^2),x,0,1);
420 3*%pi/8;
423 integrate(sqrt(1-x^2)*(x^2+1)/(2-2*x^2),x,0,1);
424 3*%pi/8;
426 integrate(sqrt(1-x^2)*(x^2+1)/(1-x^2),x,0,1);
427 3*%pi/4;
430  * Bug [ 2208303 ] Problem with jacobi_dn and elliptic_kc
431  */
432 jacobi_dn(elliptic_kc(m)*t,m);
433 jacobi_dn(elliptic_kc(m)*t,m);
436  * Bug [ 2180110 ] GCL do not signal an overflow converting bigfloat to float
437  */
438 errcatch(float(2b400));
441 errcatch(float(bfloat(2^1024)));
445  * Bug [ 2055235 ] Plot leaves range with jacobi functions
447  * Actually jacobi_cn(100, .7) is computed inaccurately.  Just check that abs(jacobi_cn(100,.7)) < 1
448  */
450 is(abs(jacobi_cn(100.0, 0.7)) < 1);
451 true$
454  * Bug [ 1658067 ] jacobi_sn(elliptic_kc(1-m)*%i/2,m) isn't simplified
456  * This test (and Maxima) used to be wrong.  This is related to the
457  * jacobi_sc(elliptic_kc(m)/2,m) test below.
458  */
459 jacobi_sn(elliptic_kc(1-m)*%i/2,m);
460 %i/m^(1/4)$
462 jacobi_sc(elliptic_kc(m)+u,m);
463 -jacobi_cs(u,m)/sqrt(1-m)$
466  * Maxima used to get this wrong by returning the reciprocal instead
467  */
468 jacobi_sc(elliptic_kc(m)/2,m);
469 1/(1-m)^(1/4);
472  * Bug [ 2505945 ] - hgfred([2,-1/2],[3],-x^2);
474  * Shouldn't signal from diff about non-variable second arg.
476  * The expected value here is computed from
477  * factor(ratsimp(subst([z=-x^2],hgfred([2,-1/2],[3],z))))
478  */
479 factor(ratsimp(hgfred([2,-1/2],[3],-x^2)));
480 4*(3*x^4*sqrt(x^2+1)+x^2*sqrt(x^2+1)-2*sqrt(x^2+1)+2)/(15*x^4)$
483  * Bug 2534420: asinh(%i*2b0) causes error
484  */
485 is(abs(asinh(%i*2b0)-expand(bfloat(asinh(%i*2)))) < 3b-17);
486 true;
489  * Bug 2543079: bfloat(gamma(3/4)/gamma(1/4)) is wrong.
490  */
491 bfloat(gamma(3/4)/gamma(1/4));
492 3.379891200336424b-1;
495  * Bug 2582034 - hgfred([a/2,-a/2],[1/2],z) causes error
496  */
497 (assume(zn<0), done);
498 done;
500 hgfred([a/2,-a/2],[1/2],zn);
501 ((%i*sqrt(zn)+sqrt(1-zn))^a+(sqrt(1-zn)-%i*sqrt(zn))^a)/2$
504  * Bug 2618401 - bfloat produces incorrect answer
505  */
506 is(abs(bfloat((sqrt(2)+2)*%pi^(3/2)/(8*gamma(3/4)^2))-float((sqrt(2)+2)*%pi^(3/2)/(8*gamma(3/4)^2))) < 1d-15);
507 true;
509 /* (-1.0b0)^(1/3) vs (-1.0d0)^(1/3) - ID: 619927 */
510 (-1b0)^(1/3);
511 -1.0b0;
513 (-1.0)^(1/3);
514 -1.0;
516 domain:complex;
517 complex;
519 (-1b0)^(1/3);
520 1.0b0*(-1)^(1/3);
522 (-1.0)^(1/3);
523 1.0*(-1)^(1/3);
525 domain:real;
526 real;
528 (-1b0)^(1/3),domain:complex,m1pbranch:true;
529 1.0b0*(sqrt(3)*%i/2+1/2);
531 (-1.0)^(1/3),domain:complex,m1pbranch:true;
532  1.0*(sqrt(3)*%i/2+1/2);
536  * Bug [ 2688847 ] float of rats rounds incorrectly
537  */
538 float((2^60-1)/2^60)-1;
539 0.0;
540 float((2^1000-1)/2^1000)-1;
541 0.0;
544  * Bug [ 2687962 ] hgfred([-3/2,1],[-1/2],-t) division by zero
546  * Solution from functions.wolfram.com
547  */
548 ratsimp(hgfred([-3/2,1],[-1/2], t));
549 1+3*t-3*t^(3/2)*atanh(sqrt(t));
552  * Bug 2793827: internal error in integrate
553  */
554 (assume(n>0),declare(n,integer),0);
557 integrate((g32475^n*(g32475*n-n-1)/(g32475-1)^2+1/(g32475-1)^2)/(1-g32475)
558  -(g32475^(2*n+1)*(g32475*n-n-1)/(g32475-1)^2+g32475^(n+1)/(g32475-1)^2)
559   /(1-g32475),g32475,0,1);
560 (n+1)^2/2-1/2;
562 kill(all);
563 done;
566  * Bug 609464 : 1+%e,numer and %e^%e,numer
568  * The simplifier has been extended to handle %e like other constants.
569  * In addition functions with arguments which involve %e simplify
570  * accordingly.
571  */
573 %e,numer;
574 2.7182818284590451;
576 %e+1,numer;
577 3.7182818284590451;
579 %e^%e,numer;
580 15.154262241479262;
582 %e^x,numer;
583 %e^x;
585 sin(%e),numer;
586 0.41078129050290885;
588 sin(%e+1),numer;
589 -0.54525155669233449;
591 /* Do not simplify, when %e is the base of an expression and %enumer FALSE*/
593 sin(%e^(2*x+1)),numer;
594 sin(%e^(2*x+1));
596 sin(%e^(%e^(2*x+1))),numer;
597 sin(%e^(%e^(2*x+1)));
599 /* Additionally simplifications when %enumer TRUE */
601 %enumer:true;
602 true;
604 sin(%e^x),numer;
605 sin(2.7182818284590451^x);
607 sin(%e^(%e^(2*x+1))),numer;
608 sin(2.7182818284590451^(2.7182818284590451^(2*x+1)));
610 %enumer:false;
611 false;
614  * Bug ID: 2797885 - "problem with integration"
616  * integrate(exp(%i*x)*sin(x),x) generates a Lisp error.
618  * This is a special case for the integrand: exp(a*x)*sin(b*x),
619  * with a^2+b^2 equal to zero.
620  */
622 /* This is the general case for an integral with exp and sin or cos */
623 integrate(exp(a*x)*sin(b*x),x);
624 %e^(a*x)*(a*sin(b*x)-b*cos(b*x))/(b^2+a^2);
626 integrate(exp(a*x)*cos(b*x),x);
627 %e^(a*x)*(b*sin(b*x)+a*cos(b*x))/(b^2+a^2);
629 /* Now the special case with a=%i and b=1 */
630 expand(integrate(exp(%i*x)*sin(x),x));
631 %i*x/2-%e^(2*%i*x)/4;
633 expand(integrate(exp(x)*sin(%i*x),x));
634 %i*%e^(2*x)/4-%i*x/2;
636 expand(integrate(exp(%i*x)*cos(x),x));
637 x/2-%i*%e^(2*%i*x)/4;
639 expand(integrate(exp(x)*cos(%i*x),x));
640 %e^(2*x)/4+x/2;
642 /* Bug ID: 932076 -  ode2( 'diff(y,x)=%i*y+sin(x), y, x) => div by 0
644  * This bug is related to the Bug ID: 2797885 - "problem with integration"
645  */
647 ode2('diff(y,x)-%i*y-sin(x),y,x);
648 y = (%c-%i*(x-%i*%e^-(2*%i*x)/2)/2)*%e^(%i*x);
651  * Bug ID: 826623 "simplifer returns %i*%i"
652  * 
653  * Some examples to show simplification of expressions of the form
654  * (a*b*...)^q*(a*b*...)^r, where q+r=1
655  */
657 sqrt(-%i)*sqrt(-%i)*%i;
660 sqrt(a*b)*sqrt(a*b)*a*b;
661 a^2*b^2;
663 (a*b*c)^(3/4)*(a*b*c)^(1/4)*c;
664 a*b*c^2;
667  * Bug ID: 2792493 "hgfred([1],[-5.2],x);"
668  */
669 hgfred([1],[-5.2],x);
670 %f[1,1]([-6.2],[-5.2],-x)*%e^x$
672 /* BUG ID: 721575 2/sqrt(2) doesn\'t simplify */
673 2/sqrt(2);
674 sqrt(2);
676 (1/2)*sqrt(2);
677 1/sqrt(2);
679 sqrt(2)*(1/2);
680 1/sqrt(2);
682 /* BUG ID 2029041 a*sqrt(2)/2 unsimplified */
684 a*sqrt(2)/2;
685 a/sqrt(2);
687 /* BUG ID 1923119 1/sqrt(8)-sqrt(8)/8 */
689 1/sqrt(8)-sqrt(8)/8;
692 /* BUG ID 1927178 integrate(sin(t),t,%pi/4,3*%pi/4) */
694 integrate(sin(t),t,%pi/4,3*%pi/4);
695 sqrt(2);
697 /* BUG ID: 1480562 2*a*2^k isn't simplified to a*2^(k+1) */
699 2*a*2^k;
700 a*2^(k+1);
702 a*2^k*2;
703 a*2^(k+1);
705 /* Some examples to show simplification of expressions
706  * with floating point and bigfloat numbers after improvement
707  * of plusin
708  */
710 (4.0*x-4.0*x);
711 0.0;
712 (4.0*x-3.0*x);
713 1.0*x;
714 (4.0*x-3.0*x)/2;
715 0.5*x;
717 (4.0b0*x-4.0*x);
718 0.0b0;
719 (4.0b0*x-3.0*x);
720 1.0b0*x;
721 (4.0b0*x-3.0*x)/2;
722 0.5b0*x;
724 /* BUG ID: 1996354 unsimplifed result from expand */
726 expand((%e^(-2*sqrt(2))*(%e^(2*sqrt(2))+2*%e^sqrt(2)+1)^2)/16
727        +(%e^(-2*sqrt(2))*(%e^(2*sqrt(2))-2*%e^sqrt(2)+1)^2)/16
728        -(%e^(-2*sqrt(2))*(%e^(2*sqrt(2))-1)^2)/8);
731 /* BUG ID: 631216 - "horner([...],x)/FIX" 
732    horner now maps over lists, matrices and equations.
733  */
735 horner(x^2+x=a*x^2+b*x);
736 x*(x+1) = x*(a*x+b);
737 horner([x^2+x,x^3+x,x^4+x]);
738 [x*(x+1),x*(x^2+1),x*(x^3+1)];
740 /* BUG ID: 2699862 "derivative of polylogarithm"
741  * The noun form is not put on the property list, but NIL. The routine 
742  * sdiffgrad generates a noun form, when the derivative is not known.
743  */
745 diff(li[n](x),n);
746 'diff(li[n](x),n);
748 diff(li[n*x](x),x);
749 'diff(li[n*x](x),x);
751 diff(li[n](x),x,1,n,1);
752 'diff(li[n-1](x),n)/x;
754 /* Not reported as a bug, but the same problem for the function psi */
756 diff(psi[n](x),n);
757 'diff(psi[n](x),n);
759 diff(psi[n*x](x),x);
760 'diff(psi[n*x](x),x);
762 diff(psi[n](x),x,1,n,1);
763 'diff(psi[n+1](x),n);
765 /* BUG ID: 2824909 " exp(%i*%pi/4) not simplified" 
766  * Check the simplification of exp(%i*%pi/4) and exp(-%i*pi/4)
767  */
769 exp(%i*%pi/4);
770 1/sqrt(2)+%i/sqrt(2);
771 exp(-%i*%pi/4);
772 1/sqrt(2)-%i/sqrt(2);
775  * Bug ID: 2831259 - bfloat() underflow bug
776  */
777 fpprec:500;
778 500;
779 float(0b0);
780 0.0;
783  * BUG ID: 2835098 - SIGN-PREP strangeness
784  */
786 block ([?limitp : true], sign (foo (x)));
787 pnz;
789 integrate(sqrt(2*m*(E[n]-U(x))),x,-x[0],x[0])=(n-1/2)*%pi*hbar;
790 sqrt(2)*'integrate(sqrt(m*(E[n]-U(x))),x,-x[0],x[0]) = %pi*hbar*(n-1/2);
792 integrate(f(x),x,x[0],x[1]);
793 'integrate(f(x),x,x[0],x[1]);
796  * BUG ID: 2840566 - defint fails to determine if one of its limit is real
797  */
799 (assume(b>0,c>0),done);
800 done;
802 integrate(x,x,0,sqrt(b^2+(b-c)^2));
803 (c^2-2*b*c+2*b^2)/2;
806  * BUG ID: 2842060 - unsimplified result from integrate
807  */
809 /* The result for a general symbol x */
810 integrate(1/x/sqrt(x^2-1),x);
811 -asin(1/abs(x));
813 (assume(x>0), done);
814 done;
816 /* abs(x) simplifies to x for x>0 */
817 integrate(1/x/sqrt(x^2-1),x);
818 -asin(1/x);
820 (forget(x>0), done);
821 done;
823 /* 
824  * Bug ID: 2820202 - rootscontract(%i/2) 
825  */
826 rootscontract(%i/2);
827 %i/2;
829 /* Bug ID: 2872738 - sign(-(1/n)*(-1)^n)
830  * We got the error because of the simplification
831  *  (-1)^n*(-1) -> (-1)^(n+1) and not -(-1)^n
832  * The other case 
833     (-1)*(-1)^n simplifies already to -(-1)^n
834  * Adding tests for both cases.
835  */
836 kill(all);
837 done;
838 sign(-(1/n)*(-1)^n);
840 (-1)*(-1)^n;
841 -(-1)^n;
842 (-1)^n*(-1);
843 -(-1)^n;
845 /* Bug ID: 2835634 - logcontract broken
846  * Bug ID: 1467368 - logcontract returns unsimplified expr
847  */
848 logcontract(log(x)-log(2));
849 log(x/2);
850 /* Check that we do not break the following again */
851 logcontract(log(%e*k)-log(%e^-1*k));
853 log(%e^2),logexpand:false;
856 /* Bug ID: 2880923 - realpart --> floating-point-overflow
857  */
858 sign(exp(2009));
859 pos;
860 realpart(sqrt(4*%e^2009-3)-1);
861 sqrt(4*%e^2009-3)-1;
862 sqrt(4*exp(2009));
863 2*%e^(2009/2);
865 /* Bug ID: 640332 - Need to specdisrep more systematically
866    Add the examples of the bug report.
867  */
868 ratdisrep(diff(rat(x),rat(x)));
870 diff(x,rat(x));
872 outofpois(diff(intopois(sin(x)),x));
873 cos(x);
874 taylor(intopois(sin(x)),x,0,3);
875 x-x^3/6;
876 ratsimp(intopois(sin(x)));
877 sin(x);
879 /* Bug ID: 627759 - Ratdisrep of aggregates 
880  */
881 ratdisrep(rat(x=y));
882 x = y;
883 ratdisrep(rat([x=a,y=b]));
884 [x = a,y = b];
885 ratdisrep(rat(matrix([a,b],[c,d])));
886 matrix([a,b],[c,d]);
888 /* Bug ID: 711885 - Rootscontract with imaginaries fails
889  */
890 (oldvalue:radexpand, radexpand:false, done);
891 done;
893 rootscontract(((sqrt(3)*%i+1)^(3/2)-4*%i)/sqrt(sqrt(3)*%i+1));
894 ((sqrt(-3)+1)^(3/2)-4*%i)/sqrt(sqrt(-3)+1);
896 /* It is a problem of the simplifier. Show that it works */
897 sqrt(1/(1+sqrt(-3)));
898 1/sqrt(sqrt(-3)+1);
900 (radexpand:oldvalue, done);
901 done;
903 /* BUG ID: 767556 - Distributing operations over =
904  * The operators "." and "^^" distribute over equations.
905  */
907 x . (a=b);
908 x . a = x . b;
910 (a=b)^^x;
911 a^^x = b^^x;
913 /* A more complicated example */
914 x . ((2*a+b . c) = x . (y + z))^^w;
915 x . (b . c+2*a)^^w = x . (x . (z+y))^^w;
917 /* Bug ID: 2914176 - Conversion of rational to bfloat is inaccurate
919  * The difference should be 1/262144, but we don't check for that.
920  */
921 (oldfpprec:fpprec, fpprec:5, done);
922 done;
923 is(bfloat((2^20+1)/(2^20-1)) - 1b0 > 0);
924 true;
926 /* Related to the fix for 2914176.  Didn't handle the ratio 0/1 */
927 is(equal(0b0, 0));
928 true;
930 (fpprec:oldfpprec, done);
931 done;
933 /* Bug ID:2933882 - Power function: 0^a not fully implemented
934  * Show some simplifications of 0^a
935  */
937 assume(a>0);
938 [a>0];
939 0^a;
941 errcatch(0^-a);
943 0^(a+%i);
945 0^(1/2+%i);
947 errcatch(0^(-1/2+%));
949 errcatch(0^%i);
950 []; 
952 forget(a>0);
953 [a>0];
955 /* Bug ID: 2938078 - Crash on attached input
956  */
958 declare(n,integer, j,noninteger);
959 done;
960 assume(equal(x,n), equal(y,j), equal(z,i));
961 [equal(x, n), equal(y, j), equal(z,i)];
963 featurep(x,integer);
964 true;
965 featurep(x,noninteger);
966 false;
967 featurep(y,integer);
968 false;
969 featurep(y,noninteger);
970 true;
972 diff(z+1,z);
975 remove(n,integer, j,noninteger);
976 done;
977 forget(equal(x,n), equal(y,j), equal(z,i));
978 [equal(x, n), equal(y, j), equal(z, i)];
980 /* Bug ID:  2948800 - integrate((1-cos(2*x)^2)^2/x^4,x,0,inf) wrong
981  */
983 integrate((1-cos(2*x)^2)^2/x^4,x,0,inf);
984 8*%pi/3;
986 assume(a>0);
987 [a>0];
989 /* The more general type with an argument a*x and a positive */
990 integrate((1-cos(a*x)^2)^2/x^4,x,0,inf);
991 %pi*a^3/3;
993 forget(a>0);
994 [a>0];
996 /* Bug ID: 777564 - subtraction "-"(a,b) should work/FIX */
998 "-"();
1001 "-"(a);
1004 "-"(2*a);
1005 -2*a;
1007 "-"(a+b);
1008 -b-a;
1010 "-"(a+b+c);
1011 -c-b-a;
1013 "-"(100,20,10);
1016 map("-",[a,x,100],[b,y,20]);
1017 [a-b,x-y,80];
1019 map("-",[a,x,100],[b,y,20],[c,z,10]);
1020 [-c-b+a,-z-y+x,70];
1022 /* Bug ID: 910270 - 1/+3*x parses as 1/(+3*x)
1023  * Show that the "+" operator can be used as a prefix operator too.
1024  */
1025 1/+3*x;
1026 x*1/3;
1027 1/+x/3;
1028 1/(3*x);
1029 a^+b*c;
1030 c*a^b;
1032 /* Bug ID: 2961822 - sinh(0.0b0) causes Maxima to abort
1033  */
1034 sinh(0.0b0);
1035 0.0b0;
1037 /* Bug ID: 1219846 - properties of translated functions
1038  * The property noun is already present
1039  */
1040 kill(f);
1041 done;
1042 f(x):=x;
1043 f(x):=x;
1044 properties(f);
1045 [function,noun];
1046 translate(f);
1047 [f];
1048 properties(f);
1049 [transfun,function,noun];
1050 kill(f);
1051 done;
1053 /* Bug ID: 2968344 - gamma_incomplete(1.0, 4.368265444147715e+19) fails
1054  */
1055 gamma_incomplete(1.0, 4.368265444147715e+19);
1056 0.0;
1058 /* Bug ID: 643254 - orderlessp([rat(x)], [rat(x)])
1059  */
1060 orderlessp([rat(x)],[rat(x)]);
1061 false;
1063 /* Bug ID: 781657 - binomial(x,x) => 1, but binomial(-1,-1) => 0
1064  * binomial(x,x) simplifies to 1 only if the sign of x is known not to be 
1065  * negative.
1066  */
1067 is(equal(binomial(x,x),1));
1068 'unknown;
1069 is(equal(binomial(x^2,x^2),1));
1070 true;
1072 /* Bug ID:856209 - inconsistency between facts() and facts(v)
1073  * Show that facts(expr) now works more general.
1074  */
1075 assume(z+a>0,b>z);
1076 [a+z>0,b>z];
1077 facts(a);
1078 [a+z>0];
1079 facts(b);
1080 [b>z];
1081 facts(z);
1082 [a+z>0,b>z];
1083 facts(a+z);
1084 [a+z>0];
1085 forget(z+a>0,b>z);
1086 [a+z>0,b>z];
1088 /* Bug ID: 840848 - trigreduce doesn't enter unknown functions
1089  */
1090 trigexpand(f(sin(2*x)));
1091 f(2*cos(x)*sin(x));
1092 trigreduce(%);
1093 f(sin(2*x));
1095 /* Bug ID: 2954472 - rectform with large floats gives bad answer
1097 is(abs(rectform(1e160/(1e160+%i))-1) < 1e-160);
1098 true;
1100 is(abs(rectform(1e160/(1e160+3/2*%i))-1) < 1.5e-160);
1101 true;
1103 /* Bug ID: 2953369 - Definite Integration of 1/(a-b*cos(x)) wrong
1105  * For simplicity we test the equivalent integrate(1/(1-r*cos(x)),x,0,%pi).
1106  */
1107 /* These assumes are to answer the questions integrate (from routine unitcir) will ask */
1108 (assume(r>0,r<1,abs(sqrt(1-r^2)-1)/r-1 < 0, sqrt(1-r^2)-r+1>0), 0);
1110 integrate(1/(1-r*cos(x)),x,0,%pi);
1111 %pi/sqrt(1-r^2);
1113 /* Bug ID: 2907727 - Incorrect Integral with option integrate_use_rootsof
1114  * :true
1115  */
1116 %rnum:0;
1118 integrate((d*x^2+2*c*x+3*b)/(g*r*x^3+d*x^2+c*x+b), x), integrate_use_rootsof:true;
1119 lsum((%r1^2*d+2*%r1*c+3*b)*log(x-%r1)/(3*%r1^2*g*r+2*%r1*d+c),%r1,
1120              rootsof(g*r*%r1^3+d*%r1^2+c*%r1+b,%r1));
1122 /* Bug ID: 2880797 - bad answer in integrate(sqrt(sin(t)^2+cos(t)^2),t,0,2*%pi)
1124  */
1125 integrate(sqrt(sin(t)^2+cos(t)^2),t,0,2*%pi);
1126 2*%pi;
1128 /* Bug ID: 2980551 - Inconsistent simplification of exp(x*%i*%pi)
1130  * These examples show consistent simplification for x an expression which
1131  * can contain float or bigfloat values
1132  */
1134 exp(2*%i*%pi);
1137 exp((2+x)*%i*%pi);
1138 exp(x*%i*%pi);
1140 exp(2*%i*%pi+x*%i*%pi);
1141 exp(x*%i*%pi);
1143 log(exp((2+x)^2*%i*%pi));
1144 (2+x)^2*%i*%pi;
1146 exp(2.0*%i*%pi);
1147 1.0;
1149 exp((2.0+x)*%i*%pi);
1150 exp(1.0*x*%i*%pi);
1152 exp(2.0*%i*%pi+x*%i*%pi);
1153 exp(1.0*x*%i*%pi);
1155 log(exp((2.0+x)^2*%i*%pi));
1156 (2.0+x)^2*%i*%pi;
1158 exp(2.0b0*%i*%pi);
1159 1.0b0;
1161 exp((2.0b0+x)*%i*%pi);
1162 exp(1.0b0*x*%i*%pi);
1164 exp(2.0b0*%i*%pi+x*%i*%pi);
1165 exp(1.0b0*x*%i*%pi);
1167 log(exp((2.0b0+x)^2*%i*%pi));
1168 (2.0b0+x)^2*%i*%pi;
1170 exp(3/2*%pi*%i);
1171 -%i;
1172 exp(1.5*%pi*%i);
1173 -1.0*%i;
1174 exp(1.5b0*%pi*%i);
1175 -1.0b0*%i;
1177 exp((3/2+x)*%pi*%i);
1178 -%i*exp(%i*%pi*x);
1179 exp((1.5+x)*%pi*%i);
1180 -%i*exp(1.0*%i*%pi*x);
1181 exp((1.5b0+x)*%pi*%i);
1182 -%i*exp(1.0b0*%i*%pi*x);
1184 /* Bug ID: 2781127 - bfpsi0 of complex
1186  * (The result was not in rectangular form but it should be.)
1187  */
1188 bfpsi0(4.5 + %i,15);
1189 2.43845477527606b-1*%i + 1.41875534014717b0;
1191 /* Bug ID: 2988190 - atan2(1b20,-1b0); badly wrong
1192  * It's really a bug in atan for x < -1, so test both.
1193  */
1194 (fpprec:16, atan(-1b20));
1195 -1.570796326794897b0;
1196 atan2(1b20,-1b0);
1197 1.570796326794897b0;
1200  * Bug ID: 2991924 - Incorrect integration of rational functions
1201  */
1202 integrate(1/(x^4-2),x,0,1) - integrate(1/(x^2-sqrt(2))/(x^2+sqrt(2)),x,0,1);
1205 integrate(1/(x^6-4),x,0,1) - integrate(1/(x^3-2)/(x^3+2),x,0,1);
1208 /* BUG ID:  2113751 - Incomprehensible behavior of coeff()
1209  */
1210 coeff(2*%e^x, x, 0);
1211 2*%e^x;
1213 /* For numerical tests */
1214 closeto(e,tol):=block([numer:true,abse],abse:abs(e),if(abse<tol) then true else abse);
1215 closeto(e,tol):=block([numer:true,abse],abse:abs(e),if(abse<tol) then true else abse);
1217 /* Bug ID: 2997276 - zeta(3),numer; gives Lisp error 
1218  * 
1219  * Also add a test for complex rational argument, which wasn't handled
1220  * correctly either.
1222  * Some Lisp implementations fail these tests because things like
1223  * (cl:expt 2d0 3) only gives single-float accuracy (but with
1224  * double-float precision).
1225  */
1226 closeto(zeta(3)-1.202056903159594,1e-15), numer:true;
1227 true;
1228 closeto(zeta(3+%i)-(1.10721440843141 - .1482908671781754*%i), 1e-15);
1229 true;
1231  * Reported on mailing list 2011-05-22 by Thomas Dean:
1233  * plot2d(abs(zeta(1/2+x*%i)),[x,0,36]) causes a Lisp error with
1234  * clisp.
1236  */
1237 closeto(abs(zeta(1/2+.5*%i)) - 1.06534921249378, 1e-14);
1238 true;
1240 /* Bug ID: 2997401 - float(log(200!)) produces an error
1242  */
1243 closeto(float(log(200!))-863.2319871924054, 1e-15);
1244 true;
1246 closeto(float(log((1+200!)/7))-861.2860770433501, 1e-15);
1247 true;
1249 /* Additional tests */
1250 closeto(float(log(-1))-float(%pi)*%i, 1e-15);
1251 true;
1253 closeto(float(log((1+200!)/(-7))) - (3.141592653589793*%i + 861.2860770433501), 1e-14);
1254 true;
1256 closeto(float(log((1+200!)+(1+199!)*%i))- (.004999958333958322*%i + 863.2319996922491), 1e-15);
1257 true;
1259 closeto(float(log((1+200!)/7+(1+199!)/11*%i)) - (.003181807444342708*%i + 869.9736929490153), 1e-15);
1260 true;
1262 /* Bug ID: 2306402 - scalarp bug
1263  * Bug ID: 1985748 - array and scalar declarations yield inconsistent results
1264  * Examples from the bug report to show consistent behavior of scalarp
1265  */
1267 declare(x,scalar);
1268 done;
1269 scalarp(foo(x));
1270 true;
1271 scalarp(foo(1));
1272 true;
1273 scalarp(foo(x,1));
1274 true;
1276 scalarp(x);
1277 true;
1278 scalarp(x[1]);
1279 true;
1280 array(x,5);
1282 scalarp(x);
1283 true;
1284 scalarp(x[1]);
1285 true;
1286 nonscalarp(x);
1287 false;
1289 kill(x);
1290 done;
1292 /* Bug ID:1723548 - gradef for variables: not used in diff
1293  * Show that the total differential of f works in expressions too.
1294  */
1295 depends(f,[x,y]);
1296 [f(x,y)];
1297 diff(f);
1298 'diff(f,y,1)*del(y)+'diff(f,x,1)*del(x)$
1299 diff(3*f);
1300 3*'diff(f,y,1)*del(y)+3*'diff(f,x,1)*del(x)$
1301 diff(a*f);
1302 a*'diff(f,y,1)*del(y)+a*'diff(f,x,1)*del(x)+f*del(a)$
1303 remove(f,dependency);
1304 done;
1306 /* Bug ID: 1089719 addrow creates strange matrix
1307  */
1308 m:matrix([0,0]);
1309 matrix([0,0]);
1310 m:addrow(m,m);
1311 matrix([0,0],[0,0])$
1312 m[1,1]:11;
1315 matrix([11,0],[0,0])$
1316 kill(m);
1317 done;
1319 /* Bug ID: 1663385 - declare multiplicative - wrong simplification
1320  */
1321 declare(f,additive,f,multiplicative);
1322 done;
1323 f(a*b+c);
1324 f(a)*f(b)+f(c);
1325 kill(f);
1326 done;
1328 /* Bug ID: 816808 - subst(in)part of rat -- internal errs
1329  */
1330 substpart(x,2/3,2);
1331 2/x;
1332 substinpart(4,2/3,2);
1333 1/2;
1335 /* Bug ID: 1117533 - letsimp complains about assignment to %pi
1336  */
1337 matchdeclare(a,true);
1338 done;
1339 (let(%pi*a,foo(a)),done);
1340 done;
1341 letsimp(%pi*x);
1342 foo(x);
1343 remlet(%pi*a);
1344 done;
1346 /* Bug ID: 2805600 depends() partially prevents diff() to work
1347  */
1348 depends(t,x);
1349 [t(x)];
1350 diff(f(t),z);
1352 remove(t,dependency);
1353 done;
1355 /* Bug ID: 1184718 - AT needs soime basic simplifications
1356  */
1357 'at(2,x=0);
1360 /* Bug ID: 2998227 - spurious at(0,A=0)
1361  */
1362 taylor(integrate(gamma(x+1),x,0,A),A,0,3),nouns;
1363 A-%gamma*A^2/2+(6*%gamma^2+%pi^2)*A^3/36;
1365 /* Bug ID: 3010829 - numerical evaluation of elliptic_ec fails for argument > 1
1366  */
1367 closeto(elliptic_ec(2.0)-(.5990701173677959*%i+0.599070117367796), 1.5e-15);
1368 true;
1370 /* Bug ID: 1929287 - 0.0 + [0] ---> [0]
1371  */
1372 0.0+[0];
1373 [0.0];
1374 0.0b0+[0];
1375 [0.0b0];
1376 0.0+matrix([0,1/2,1,x]);
1377 matrix([0.0,0.5,1.0,x]);
1378 0.0b0+matrix([0,1/2,1,x]);
1379 matrix([0.0b0,5.0b-1,1.0b0,x]);
1381 /* Bug ID: 2996106 - at(diff(f(x,y),x,1,y,1),[x=a,y=b]) is wrong
1382  */
1383 at(diff(f(x,y),x,1,y,1),[x=a,y=b]);
1384 'at('diff(f(x,y),x,1,y,1),[x = a,y = b]);
1386 /* Bug report ID: 2556133 - "at" should do parallel substitutions
1387  */
1388 errcatch(at(atan2(y^2+1,x),[y=%i,x=0]));
1390 errcatch(at(atan2(y^2+1,x),[x=0,y=%i]));
1393 /* Bug report ID: 2014941 - compositions of 'at'
1394  */
1395 at(at(diff(f(x),x),[x=b]),[b=y]);
1396 'at('diff(f(x),x,1),[x = y]);
1398 at(diff(f(x,y),x,1,y,1),[x=a,y=b]) - at(diff(f(x,y),x,1,y,1),[y=b,x=a]);
1401 /* Bug report ID: 1677217 - composistions of 'at'
1402  */
1403 depends(y,[x,z]);
1404 [y(x,z)];
1405 at(at(diff(y,x),x=a),z=b);
1406 'at('at('diff(y,x,1),x = a),z = b);
1407 remove(y,dependency);
1408 done;
1410 /* Bug report ID: 3023978 - integrate(x^x+x,x) is wrong
1411  */
1412 integrate(x^x+x,x);
1413 'integrate(exp(x*log(x)),x)+x^2/2;
1415 /* Bug report ID: 2465066 - unsimplified result from integrate
1416  */
1417 matchdeclare(x, symbolp);
1418 done;
1419 (tellsimpafter('integrate(f(x),x), g(x)),done);
1420 done;
1421 integrate(5*f(x) + 7,x);
1422 5*g(x)+7*x;
1423 kill(rules);
1424 done;
1426 /* Bug report ID: 2789110 - solve, tan and atan depend on order of variables
1427  */
1428 solve(tan(x - atan(a/b)) = 0, x);
1429 [x = atan(a/b)];
1430 solve(tan(x - atan(b/a)) = 0, x);
1431 [x = atan(b/a)];
1433 /* Bug report ID: 1961494 - translated functions & values list
1434  */
1435 (kill(all), f():= x:2, translate(f));
1436 [f];
1437 f();
1439 values;
1440 [x];
1441 kill(f,x);
1442 done;
1443 /* The value of x has been removed. */
1447 /* Bug report ID: 3025038 - gruntz needs logexpand:true
1448  */
1449 gruntz( (x + 2^x) / 3^x, x, inf),logexpand:false;
1452 /* Bug report ID: 2977217 - maxima can not integrate x*exp(-1/2*(x-m)^2)
1453  */
1454 integrate(x*exp(-1/2*(x-m)^2),x);
1455 %i*(sqrt(2)*%i*gamma_incomplete(1,(m-x)^2/2)*(m-x)^2/(x-m)^2
1456    -%i*gamma_incomplete(1/2,(m-x)^2/2)*m*(m-x)/abs(x-m))/sqrt(2);
1458 /* Bug report ID: 2996542 - log(x) integration is incorrect
1459  */
1460 assume(a>0);
1461 [a>0];
1462 integrate(log(x),x,0,a);
1463 a*log(a)-a;
1464 forget(a>0);
1465 [a>0];
1467 /* Bug report ID: 3062883 - diff does not recognize indirect dependencies 
1468  *                          in expressions
1469  */
1471 depends([a,b],x,x,t);
1472 [a(x),b(x),x(t)];
1473 diff(-a,t);
1474 -'diff(a,x,1)*'diff(x,t,1);
1475 diff(a*b,t);
1476 a*'diff(b,x,1)*'diff(x,t,1)+'diff(a,x,1)*b*'diff(x,t,1);
1477 remove([a,b,x],dependency);
1478 done;
1480 /* Bug report ID: 3080397 - laplace(unit_step(-t),t,s) generates an error.
1481  */
1482 laplace(unit_step(-t),t,s);
1485 /* Bug report ID: 3081820 - lbfgs causes error
1487  * Still generates an error, but a different error that maxima
1488  * signals.
1489  */
1490 block([V:0.75, a:24, b:68, e],
1491   C(r) := 2*%pi*b*r^2 + 4*a*%pi*r + 2*b*V/r + a*V/(%pi*r^2),
1492   load(lbfgs),
1493   /* This should signal an error that we catch */
1494   e : errcatch(lbfgs(C(r), [r], [1], 1e-4, [1,0])),
1495   [e, error]);
1496 [[], ["Evaluation of gradient at ~M failed.  Bad initial point?~%", [0.0]]];
1498 /* Bug report ID: 875089 - defint(f(x)=g(x),x,0,1) -> false = false
1500  * We distribute defint more early in the code of bags to get a correct result.
1501  */
1502  defint(f(x)=g(x),x,0,1);
1503  'integrate(f(x),x,0,1)='integrate(g(x),x,0,1);
1505 /* Bug report ID: 2796194 - error doing a Fourier transform */
1506 (assume(equal(x,0)),done);
1507 done;
1509 errcatch(integrate(%pi*exp(-2*%pi*t)*exp(2*%pi*x*t*%i),t,minf,inf));
1512 error;
1513 ["defint: integral is divergent."];
1515 (forget(equal(x,0)),done);
1516 done;
1518 /* Bug reported on the mailing list
1519  * <http://www.math.utexas.edu/pipermail/maxima/2010/023024.html>
1520  * integrate(cos(2*x)*cos(x),x) is wrong.
1522  * Add a few more test that are similar to test the part of
1523  * monstertrig that deals with trig1(m*x)*trig2(n*x) where trig1 and
1524  * trig2 are either sin or cos.
1525  */
1526 integrate(cos(2*x)*cos(x),x);
1527 sin(3*x)/6+sin(x)/2;
1529 integrate(sin(2*x)*sin(x),x);
1530 sin(x)/2-sin(3*x)/6;
1532 integrate(cos(2*x)*sin(x),x);
1533 cos(x)/2-cos(3*x)/6;
1535 integrate(sin(x)*cos(2*x),x);
1536 cos(x)/2-cos(3*x)/6;
1538 /* Bug ID: 3111568 - subsequent calls to gradef hide variable dependencies
1539  */
1540 gradef(f,x,g);
1542 gradef(f,y,h);
1544 dependencies;
1545 [f(y,x)];
1546 kill(f);
1547 done;
1549 /* Bug ID: 3118770 - %edispflag:true causes a bug
1550  */
1551 %edispflag:true;
1552 true;
1553 integrate(x/(%e)^(2*x), x, 0, 1);
1554 1/4-3/(4*%e^2);
1555 reset(%edispflag);
1556 [%edispflag];
1558 /* Bug ID: 3067098 - The command timer for a Lisp function
1559  * Check that the function trisplit does not go away, when we collect
1560  * timing statistics for this function and call later kill(all).
1561  */
1562 timer(?trisplit);
1563 [?trisplit];
1564 kill(all);
1565 done;
1566 rectform(1+%i);
1567 1+%i;
1569 /* Bug ID: 3133916 - scanmap(minfactorial,a!) infinite loop
1570  */
1571 scanmap(minfactorial, a!);
1574 /* Bug ID: 3131324 - simplification of sqrt
1575  */
1576 sqrt(x^3)/sqrt(x^3);
1579 /* Bug ID: 1285104 - trigsimp and trigreduce & square roots
1580  */
1582 trigreduce(sqrt(r^2*sin(x)^2+r^2*cos(x)^2));
1583 abs(r);
1584 trigreduce(sqrt(r^2*sin(x)^2+r^2*cos(x)^2)),radexpand:all;
1586 radexpand:false;
1587 false;
1588 trigreduce(sqrt(r^2*sin(x)^2+r^2*cos(x)^2));
1589 sqrt(r^2);
1590 reset(radexpand);
1591 [radexpand];
1593 /* Bug ID: 917283 - Comment syntax confused
1594  * Show that nested comments work as expected.
1595  */
1596 a/*/**/*/+b;
1597 a+b;
1598 a/*/**/*/+/*/**/*/b;
1599 a+b;
1601 /* Bug ID: 3138054 -  bfloat problem / FIX -
1602  */
1603 exp(gamma(1/3)),bfloat;
1604 1.45696199392313b1;
1606 /* Bug ID: 3288989 - Lisp functions and linear display
1607  * Show that we do not get a Lisp error.
1608  */
1609 grind(?cdr([a,b,c]));
1610 done;
1612 /* Bug ID: 3291590 - Problems with fast arrays
1613  */
1614 (a:make_array(hashed), done);
1615 done;
1616 a[100]:100;
1617 100;
1618 a[x]:sin(x);
1619 sin(x);
1620 a[x*y]:x^2+y;
1621 y+x^2;
1623 /* Cutting out these two examples.
1624  * The ordering of the lists is different depending on the underlying Lisp.
1626  * arrayinfo(a);
1627  * [hash_table,1,100,x,x*y];
1628  * listarray(a);
1629  * [100,sin(x),y+x^2];
1630  */
1632 (f:make_array(functional, 'factorial, hashed), done);
1633 done;
1634 f[10];
1635 3628800;
1637 (kill(f), 0);
1640 (a: make_array(fixnum, 2, 2), done);
1641 done;
1642 listarray(a);
1643 [0, 0, 0, 0];
1645 use_fast_arrays:true;
1646 true;
1648 (array(a, any, 2, 2), done);
1649 done;
1650 arrayinfo(a);
1651 [declared, 2, [2, 2]];
1652 (array(a, fixnum, 2, 2), done);
1653 done;
1654 arrayinfo(a);
1655 [declared, 2, [2, 2]];
1656 (array(a, flonum, 2, 2), done);
1657 done;
1658 arrayinfo(a);
1659 [declared, 2, [2, 2]];
1660 (array(a, hashed), done);
1661 done;
1662 arrayinfo(a);
1663 [hash_table, 1];
1665 reset(use_fast_arrays);
1666 [use_fast_arrays];
1667 kill(a);
1668 done;
1670 /* Bug ID: 3247367 - expand returns unsimplified
1671  */
1672 sqrt(2)+sqrt(2);
1673 2^(3/2);
1674 sqrt(2)+sqrt(2)+sqrt(2);
1675 3*sqrt(2);
1676 sqrt(2)+sqrt(2)+sqrt(2)+sqrt(2);
1677 2^(5/2);
1678 sqrt(2)+sqrt(2)+sqrt(2)+sqrt(2)+sqrt(2);
1679 5*sqrt(2);
1681 2*sqrt(2)+3*sqrt(2);
1682 5*sqrt(2);
1683 3*sqrt(2)+2*sqrt(2);
1684 5*sqrt(2);
1685 3*sqrt(2)+2*sqrt(2)+sqrt(2);
1686 3*2^(3/2);
1687 sqrt(2)+3*sqrt(2)+2*sqrt(2);
1688 3*2^(3/2);
1690 sqrt(1/2)+sqrt(1/2);
1691 sqrt(2);
1692 sqrt(1/2)+sqrt(1/2)+sqrt(1/2);
1693 3/sqrt(2);
1694 sqrt(1/2)+sqrt(1/2)+sqrt(1/2)+sqrt(1/2);
1695 2^(3/2);
1696 sqrt(1/2)+sqrt(1/2)+sqrt(1/2)+sqrt(1/2)+sqrt(1/2);
1697 5/sqrt(2);
1699 2*sqrt(1/2)+3*sqrt(1/2);
1700 5/sqrt(2);
1701 3*sqrt(1/2)+2*sqrt(1/2);
1702 5/sqrt(2);
1703 3*sqrt(1/2)+2*sqrt(1/2)+sqrt(1/2);
1704 3*sqrt(2);
1705 sqrt(1/2)+3*sqrt(1/2)+2*sqrt(1/2);
1706 3*sqrt(2);
1708 2^(1/5)+2^(1/5);
1709 2^(6/5);
1710 2^(1/5)+2^(1/5)+2^(1/5);
1711 3*2^(1/5);
1712 2^(1/5)+2^(1/5)+2^(1/5)+2^(1/5);
1713 2^(11/5);
1714 2^(1/5)+2^(1/5)+2^(1/5)+2^(1/5)+2^(1/5);
1715 5*2^(1/5);
1717 (1/2)^(1/5)+(1/2)^(1/5);
1718 2^(4/5);
1719 (1/2)^(1/5)+(1/2)^(1/5)+(1/2)^(1/5);
1720 3/2^(1/5);
1721 (1/2)^(1/5)+(1/2)^(1/5)+(1/2)^(1/5)+(1/2)^(1/5);
1722 2^(9/5);
1723 (1/2)^(1/5)+(1/2)^(1/5)+(1/2)^(1/5)+(1/2)^(1/5)+(1/2)^(1/5);
1724 5/2^(1/5);
1726 2*(1/2)^(1/5)+3*(1/2)^(1/5);
1727 5/2^(1/5);
1728 3*(1/2)^(1/5)+2*(1/2)^(1/5);
1729 5/2^(1/5);
1731 2^sin(x)+2^sin(x);
1732 2^(sin(x)+1);
1733 2^sin(x)+2^sin(x)+2^sin(x);
1734 3*2^sin(x);
1735 2^sin(x)+2^sin(x)+2^sin(x)+2^sin(x);
1736 2^(sin(x)+2);
1737 2^sin(x)+2^sin(x)+2^sin(x)+2^sin(x)+2^sin(x);
1738 5*2^sin(x);
1740 (1/2)^sin(x)+(1/2)^sin(x);
1741 2^(1-sin(x));
1742 (1/2)^sin(x)+(1/2)^sin(x)+(1/2)^sin(x);
1743 3/2^sin(x);
1744 (1/2)^sin(x)+(1/2)^sin(x)+(1/2)^sin(x)+(1/2)^sin(x);
1745 2^(2-sin(x));
1746 (1/2)^sin(x)+(1/2)^sin(x)+(1/2)^sin(x)+(1/2)^sin(x)+(1/2)^sin(x);
1747 5/2^sin(x);
1749 (1-sqrt(5))^3-4*(1-sqrt(5))^2+8, expand;
1751 1/sqrt(2)+1/sqrt(2)+1/sqrt(2);
1752 3/sqrt(2);
1753 2^(9/5)+2^(4/5);
1754 3*2^(4/5);
1755 3*sqrt(2)+2*sqrt(2);
1756 5*sqrt(2);
1757 2*sqrt(2)+3*sqrt(2);
1758 5*sqrt(2);
1759 (1-sqrt(5))^3, expand;
1760 16-8*sqrt(5);
1761 p : z^3-2^(3/2)*%i*z^2-4*z^2+2^(5/2)*%i*z+2*z;
1762 z^3-2^(3/2)*%i*z^2-4*z^2+2^(5/2)*%i*z+2*z;
1763 divide(p, (z-2-sqrt(2)*%i),z);
1764 [z^2+(-sqrt(2)*%i-2)*z,0];
1765 2^a + 3*2^(a+1);
1766 7*2^a;
1767 2^(3/5)+2^(-2/5);
1768 3/2^(2/5);
1769 2^(3/5+x)+2^(-2/5+x);
1770 3*2^(x-2/5);
1772 /* -----------------------------------------------------------------------------
1773  * Bug ID: 1439566 - zerobern & bernpoly
1774  * Show that the option variable zerobern does not change the results.
1775  * -------------------------------------------------------------------------- */
1776 zerobern:false;
1777 false;
1778 bernpoly(x,3);
1779 x^3-3*x^2/2+x/2$
1780 bernpoly(x,5);
1781 x^5-5*x^4/2+5*x^3/3-x/6$
1782 reset(zerobern);
1783 [zerobern];
1785 /* Show that bern no longer fails with zerobern:false.
1787  * The compared values are from A&S p810, Table 23.2.
1788  */
1789 bern(28);
1790 -23749461029/870$
1791 bern(40);
1792 -261082718496449122051/13530$
1793 euler(16);
1794 19391512145$
1796 zerobern:false;
1797 false$
1798 bern(17);
1799 -7709321041217/510$
1800 bern(24);
1801 596451111593912163277961/282$
1802 euler(10);
1803 370371188237525$
1805 reset(zerobern);
1806 [zerobern]$
1808 /* -----------------------------------------------------------------------------
1809  * Bug ID: 2905929 - gcdex
1810  * -------------------------------------------------------------------------- */
1811 q0[2] : 6;
1813 ratdisrep(gcdex(x-7, x-8));
1814 [1,-1,1]$
1816 is(equal(gcdex(z^2-1, 0, z), [1,0,z^2-1]));
1817 true;
1819 is(equal(gcdex(0, z^2-1, z), [0, 1, z^2-1]));
1820 true;
1822 /* Examples from the Maxima Manual */
1823 is(equal(gcdex(x^2+1, x^3+4), [-(x^2+4*x-1)/17,(x+4)/17,1]));
1824 true$
1825 is(equal(gcdex(x*(y+1), y^2-1, x), [0,1/(y^2-1),1]));
1826 true$
1828 kill(q0);
1829 done;
1831 /* -----------------------------------------------------------------------------
1832  * Bug ID: 3389830 - Error break in rtest15 with linear display
1834  * Show that we do not get an error with grind for a prefix and a postfix
1835  * Operator when displaying the definition of a function or a macro.
1836  * This is a test of the function msz-mdef in grind.lisp.
1837  * -------------------------------------------------------------------------- */
1838 (postfix("f"), prefix("g"), done);
1839 done$
1840 grind("f"(x):=x);
1841 done$
1842 grind("f"(x)::=x);
1843 done$
1844 grind("g"(x):=x);
1845 done$
1846 grind("g"(x)::=x);
1847 done$
1849 kill ("f", "g");
1850 done;
1852 /* -----------------------------------------------------------------------------
1853  * Bug ID: 3396631 - equal terms produce different results
1854  * Correcting a bug in plusin revision 23.08.2011
1855  * -------------------------------------------------------------------------- */
1856 5*sqrt(5)+2*sqrt(3)+6*sqrt(5);
1857 11*sqrt(5)+2*sqrt(3)$
1858 5*sqrt(5)+4*sqrt(3)+6*sqrt(5);
1859 11*sqrt(5)+4*sqrt(3)$
1860 5*sqrt(5)+3*sqrt(5)+5*sqrt(3)+3*sqrt(3)+2*sqrt(75)+2*sqrt(45);
1861 14*sqrt(5)+2*3^(5/2)$
1862 5*sqrt(5)+5*sqrt(3)+3*sqrt(3)+2*sqrt(75)+2*sqrt(45)+3*sqrt(5);
1863 14*sqrt(5)+2*3^(5/2)$
1864 5*sqrt(5)+5*sqrt(3)+2*sqrt(75)+2*sqrt(45)+3*sqrt(5)+3*sqrt(3);
1865 14*sqrt(5)+2*3^(5/2)$
1867 /* -----------------------------------------------------------------------------
1868  * Bug ID 3437268: expand doesn't fully expand
1869  * Check the expected results after revision 14.11.2011 of simp.lisp.
1870  * -------------------------------------------------------------------------- */
1871 -3*a/sqrt(2)+sqrt(2)*a+a/sqrt(2);
1873 expand(-(atan((sqrt(2)*sin(8))/cos(8))+3*%pi)/sqrt(2)
1874         +atan((sqrt(2)*sin(8))/cos(8))/sqrt(2)
1875         +sqrt(2)*%pi
1876         +%pi/sqrt(2));
1880  * SF Bug: elliptic_e error observed - ID: 3438911
1882  * Test the bug by using the identity:
1883  * elliptic_e(%pi,m) = 2*elliptic_ec(m)
1885  * There's also a bug in elliptic_f.  We test this using the identity:
1886  * elliptic_f(%pi,m) = 2*elliptic_kc(m)
1887  */
1889 closeto(e,tol):=block([numer:true,abse],abse:abs(e),if(abse<tol) then true else abse);
1890 closeto(e,tol):=block([numer:true,abse],abse:abs(e),if(abse<tol) then true else abse);
1892 closeto(elliptic_e(float(%pi), .1) - 2*elliptic_ec(.1), 1e-15);
1893 true;
1894 closeto(elliptic_e(float(%pi), .9) - 2*elliptic_ec(.9), 1e-15);
1895 true;
1896 closeto(elliptic_e(bfloat(%pi), .1b0) - 2*elliptic_ec(.1b0), 1e-16);
1897 true;
1898 closeto(elliptic_e(bfloat(%pi), .9b0) - 2*elliptic_ec(.9b0), 1e-16);
1899 true;
1901 closeto(elliptic_f(float(%pi), .1) - 2*elliptic_kc(.1), 1e-15);
1902 true;
1903 closeto(elliptic_f(float(%pi), .9) - 2*elliptic_kc(.9), 1e-15);
1904 true;
1905 closeto(elliptic_f(bfloat(%pi), .1b0) - 2*elliptic_kc(.1b0), 1e-16);
1906 true;
1907 closeto(elliptic_f(bfloat(%pi), .9b0) - 2*elliptic_kc(.9b0), 1e-16);
1908 true;
1911  * Bug 3526111 - float erf (%i) not working
1912  */
1914 closeto(float(erf(%i)) - 1.650425758797543*%i, 1e-15);
1915 true;
1918  * Bug 3529992: Shi (sinh integral) wrong branch, integrate inconsistent
1919  */
1920 closeto(float(expintegral_shi(1/2) - 0.50699674981966719583), 3e-16);
1921 true;
1923 /* integrate changes k[0] --> k(0) - ID: 3530767 */
1924 integrate(x * (x^2 + k[0])/(1 + x^2),x);
1925 ((k[0]-1)*log(x^2+1))/2+x^2/2$
1927 /* polarform error on simple case - ID: 3517034 */
1928 polarform((a+1)/2 - a/2 - 1/2);
1931 polarform((a+1)/2 - a/2 - 0.5);
1932 0.0$
1934 polarform((a+1)/2 - a/2 - 0.5b0);
1935 0.0b0$
1938 /* #2531 Integration with inf */
1939 errcatch(integrate((1+1/x)^(1/2),x,1,inf));
1942 error;
1943 ["defint: integral is divergent."];
1948  * ID: 3440046: elliptic_f(0.5,1) signals error
1950  * Add a few more tests for invalid values.
1951  */
1952 closeto(elliptic_f(0.5,1)-elliptic_f(1/2,1), 1e-15);
1953 true;
1955 closeto(elliptic_f(0.5b0,1) - bfloat(elliptic_f(1/2,1)), 1b-16);
1956 true;
1958 errcatch(elliptic_f(2.0,1));
1961 errcatch(elliptic_f(2b0,1));
1965  * Bug 3428734:  integrate(bessel_y(1,z),z)  with ?z : 1
1966  */
1968 (?z:1, 0);
1971 integrate(bessel_y(1,z),z);
1972 -bessel_y(0,z);
1974 integrate(bessel_j(1,z),z);
1975 -bessel_j(0,z);
1977 integrate(bessel_k(1,z),z);
1978 -bessel_k(0,z);
1980 integrate(bessel_i(1,z),z);
1981 bessel_i(0,z);
1984  * Bug 3381301: log(-1.0b0) has small realpart
1985  */
1986 realpart(log(-1b0));
1990  * Bug 3559064: elliptic_f(2,1) is wrong.
1991  */
1992 errcatch(elliptic_f(2,1));
1996  * Bug 2528: A variable should be real if it is both real and complex
1997  */
1998 (declare(foo, real), declare(foo, complex), 0);
2001 [realpart(foo), imagpart(foo)];
2002 [foo, 0]$
2004 (kill(foo), 0);
2007 map(lambda([x], featurep(x, 'irrational)),[42,%pi,%phi,%e]);
2008 [false, true, true, true]$
2010 /* #2501 %pi/8 is definitely not an integer */
2011 integrate(log(cot(x)-1),x,0,%pi/4);
2012 (%i*li[2]((%i+1)/2)-%i*li[2](-((%i-1)/2)))/2 -(%i*(2*li[2](%i+1)-2*li[2](1-%i))+%pi*log(2))/4$
2014 integrate(log(cos(x)),x,0,%pi/2);
2015 %i*%pi^2/24-(6*%pi*log(4)+%i*%pi^2)/24$
2017 map(lambda([x], featurep(x, noninteger)),[sqrt(5),%pi,%pi/3, %pi/8,log(42),99/2013]);
2018 [true,true,true,true,true,true]$
2020 map(lambda([x], featurep(x, noninteger)),[0,1,2013]);
2021 [false,false,false]$
2023 /* #2583 sign error for integrate(x^(8*%i-1),x) */
2024 block([domain : 'real], integrate(x^(8*%i-1),x));
2025 -%i*x^(8*%i)/8$
2027 /* #2602: some-bfloatp and some-floatp recursed wrongly on rat expressions */
2028 ?some\-bfloatp(rat(1/2));
2029 false$
2031 /* #2594: Error in trigreduce for complicated expressions */
2032 subst(0, x, trigreduce(product(cos(k*x), k, 1, 8)));
2035 /* SF bug #2818: Problem with trigreduce */
2036 trigreduce(sin(1/8*%pi)*sin(3/8*%pi)*sin(5/8*%pi)*sin(7/8*%pi));
2037 1/8;
2039 /* #2591: Risch gives lisp error */
2040 (risch(asinh((z^2-1)/z)/z,z), 0);
2043 /* #2682: Function zeta fails numerically for large numbers */
2044 closeto(zeta(40.0) - 1, 1e-12);
2045 true$
2047 /* #2675 (1/3): Integration yields noun form with subscripted variable */
2048 integrate(exp(-(1+%i)*x[1]),x[1],0,inf);
2049 -((-1 + %i)/2)$
2051 /* #2688: %e^^A returns element by element exponent */
2052 is(%e^^matrix([1,2],[3,4]) = %e^matrix([1,2],[3,4]));
2053 false$
2055 /* #2676: Integral incorrect when variable is subscripted */
2056 integrate(x[1]*exp(x[1]), x[1]);
2057 exp(x[1])*(x[1]-1)$
2059 /* #2726: Integrate produces wrong answer for Gaussian Moments */
2060 (declare(m2726, even),
2061  block([tmp: integrate(exp(-x^2/2)/sqrt(2*%pi) * x^m2726, x, -1/4, 1/4)],
2062    sign (subst(m2726 = 4, tmp))));
2063 pos$
2065 /* # 2697: Inconsistent handling of Greek symbols */
2066 integrate(y(%theta)=sin(%theta),%theta,%theta[0], %theta[1]);
2067 'integrate(y(%theta),%theta,%theta[0],%theta[1]) = cos(%theta[0])-cos(%theta[1])$
2069 integrate(y(t)=sin(t),t,t[0], t[1]);
2070 'integrate(y(t),t,t[0],t[1]) = cos(t[0])-cos(t[1])$
2072 integrate(y(tau)=sin(tau),tau,tau[0], tau[1]);
2073 'integrate(y(tau),tau,tau[0],tau[1]) = cos(tau[0])-cos(tau[1])$
2075 integrate ([foo(x), bar(x)], x, x[1], x[2]);
2076 ['integrate (foo(x), x, x[1], x[2]), 'integrate (bar(x), x, x[1], x[2])];
2078 /* # 2738: Integrate encountered a Lisp error: The value 2 is not of type LIST. */
2080 (kill (x, y, I, J),
2081  x(t):=2*cos(t),
2082  y(t):=2*sin(t),
2083  I : (x(t)+y(t)^2)*sqrt(diff(x(t),t)^2+diff(y(t),t)^2),
2084  J : integrate (I, t));
2085 4*(t-tan(t)/(tan(t)^2+1))+4*sin(t)$
2087 trigsimp (diff (J, t) - I);
2089 /* bug #2980: Infinite recursion with (e: log(e), rectform(e)) */
2090 block ([e: log(e)], rectform(e));
2091 log(abs(e)) + %i*atan2(0, e)$
2093 /* bug #2159: integration_with_logabs ("integrate(tan(x),x);" etc. do not take "logabs" flag into account) */
2094 integrate([tan(x),csc(x),sec(x),cot(x),tanh(x),coth(x),csch(x)],x);
2095 [log(sec(x)),-log(csc(x)+cot(x)),log(sec(x)+tan(x)),log(sin(x)),log(cosh(x)),log(sinh(x)),log(tanh(x/2))]$
2096 integrate([tan(x),csc(x),sec(x),cot(x),tanh(x),coth(x),csch(x)],x),logabs;
2097 [log(abs(sec(x))),-log(abs(csc(x)+cot(x))),log(abs(sec(x)+tan(x))),log(abs(sin(x))),log(cosh(x)),log(abs(sinh(x))),log(abs(tanh(x/2)))]$
2099 /* Bug #3075: #3075 answer "3*false" from "integrate(3*asinh(x),x,-inf,inf)" */
2100 /* We can't check for the correct answer zero (yet), because Maxima can't solve integrate(asinh(x),x,-inf,inf). */
2101 is(integrate(3*asinh(x),x,-inf,inf)#3*false);
2102 true$
2105  * Bug #3056: exp(1b19) signals error that 1b19 doesn't have enough
2106  * precision to compute its integer part.  Add test for this and also
2107  * the original test from commit 576c7508.)
2108  */
2110 /* Don't really care what the answer is as long as we don't signal an error */
2111 is(errcatch(exp(1b19)) # []);
2112 true;
2114 /* Test from the commit 576c7508 */
2115 ceiling((207300647060*%e^-563501581931)/(403978495031*%e^-1098127402131));
2116 ceiling((207300647060*%e^534625820200)/403978495031);
2118 /* Bug #3098: numerical evaluation of li[3] */
2119 li[3](0.0);
2120 0.0;
2122 closeto(li[3](1.0) - zeta(3.0), 1e-15);
2123 true;
2125 closeto(li[3](0.5) - li[3](1/2), 1e-15);
2126 true;
2128 closeto(li[3](-2.0) - float(subst(z=-2.0, li[3](1/z) - log(-z)/6*(log(-z)^2+%pi^2))), 1e-15);
2129 true;
2131 closeto(abs(li[3](2.0) - expand(float(subst(z=2.0, li[3](1/z) - log(-z)/6*(log(-z)^2+%pi^2))))), 1e-15);
2132 true;
2134 li[2](-1);
2135 -%pi^2/12;
2137 li[2](1);
2138 %pi^2/6;
2140 li[2](1/2);
2141 %pi^2/12 - log(2)^2/2;
2143 closeto(li[2](0.5) - (%pi^2/12 - log(2)^2/2), 1.1103e-16), numer;
2144 true;
2146 closeto(li[2](2.0) - (%pi^2/4 - %i*%pi*log(2)), 2.513e-15), numer;
2147 true;
2149 closeto(li[2]((1-sqrt(5))/2) - (log((sqrt(5)-1)/2)^2/2-%pi^2/15), 1.1103e-16), numer;
2150 true;
2152 /* Catalan's constant: 0.915965594... */
2153 closeto(li[2](1.0*%i) - (-%pi^2/48 + %i*0.915965594177219015054603514932384110774149374281672134266), 1.3878e-16), numer;
2154 true;
2156 closeto(li[2](1.0-%i) - (%pi^2/16-%i*0.915965594177219015054603514932384110774149374281672134266 - %pi*%i*log(2)/4), 4.5e-16), numer;
2157 true;
2159 /* Make sure li[3](1/7),numer returns a float and not a bfloat */
2160 ?floatp(li[3](float(1/7)));
2161 true;
2163 ?floatp(realpart(li[2](1.0+1.0*%i)));
2164 true;
2166 closeto(li[3](0.5) - float((7*zeta(3))/8+log(2)^3/6-(%pi^2*log(2))/12), 1.1103e-16);
2167 true;
2169 closeto(float(li[3](exp(%pi*%i/3))) - float(zeta(3)/3 + %i*5*%pi^3/162), 5.6611e-16);
2170 true;
2172 /* Bug 3112: zeta(n) for negative even n is inaccurate */
2173 zeta(-4.0);
2174 0.0;
2176 zeta(-6b0);
2177 0b0;
2179 /* Bug 3105: li[s](1.0) doesn't simplify */
2180 closeto(li[4](1.0)-li[4](1), 1.11022e-16);
2181 true;
2183 closeto(li[4](-1.0)-li[4](-1), 1.11022e-16);
2184 true;
2186 closeto(li[4](1b0)-li[4](1), 10^-fpprec);
2187 true;
2189 closeto(li[4](-1b0)-li[4](-1), 10^-fpprec);
2190 true;
2194  * More numeric test for polylog function li[s](z).
2196  * The reference values were obtained from
2197  * http://functions.wolfram.com/webMathematica/FunctionEvaluation.jsp?name=PolyLog
2198  */
2199 fpprec:24;
2202 closeto(li[4](0.25) - 0.25411619074634353405967371315352,
2203   5.5512e-17);
2204 true;
2206 closeto(li[4](0.25b0) - 0.25411619074634353405967371315352b0,
2207   2.06796b-25);
2208 true;
2210 closeto(li[4](0.75) - 0.79222102797282777952948578955736,
2211   2.2205e-16);
2212 true;
2214 closeto(li[4](0.75b0) - 0.79222102797282777952948578955736b0,
2215   6.20386b-25);
2216 true;
2218 closeto(li[4](1.5) - (1.7347570807760620737768805117515 - 0.0349027048283367002627421237287*%i),
2219   2.2205e-16);
2220 true;
2222 closeto(li[4](1.5b0) - (1.7347570807760620737768805117515b0 - 0.0349027048283367002627421237287b0*%i),
2223   4.14398b-25);
2224 true;
2226 closeto(li[4](10.0) - (9.6140263862742968515251940747859 - 6.3921313179656069159740055708257*%i),
2227   5.618e-15);
2228 true;
2230 closeto(li[4](10.0b0) - (9.6140263862742968515251940747859b0 - 6.3921313179656069159740055708257b0*%i),
2231   1.9364b-23);
2232 true;
2234 closeto(li[4](-5.0) - (-4.1064679790949702621073505378164),
2235   8.8818e-16);
2236 true;
2238 closeto(li[4](-5b0) - (-4.1064679790949702621073505378164b0),
2239   4.9631b-24);
2240 true;
2242 closeto(li[4](2.0*%i) - (-0.2113943747614829764326347997923 + 1.9289340331586646502356787803360*%i),
2243   7.22e-16);
2244 true;
2246 closeto(li[4](2b0*%i) - (-0.2113943747614829764326347997923b0 + 1.9289340331586646502356787803360b0*%i),
2247   1.9788b-24);
2248 true;
2250 closeto(li[5](0.25) - 0.25202158817857420100669519623555,
2251   5.55112e-17);
2252 true;
2254 closeto(li[5](0.25b0) - 0.25202158817857420100669519623555b0,
2255   5.16988b-25);
2256 true;
2258 closeto(li[5](0.75) - 0.76973541059975738097269173152535,
2259   1.111e-16);
2260 true;
2262 closeto(li[5](0.75b0) - 0.76973541059975738097269173152535b0,
2263   2.06796b-25);
2264 true;
2266 closeto(li[5](1.5) - (1.5961739456813534102689069143338 - 0.0035379572466222227823786042761*%i),
2267   4.33681e-19);
2268 true;
2270 closeto(li[5](1.5b0) - (1.5961739456813534102689069143338b0 - 0.0035379572466222227823786042761b0*%i),
2271   4.13594b-25);
2272 true;
2274 closeto(li[5](10.0) - (11.2390407376112991620107110964539 - 3.6796065713019972004384472107791*%i),
2275   9.93014e-15);
2276 true;
2278 closeto(li[5](10.0b0) - (11.2390407376112991620107110964539b0 - 3.6796065713019972004384472107791b0*%i),
2279   2.18382b-23);
2280 true;
2282 closeto(li[5](-5.0) - (-4.4800824065112010228046981292686),
2283   1e-16);
2284 true;
2286 closeto(li[5](-5b0) - (-4.4800824065112010228046981292686b0),
2287   6.61745b-24);
2288 true;
2290 closeto(li[5](2.0*%i) - (-0.1139660114783041974283299769126 + 1.9734617121122917650272273558071*%i),
2291   6.98e-16);
2292 true;
2294 closeto(li[5](2b0*%i) - (-0.1139660114783041974283299769126b0 + 1.9734617121122917650272273558071b0*%i),
2295   6.42086b-25);
2296 true;
2298 closeto(li[20](5.0) - (5.0000238783147176199891129814336 - 2.182054400942151422e-13*%i),
2299   2.41797e-15);
2300 true;
2302 closeto(li[20](5b0) - (5.0000238783147176199891129814336b0 - 2.182054400942151422b-13*%i),
2303   6.76366b-24);
2304 true;
2306 /* Bug #3194: No simplification of "tan(x+n*%pi)" and "cot(x+n*%pi)" with "n" being a declared integer */
2307 /* Also test that the "modulus 1/2" check in "%piargs-tan/cot" works correctly. */
2308 declare(i, integer, ei, even, oi, odd);
2309 done$
2310 [tan(x+i*%pi),cot(x+i*%pi)];
2311 [tan(x),cot(x)]$
2312 [tan(x+ei*%pi),cot(x+ei*%pi)];
2313 [tan(x),cot(x)]$
2314 [tan(x+oi*%pi),cot(x+oi*%pi)];
2315 [tan(x),cot(x)]$
2316 [tan(x-3/2*%pi),tan(x-1/2*%pi),tan(x+1/2*%pi),tan(x+3/2*%pi)];
2317 [-cot(x),-cot(x),-cot(x),-cot(x)]$
2318 [cot(x-3/2*%pi),cot(x-1/2*%pi),cot(x+1/2*%pi),cot(x+3/2*%pi)];
2319 [-tan(x),-tan(x),-tan(x),-tan(x)]$
2320 kill(i, ei, oi);
2321 done$
2323 /* Bug #3148: sign can't figure out sign(a - b) but it knows sign(b - a) where a and b are exponentials */
2324 assume(t>0);
2325 [t>0]$
2326 sign(2^(500000*t)-2^(500007*t));
2327 neg$
2328 sign(2^(500007*t)-2^(500000*t));
2329 pos$
2330 forget(t>0);
2331 [t>0]$
2333 /* Bug #3246: Integrating u'(x) * f(u(x) + c) fails for f any inverse trigonometric/hyperbolic function */
2334 /* Also make sure that all the antiderivatives of (inverse) trigonometric/hyperbolic functions are correct. */
2335 integrate(map(lambda([f], diff(u(x), x) * f(u(x) + c)), [asin,acos,atan,acsc,asec,acot,asinh,acosh,atanh,acsch,asech,acoth]), x);
2336 [(u(x)+c)*asin(u(x)+c)+sqrt(1-(u(x)+c)^2),(u(x)+c)*acos(u(x)+c)-sqrt(1-(u(x)+c)^2),(u(x)+c)*atan(u(x)+c)-log((u(x)+c)^2+1)/2,log(sqrt(1-1/(u(x)+c)^2)+1)/2-log(1-sqrt(1-1/(u(x)+c)^2))/2+(u(x)+c)*acsc(u(x)+c),-log(sqrt(1-1/(u(x)+c)^2)+1)/2+log(1-sqrt(1-1/(u(x)+c)^2))/2+(u(x)+c)*asec(u(x)+c),log((u(x)+c)^2+1)/2+(u(x)+c)*acot(u(x)+c),(u(x)+c)*asinh(u(x)+c)-sqrt((u(x)+c)^2+1),(u(x)+c)*acosh(u(x)+c)-sqrt((u(x)+c)^2-1),log(1-(u(x)+c)^2)/2+(u(x)+c)*atanh(u(x)+c),log(sqrt(1/(u(x)+c)^2+1)+1)/2-log(sqrt(1/(u(x)+c)^2+1)-1)/2+(u(x)+c)*acsch(u(x)+c),(u(x)+c)*asech(u(x)+c)-atan(sqrt(1/(u(x)+c)^2-1)),log(1-(u(x)+c)^2)/2+(u(x)+c)*acoth(u(x)+c)]$
2337 radcan(exponentialize(map(lambda([f], f(x) - diff(integrate(f(x), x), x)), [sin,cos,tan,csc,sec,cot,sinh,cosh,tanh,csch,sech,coth,asin,acos,atan,acsc,asec,acot,asinh,acosh,atanh,acsch,asech,acoth]))), domain:complex;
2338 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]$
2340 /* Bug #3258: integrate's answer contains diff operator with negative order */
2341 freeof(diff, integrate(%e^(c*x-r^2/(4*x))/x^(3/2),x));
2342 true$
2344 /* Bug #3220: create_list doesn't bind variables properly */
2345 errcatch (create_list (%i, %i, [1, 2, 3]));
2348 create_list (bfloat (1 - 10^-50) - 1, fpprec, [16, 100]);
2349 [0.0b0, -1.0b-50]$
2351 create_list (bfloat (3.14), fpprec, 1, 3);
2352 [3.0b0, 3.1b0, 3.14b0]$
2354 /* Bug #3356: sign(nz * nz) = nz */
2355 assume(apos > 0, aneg < 0, apz >= 0, anz <= 0, notequal(apn, 0), bpos > 0, bneg < 0, bpz >= 0, bnz <= 0, notequal(bpn, 0));
2356 [apos > 0, aneg < 0, apz >= 0, anz <= 0, notequal(apn, 0), bpos > 0, bneg < 0, bpz >= 0, bnz <= 0, notequal(bpn, 0)]$
2357 map('sign,
2358         [
2359                 apos * bpos, apos * bneg, apos * bpz, apos * bnz, apos * bpn, apos * bpnz,
2360                 aneg * bpos, aneg * bneg, aneg * bpz, aneg * bnz, aneg * bpn, aneg * bpnz,
2361                 apz * bpos, apz * bneg, apz * bpz, apz * bnz, apz * bpn, apz * bpnz,
2362                 anz * bpos, anz * bneg, anz * bpz, anz * bnz, anz * bpn, anz * bpnz,
2363                 apn * bpos, apn * bneg, apn * bpz, apn * bnz, apn * bpn, apn * bpnz,
2364                 apnz * bpos, apnz * bneg, apnz * bpz, apnz * bnz, apnz * bpn, apnz * bpnz
2365         ]
2368         'pos, 'neg, 'pz, 'nz, 'pn, 'pnz,
2369         'neg, 'pos, 'nz, 'pz, 'pn, 'pnz,
2370         'pz, 'nz, 'pz, 'nz, 'pnz, 'pnz,
2371         'nz, 'pz, 'nz, 'pz, 'pnz, 'pnz,
2372         'pn, 'pn, 'pnz, 'pnz, 'pn, 'pnz,
2373         'pnz, 'pnz, 'pnz, 'pnz, 'pnz, 'pnz
2375 forget(apos > 0, aneg < 0, apz >= 0, anz <= 0, notequal(apn, 0), bpos > 0, bneg < 0, bpz >= 0, bnz <= 0, notequal(bpn, 0));
2376 [apos > 0, aneg < 0, apz >= 0, anz <= 0, notequal(apn, 0), bpos > 0, bneg < 0, bpz >= 0, bnz <= 0, notequal(bpn, 0)]$
2378 /* test cases mentioned in bug report #3356 */
2380 (kill (a, b), assume(a<=0, b<=0), sign(a*b));
2383 (kill (q, r), assume(q<0, r<0), sign(q*r));
2384 pos;
2386 sign(a*r);
2389 sign(a*-2);
2392 sign(a*q*r);
2395 sign(a*b*q);
2398 (forget (a <= 0, b <= 0, q < 0, r < 0), 0);
2401 /* Bug #3403: Function/lambda parameters declared constant cause error */
2402 declare(c, constant);
2403 done$
2404 emptyp(errcatch(f(c) := c));
2405 false$
2406 emptyp(errcatch(lambda([c], c)));
2407 false$
2408 emptyp(errcatch(f(%e) := %e));
2409 true$
2410 emptyp(errcatch(lambda([%e], %e)));
2411 true$
2412 kill(c, f);
2413 done$
2415 /*        Bug #3009: factoring exponentials causes MAKE-ARRAY error */
2416 /* a.k.a. Bug #3146: max() runs out of memory when comparing exponential functions */
2417 sign(((-1)-%e^-(4.075321792706671E-4*d_1))*%e^-(4.075321792706671E-4*d_2)+%e^-(8.150643585413342E-4*d_2)-%e^-(4.075321792706671E-4*d_1)+%e^-(8.150643585413342E-4*d_1)+1);
2418 pnz$
2419 factor(a^1000000+a+1);
2420 a^1000000+a+1$
2421 max(2.0325-6.9825*%e^-(492380.0*t),2.103-7.053*%e^-(406810.0*t));
2422 'max(2.0325-6.9825*%e^-(492380.0*t),2.103-7.053*%e^-(406810.0*t))$
2423 sign(exp(-492380*t)-2793);
2424 pnz$
2426 /* Bug #3147: sign of expressions with exponents crashes */
2427 assume(t>0);
2428 [t>0]$
2429 sign(2^(500005*t)-2^(500001*t));
2430 pos$
2431 kill(t);
2432 done$
2434 /* Test factor_max_degree. */
2435 block([factor_max_degree : 0], [factor(x^2+2*x+1), factor(x^2-1), factor(x^2+3*x+2), factor(x^2000+x^1999)]);
2436 [(x+1)^2, (x-1)*(x+1), (x+1)*(x+2), x^1999*(x+1)]$
2437 block([factor_max_degree : 1, factor_max_degree_print_warning : false], [factor(x^2+2*x+1), factor(x^2-1), factor(x^2+3*x+2), factor(x^2000+x^1999)]);
2438 [(x+1)^2, x^2-1, x^2+3*x+2, x^1999*(x+1)]$
2439 block([factor_max_degree : 2], [factor(x^2+2*x+1), factor(x^2-1), factor(x^2+3*x+2), factor(x^2000+x^1999)]);
2440 [(x+1)^2, (x-1)*(x+1), (x+1)*(x+2), x^1999*(x+1)]$
2442 /*        Bug #2928: Loops forever: ev(ratexpand(1/(x^(2/3)+1)), algebraic:true); */
2443 /* a.k.a. Bug #2994: Infinite loop: ratsimp(x/(sqrt(x^(2/3)+1)),x),algebraic; */
2444 /* a.k.a. Bug #3419: Endless loop in BPROG (rat(1/(x^(2/3)+1)), algebraic) */
2445 (test(expr) := is(radcan(ev(rat(expr), algebraic) - expr) = 0), done);
2446 done$
2447 test(1/(x^(1/3)+1));
2448 true$
2449 test(1/(x^(2/3)+1));
2450 true$
2451 test(1/((x-1)^(2/3)+1));
2452 true$
2453 test(x/(sqrt(x^(2/3)+1)));
2454 true$
2455 kill(expr);
2456 done$
2458 /* Bug #3431: error system variable holds unsimplified list, causing errors to be repeated when trying to access it */
2459 errcatch(0^0);
2461 errcatch(print(error), true);
2462 [true]$
2464 /* SF bug #3458: "does not interpret addcol as it should but instead interprets same as addrow" */
2466 addcol (matrix (), [11, 22, 33]);
2467 matrix ([11], [22], [33]);
2469 /* additional tests for addcol and addrow */
2471 addcol (matrix (), [11, 22, 33], [111, 222, 333]);
2472 matrix ([11, 111], [22, 222], [33, 333]);
2474 addcol (matrix (), [11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2475 matrix ([11, 111, 1111], [22, 222, 2222], [33, 333, 3333]);
2477 addcol (matrix ([1, 2, 3]), [11, 22, 33]);
2478 matrix ([1, 2, 3, 11, 22, 33]);
2480 addcol (matrix ([1, 2, 3]), [11, 22, 33], [111, 222, 333]);
2481 matrix ([1, 2, 3, 11, 22, 33, 111, 222, 333]);
2483 addcol (matrix ([1, 2, 3]), [11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2484 matrix ([1, 2, 3, 11, 22, 33, 111, 222, 333, 1111, 2222, 3333]);
2486 addcol (matrix ([1], [2], [3]), [11, 22, 33]);
2487 matrix ([1, 11], [2, 22], [3, 33]);
2489 addcol (matrix ([1], [2], [3]), [11, 22, 33], [111, 222, 333]);
2490 matrix ([1, 11, 111], [2, 22, 222], [3, 33, 333]);
2492 addcol (matrix ([1], [2], [3]), [11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2493 matrix ([1, 11, 111, 1111], [2, 22, 222, 2222], [3, 33, 333, 3333]);
2495 addrow (matrix (), [11, 22, 33]);
2496 matrix ([11, 22, 33]);
2498 addrow (matrix (), [11, 22, 33], [111, 222, 333]);
2499 matrix ([11, 22, 33], [111, 222, 333]);
2501 addrow (matrix (), [11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2502 matrix ([11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2504 addrow (matrix ([1, 2, 3]), [11, 22, 33]);
2505 matrix ([1, 2, 3], [11, 22, 33]);
2507 addrow (matrix ([1, 2, 3]), [11, 22, 33], [111, 222, 333]);
2508 matrix ([1, 2, 3], [11, 22, 33], [111, 222, 333]);
2510 addrow (matrix ([1, 2, 3]), [11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2511 matrix ([1, 2, 3], [11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2514  * Seems like these should succeed, but they fail
2515  * with error about "incompatible structure", although similar calls succeed.
2516  * Just omit these tests unless addrow/addcol are ever revised for greater consistency.
2518 addrow (matrix ([1], [2], [3]), [11, 22, 33]);
2519 matrix ([1], [2], [3], [11], [22], [33]);
2521 addrow (matrix ([1], [2], [3]), [11, 22, 33], [111, 222, 333]);
2522 matrix ([1], [2], [3], [11], [22], [33], [111], [222], [333]);
2524 addrow (matrix ([1], [2], [3]), [11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2525 matrix ([1], [2], [3], [11], [22], [33], [111], [222], [333], [1111], [2222], [3333]);
2527  */
2529 addcol (matrix (), matrix ([11], [22], [33]));
2530 matrix ([11], [22], [33]);
2532 addcol (matrix (), matrix ([11, 22, 33]));
2533 matrix ([11, 22, 33]);
2535 addcol (matrix (), matrix ([11], [22], [33]), matrix ([111], [222], [333]));
2536 matrix ([11, 111], [22, 222], [33, 333]);
2538 addcol (matrix (), matrix ([11, 22, 33]), matrix ([111, 222, 333]));
2539 matrix ([11, 22, 33, 111, 222, 333]);
2541 addcol (matrix (), matrix ([11], [22], [33]), matrix ([111], [222], [333]), matrix ([1111], [2222], [3333]));
2542 matrix ([11, 111, 1111], [22, 222, 2222], [33, 333, 3333]);
2544 addcol (matrix (), matrix ([11, 22, 33]), matrix ([111, 222, 333]), matrix ([1111, 2222, 3333]));
2545 matrix ([11, 22, 33, 111, 222, 333, 1111, 2222, 3333]);
2547 addcol (matrix ([1, 2, 3]), matrix ([11, 22, 33]));
2548 matrix ([1, 2, 3, 11, 22, 33]);
2550 addcol (matrix ([1, 2, 3]), matrix ([11, 22, 33]), matrix ([111, 222, 333]));
2551 matrix ([1, 2, 3, 11, 22, 33, 111, 222, 333]);
2553 addcol (matrix ([1, 2, 3]), matrix ([11, 22, 33]), matrix ([111, 222, 333]), matrix ([1111, 2222, 3333]));
2554 matrix ([1, 2, 3, 11, 22, 33, 111, 222, 333, 1111, 2222, 3333]);
2556 addrow (matrix (), matrix ([11], [22], [33]));
2557 matrix ([11], [22], [33]);
2559 addrow (matrix (), matrix ([11, 22, 33]));
2560 matrix ([11, 22, 33]);
2562 addrow (matrix (), matrix ([11], [22], [33]), matrix ([111], [222], [333]));
2563 matrix ([11], [22], [33], [111], [222], [333]);
2565 addrow (matrix (), matrix ([11, 22, 33]), matrix ([111, 222, 333]));
2566 matrix ([11, 22, 33], [111, 222, 333]);
2568 addrow (matrix (), matrix ([11], [22], [33]), matrix ([111], [222], [333]), matrix ([1111], [2222], [3333]));
2569 matrix ([11], [22], [33], [111], [222], [333], [1111], [2222], [3333]);
2571 addrow (matrix (), matrix ([11, 22, 33]), matrix ([111, 222, 333]), matrix ([1111, 2222, 3333]));
2572 matrix ([11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2574 addrow (matrix ([1, 2, 3]), [11, 22, 33]);
2575 matrix ([1, 2, 3], [11, 22, 33]);
2577 addrow (matrix ([1, 2, 3]), [11, 22, 33], [111, 222, 333]);
2578 matrix ([1, 2, 3], [11, 22, 33], [111, 222, 333]);
2580 addrow (matrix ([1, 2, 3]), [11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2581 matrix ([1, 2, 3], [11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2583 /* addrow/addcol that should fail */
2585 errcatch (addrow (matrix ([1], [2], [3]), [11, 22, 33]));
2589  * Seems like these should fail, but they succeed.
2590  * Just omit these tests unless addrow/addcol are ever revised for greater consistency.
2592 errcatch (addrow (matrix ([1], [2], [3]), matrix ([11, 22, 33])));
2595 errcatch (addrow (matrix ([1, 2, 3]), matrix ([1], [2], [3])));
2598 errcatch (addcol (matrix ([1, 2, 3]), matrix ([1], [2], [3])));
2601 errcatch (addcol (matrix ([1], [2], [3]), matrix ([11, 22, 33])));
2604  */