4 /* make sure things work after a reset(). ID: 1986726 and ID: 2787047
6 * display2d is a resettable option variable. We save the value of display2d
7 * and restore it after the reset. This allows to run the testsuite in both
10 (save:display2d, done);
14 (display2d:save, 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)]);
54 /* Verify that grind treats nouns correctly. string calls MSIZE in src/grind.lisp.
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.
79 string ('"+"(a, b, '"."(c, d), '"^"(e, f)));
80 "'?mplus(a,b,'?mnctimes(c,d),'?mexpt(e,f))";
84 -%i*log((%i*y+x)/sqrt(x^2+y^2));
85 rectform(ev(%,x=-1,y=1));
89 * Bug [ 1661490 ] An integral gives a wrong result.
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
99 * Should return the integral instead of producing false.
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);
109 * Bug [ 1854888 ] hgfred([5],[5], 1) doesn't simplify
115 * Bug [ 1858964 ] hgfred([7],[-1], x) --/--> error
121 * Bug [ 1858939 ] hgfred([-1],[-2],x) --> error
124 /* Because of revision 1.110 of hyp.lisp gen_laguerre simplifies
125 -gen_laguerre(1,-3,x)/2; */
129 * Tests for the :: operator
152 /* Bug [ 1860250 ] erf(-inf) --> -erf(inf) */
166 /* Bug [ 1950653 ] bessel_j not simplified
167 * A few additional related tests added too.
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
181 block([fpprintprec:5], string(1.23b0));
184 block([fpprintprec:5], string(1.2345b0));
187 block([fpprintprec:5], string(1.23456789b0));
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",
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",
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)),
271 /* SF bug #3213: "fpprintprec do not round bfloat correctly." */
273 (reset (fpprec, bftrunc),
275 string (1.23456789b0));
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;
292 string (bfloat ((1 + 8/9)/1000000000000)), fpprec=2;
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;
330 every (lambda ([s], s="5.56b-4"), map (string, makelist (bfloat (5/9000), fpprec, fpprintprec, 40))), fpprintprec=3;
333 every (lambda ([s], s="5.556b2"), map (string, makelist (bfloat (5000/9), fpprec, fpprintprec, 40))), fpprintprec=4;
336 every (lambda ([s], s="5.5556b-4"), map (string, makelist (bfloat (5/9000), fpprec, fpprintprec, 40))), fpprintprec=5;
339 every (lambda ([s], s="5.55556b2"), map (string, makelist (bfloat (5000/9), fpprec, fpprintprec, 40))), fpprintprec=6;
342 every (lambda ([s], s="5.555556b-4"), map (string, makelist (bfloat (5/9000), fpprec, fpprintprec, 40))), fpprintprec=7;
345 every (lambda ([s], s="5.5555556b2"), map (string, makelist (bfloat (5000/9), fpprec, fpprintprec, 40))), fpprintprec=8;
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.
358 mybf : bfloat(5/9000),
359 is (rationalize (mybf) >= (5*sum(10^i, i, 0, fpprec)/10^(fpprec + 1))/1000));
362 every (lambda ([s], s="5.6b-4"), map (string, makelist (mybf, fpprintprec, fpprec, 40)));
366 mybf : bfloat(5000/9),
367 is (rationalize (mybf) >= (5*sum(10^i, i, 0, fpprec)/10^(fpprec + 1))*1000));
370 every (lambda ([s], s="5.56b2"), map (string, makelist (mybf, fpprintprec, fpprec, 40)));
374 mybf : bfloat(5/9000),
375 is (rationalize (mybf) >= (5*sum(10^i, i, 0, fpprec)/10^(fpprec + 1))/1000));
378 every (lambda ([s], s="5.556b-4"), map (string, makelist (mybf, fpprintprec, fpprec, 40)));
382 mybf : bfloat(5000/9),
383 is (rationalize (mybf) >= (5*sum(10^i, i, 0, fpprec)/10^(fpprec + 1))*1000));
386 every (lambda ([s], s="5.5555b2"), map (string, makelist (mybf, fpprintprec, fpprec, 40)));
390 mybf : bfloat(5/9000),
391 is (rationalize (mybf) >= (5*sum(10^i, i, 0, fpprec)/10^(fpprec + 1))/1000));
394 every (lambda ([s], s="5.555555556b-4"), map (string, makelist (mybf, fpprintprec, fpprec, 40)));
398 mybf : bfloat(5000/9),
399 is (rationalize (mybf) >= (5*sum(10^i, i, 0, fpprec)/10^(fpprec + 1))*1000));
402 every (lambda ([s], s="5.5555555555555555556b2"), map (string, makelist (mybf, fpprintprec, fpprec, 40)));
406 mybf : bfloat(5/9000),
407 is (rationalize (mybf) >= (5*sum(10^i, i, 0, fpprec)/10^(fpprec + 1))/1000));
410 every (lambda ([s], s="5.555555555555555555555555555555555555555b-4"), map (string, makelist (mybf, fpprintprec, fpprec, 40)));
417 * Bug 2142758: integrate(sqrt(2-2*x^2)*(sqrt(2)*x^2+sqrt(2))/(4-4*x^2),x,0,1)
419 integrate(sqrt(2-2*x^2)*(sqrt(2)*x^2+sqrt(2))/(4-4*x^2),x,0,1);
423 integrate(sqrt(1-x^2)*(x^2+1)/(2-2*x^2),x,0,1);
426 integrate(sqrt(1-x^2)*(x^2+1)/(1-x^2),x,0,1);
430 * Bug [ 2208303 ] Problem with jacobi_dn and elliptic_kc
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
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
450 is(abs(jacobi_cn(100.0, 0.7)) < 1);
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.
459 jacobi_sn(elliptic_kc(1-m)*%i/2,m);
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
468 jacobi_sc(elliptic_kc(m)/2,m);
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))))
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
485 is(abs(asinh(%i*2b0)-expand(bfloat(asinh(%i*2)))) < 3b-17);
489 * Bug 2543079: bfloat(gamma(3/4)/gamma(1/4)) is wrong.
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
497 (assume(zn<0), 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
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);
509 /* (-1.0b0)^(1/3) vs (-1.0d0)^(1/3) - ID: 619927 */
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
538 float((2^60-1)/2^60)-1;
540 float((2^1000-1)/2^1000)-1;
544 * Bug [ 2687962 ] hgfred([-3/2,1],[-1/2],-t) division by zero
546 * Solution from functions.wolfram.com
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
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);
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
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;
596 sin(%e^(%e^(2*x+1))),numer;
597 sin(%e^(%e^(2*x+1)));
599 /* Additionally simplifications when %enumer TRUE */
605 sin(2.7182818284590451^x);
607 sin(%e^(%e^(2*x+1))),numer;
608 sin(2.7182818284590451^(2.7182818284590451^(2*x+1)));
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.
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));
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"
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"
653 * Some examples to show simplification of expressions of the form
654 * (a*b*...)^q*(a*b*...)^r, where q+r=1
657 sqrt(-%i)*sqrt(-%i)*%i;
660 sqrt(a*b)*sqrt(a*b)*a*b;
663 (a*b*c)^(3/4)*(a*b*c)^(1/4)*c;
667 * Bug ID: 2792493 "hgfred([1],[-5.2],x);"
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 */
682 /* BUG ID 2029041 a*sqrt(2)/2 unsimplified */
687 /* BUG ID 1923119 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);
697 /* BUG ID: 1480562 2*a*2^k isn't simplified to a*2^(k+1) */
705 /* Some examples to show simplification of expressions
706 * with floating point and bigfloat numbers after improvement
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.
735 horner(x^2+x=a*x^2+b*x);
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.
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 */
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)
770 1/sqrt(2)+%i/sqrt(2);
772 1/sqrt(2)-%i/sqrt(2);
775 * Bug ID: 2831259 - bfloat() underflow bug
783 * BUG ID: 2835098 - SIGN-PREP strangeness
786 block ([?limitp : true], sign (foo (x)));
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
799 (assume(b>0,c>0),done);
802 integrate(x,x,0,sqrt(b^2+(b-c)^2));
806 * BUG ID: 2842060 - unsimplified result from integrate
809 /* The result for a general symbol x */
810 integrate(1/x/sqrt(x^2-1),x);
816 /* abs(x) simplifies to x for x>0 */
817 integrate(1/x/sqrt(x^2-1),x);
824 * Bug ID: 2820202 - rootscontract(%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
833 (-1)*(-1)^n simplifies already to -(-1)^n
834 * Adding tests for both cases.
845 /* Bug ID: 2835634 - logcontract broken
846 * Bug ID: 1467368 - logcontract returns unsimplified expr
848 logcontract(log(x)-log(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
860 realpart(sqrt(4*%e^2009-3)-1);
865 /* Bug ID: 640332 - Need to specdisrep more systematically
866 Add the examples of the bug report.
868 ratdisrep(diff(rat(x),rat(x)));
872 outofpois(diff(intopois(sin(x)),x));
874 taylor(intopois(sin(x)),x,0,3);
876 ratsimp(intopois(sin(x)));
879 /* Bug ID: 627759 - Ratdisrep of aggregates
883 ratdisrep(rat([x=a,y=b]));
885 ratdisrep(rat(matrix([a,b],[c,d])));
888 /* Bug ID: 711885 - Rootscontract with imaginaries fails
890 (oldvalue:radexpand, radexpand:false, 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)));
900 (radexpand:oldvalue, done);
903 /* BUG ID: 767556 - Distributing operations over =
904 * The operators "." and "^^" distribute over equations.
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.
921 (oldfpprec:fpprec, fpprec:5, done);
923 is(bfloat((2^20+1)/(2^20-1)) - 1b0 > 0);
926 /* Related to the fix for 2914176. Didn't handle the ratio 0/1 */
930 (fpprec:oldfpprec, done);
933 /* Bug ID:2933882 - Power function: 0^a not fully implemented
934 * Show some simplifications of 0^a
947 errcatch(0^(-1/2+%));
955 /* Bug ID: 2938078 - Crash on attached input
958 declare(n,integer, j,noninteger);
960 assume(equal(x,n), equal(y,j), equal(z,i));
961 [equal(x, n), equal(y, j), equal(z,i)];
965 featurep(x,noninteger);
969 featurep(y,noninteger);
975 remove(n,integer, j,noninteger);
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
983 integrate((1-cos(2*x)^2)^2/x^4,x,0,inf);
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);
996 /* Bug ID: 777564 - subtraction "-"(a,b) should work/FIX */
1016 map("-",[a,x,100],[b,y,20]);
1019 map("-",[a,x,100],[b,y,20],[c,z,10]);
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.
1032 /* Bug ID: 2961822 - sinh(0.0b0) causes Maxima to abort
1037 /* Bug ID: 1219846 - properties of translated functions
1038 * The property noun is already present
1049 [transfun,function,noun];
1053 /* Bug ID: 2968344 - gamma_incomplete(1.0, 4.368265444147715e+19) fails
1055 gamma_incomplete(1.0, 4.368265444147715e+19);
1058 /* Bug ID: 643254 - orderlessp([rat(x)], [rat(x)])
1060 orderlessp([rat(x)],[rat(x)]);
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
1067 is(equal(binomial(x,x),1));
1069 is(equal(binomial(x^2,x^2),1));
1072 /* Bug ID:856209 - inconsistency between facts() and facts(v)
1073 * Show that facts(expr) now works more general.
1088 /* Bug ID: 840848 - trigreduce doesn't enter unknown functions
1090 trigexpand(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);
1100 is(abs(rectform(1e160/(1e160+3/2*%i))-1) < 1.5e-160);
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).
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);
1113 /* Bug ID: 2907727 - Incorrect Integral with option integrate_use_rootsof
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)
1125 integrate(sqrt(sin(t)^2+cos(t)^2),t,0,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
1140 exp(2*%i*%pi+x*%i*%pi);
1143 log(exp((2+x)^2*%i*%pi));
1149 exp((2.0+x)*%i*%pi);
1152 exp(2.0*%i*%pi+x*%i*%pi);
1155 log(exp((2.0+x)^2*%i*%pi));
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));
1177 exp((3/2+x)*%pi*%i);
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.)
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.
1194 (fpprec:16, atan(-1b20));
1195 -1.570796326794897b0;
1197 1.570796326794897b0;
1200 * Bug ID: 2991924 - Incorrect integration of rational functions
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()
1210 coeff(2*%e^x, x, 0);
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
1219 * Also add a test for complex rational argument, which wasn't handled
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).
1226 closeto(zeta(3)-1.202056903159594,1e-15), numer:true;
1228 closeto(zeta(3+%i)-(1.10721440843141 - .1482908671781754*%i), 1e-15);
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
1237 closeto(abs(zeta(1/2+.5*%i)) - 1.06534921249378, 1e-14);
1240 /* Bug ID: 2997401 - float(log(200!)) produces an error
1243 closeto(float(log(200!))-863.2319871924054, 1e-15);
1246 closeto(float(log((1+200!)/7))-861.2860770433501, 1e-15);
1249 /* Additional tests */
1250 closeto(float(log(-1))-float(%pi)*%i, 1e-15);
1253 closeto(float(log((1+200!)/(-7))) - (3.141592653589793*%i + 861.2860770433501), 1e-14);
1256 closeto(float(log((1+200!)+(1+199!)*%i))- (.004999958333958322*%i + 863.2319996922491), 1e-15);
1259 closeto(float(log((1+200!)/7+(1+199!)/11*%i)) - (.003181807444342708*%i + 869.9736929490153), 1e-15);
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
1292 /* Bug ID:1723548 - gradef for variables: not used in diff
1293 * Show that the total differential of f works in expressions too.
1298 'diff(f,y,1)*del(y)+'diff(f,x,1)*del(x)$
1300 3*'diff(f,y,1)*del(y)+3*'diff(f,x,1)*del(x)$
1302 a*'diff(f,y,1)*del(y)+a*'diff(f,x,1)*del(x)+f*del(a)$
1303 remove(f,dependency);
1306 /* Bug ID: 1089719 addrow creates strange matrix
1311 matrix([0,0],[0,0])$
1315 matrix([11,0],[0,0])$
1319 /* Bug ID: 1663385 - declare multiplicative - wrong simplification
1321 declare(f,additive,f,multiplicative);
1328 /* Bug ID: 816808 - subst(in)part of rat -- internal errs
1332 substinpart(4,2/3,2);
1335 /* Bug ID: 1117533 - letsimp complains about assignment to %pi
1337 matchdeclare(a,true);
1339 (let(%pi*a,foo(a)),done);
1346 /* Bug ID: 2805600 depends() partially prevents diff() to work
1352 remove(t,dependency);
1355 /* Bug ID: 1184718 - AT needs soime basic simplifications
1360 /* Bug ID: 2998227 - spurious at(0,A=0)
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
1367 closeto(elliptic_ec(2.0)-(.5990701173677959*%i+0.599070117367796), 1.5e-15);
1370 /* Bug ID: 1929287 - 0.0 + [0] ---> [0]
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
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
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'
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'
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);
1410 /* Bug report ID: 3023978 - integrate(x^x+x,x) is wrong
1413 'integrate(exp(x*log(x)),x)+x^2/2;
1415 /* Bug report ID: 2465066 - unsimplified result from integrate
1417 matchdeclare(x, symbolp);
1419 (tellsimpafter('integrate(f(x),x), g(x)),done);
1421 integrate(5*f(x) + 7,x);
1426 /* Bug report ID: 2789110 - solve, tan and atan depend on order of variables
1428 solve(tan(x - atan(a/b)) = 0, x);
1430 solve(tan(x - atan(b/a)) = 0, x);
1433 /* Bug report ID: 1961494 - translated functions & values list
1435 (kill(all), f():= x:2, translate(f));
1443 /* The value of x has been removed. */
1447 /* Bug report ID: 3025038 - gruntz needs logexpand:true
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)
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
1462 integrate(log(x),x,0,a);
1467 /* Bug report ID: 3062883 - diff does not recognize indirect dependencies
1471 depends([a,b],x,x,t);
1474 -'diff(a,x,1)*'diff(x,t,1);
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);
1480 /* Bug report ID: 3080397 - laplace(unit_step(-t),t,s) generates an error.
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
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),
1493 /* This should signal an error that we catch */
1494 e : errcatch(lbfgs(C(r), [r], [1], 1e-4, [1,0])),
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.
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);
1509 errcatch(integrate(%pi*exp(-2*%pi*t)*exp(2*%pi*x*t*%i),t,minf,inf));
1513 ["defint: integral is divergent."];
1515 (forget(equal(x,0)),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.
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
1549 /* Bug ID: 3118770 - %edispflag:true causes a bug
1553 integrate(x/(%e)^(2*x), x, 0, 1);
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).
1569 /* Bug ID: 3133916 - scanmap(minfactorial,a!) infinite loop
1571 scanmap(minfactorial, a!);
1574 /* Bug ID: 3131324 - simplification of sqrt
1576 sqrt(x^3)/sqrt(x^3);
1579 /* Bug ID: 1285104 - trigsimp and trigreduce & square roots
1582 trigreduce(sqrt(r^2*sin(x)^2+r^2*cos(x)^2));
1584 trigreduce(sqrt(r^2*sin(x)^2+r^2*cos(x)^2)),radexpand:all;
1588 trigreduce(sqrt(r^2*sin(x)^2+r^2*cos(x)^2));
1593 /* Bug ID: 917283 - Comment syntax confused
1594 * Show that nested comments work as expected.
1598 a/*/**/*/+/*/**/*/b;
1601 /* Bug ID: 3138054 - bfloat problem / FIX -
1603 exp(gamma(1/3)),bfloat;
1606 /* Bug ID: 3288989 - Lisp functions and linear display
1607 * Show that we do not get a Lisp error.
1609 grind(?cdr([a,b,c]));
1612 /* Bug ID: 3291590 - Problems with fast arrays
1614 (a:make_array(hashed), done);
1623 /* Cutting out these two examples.
1624 * The ordering of the lists is different depending on the underlying Lisp.
1627 * [hash_table,1,100,x,x*y];
1629 * [100,sin(x),y+x^2];
1632 (f:make_array(functional, 'factorial, hashed), done);
1640 (a: make_array(fixnum, 2, 2), done);
1645 use_fast_arrays:true;
1648 (array(a, any, 2, 2), done);
1651 [declared, 2, [2, 2]];
1652 (array(a, fixnum, 2, 2), done);
1655 [declared, 2, [2, 2]];
1656 (array(a, flonum, 2, 2), done);
1659 [declared, 2, [2, 2]];
1660 (array(a, hashed), done);
1665 reset(use_fast_arrays);
1670 /* Bug ID: 3247367 - expand returns unsimplified
1674 sqrt(2)+sqrt(2)+sqrt(2);
1676 sqrt(2)+sqrt(2)+sqrt(2)+sqrt(2);
1678 sqrt(2)+sqrt(2)+sqrt(2)+sqrt(2)+sqrt(2);
1681 2*sqrt(2)+3*sqrt(2);
1683 3*sqrt(2)+2*sqrt(2);
1685 3*sqrt(2)+2*sqrt(2)+sqrt(2);
1687 sqrt(2)+3*sqrt(2)+2*sqrt(2);
1690 sqrt(1/2)+sqrt(1/2);
1692 sqrt(1/2)+sqrt(1/2)+sqrt(1/2);
1694 sqrt(1/2)+sqrt(1/2)+sqrt(1/2)+sqrt(1/2);
1696 sqrt(1/2)+sqrt(1/2)+sqrt(1/2)+sqrt(1/2)+sqrt(1/2);
1699 2*sqrt(1/2)+3*sqrt(1/2);
1701 3*sqrt(1/2)+2*sqrt(1/2);
1703 3*sqrt(1/2)+2*sqrt(1/2)+sqrt(1/2);
1705 sqrt(1/2)+3*sqrt(1/2)+2*sqrt(1/2);
1710 2^(1/5)+2^(1/5)+2^(1/5);
1712 2^(1/5)+2^(1/5)+2^(1/5)+2^(1/5);
1714 2^(1/5)+2^(1/5)+2^(1/5)+2^(1/5)+2^(1/5);
1717 (1/2)^(1/5)+(1/2)^(1/5);
1719 (1/2)^(1/5)+(1/2)^(1/5)+(1/2)^(1/5);
1721 (1/2)^(1/5)+(1/2)^(1/5)+(1/2)^(1/5)+(1/2)^(1/5);
1723 (1/2)^(1/5)+(1/2)^(1/5)+(1/2)^(1/5)+(1/2)^(1/5)+(1/2)^(1/5);
1726 2*(1/2)^(1/5)+3*(1/2)^(1/5);
1728 3*(1/2)^(1/5)+2*(1/2)^(1/5);
1733 2^sin(x)+2^sin(x)+2^sin(x);
1735 2^sin(x)+2^sin(x)+2^sin(x)+2^sin(x);
1737 2^sin(x)+2^sin(x)+2^sin(x)+2^sin(x)+2^sin(x);
1740 (1/2)^sin(x)+(1/2)^sin(x);
1742 (1/2)^sin(x)+(1/2)^sin(x)+(1/2)^sin(x);
1744 (1/2)^sin(x)+(1/2)^sin(x)+(1/2)^sin(x)+(1/2)^sin(x);
1746 (1/2)^sin(x)+(1/2)^sin(x)+(1/2)^sin(x)+(1/2)^sin(x)+(1/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);
1755 3*sqrt(2)+2*sqrt(2);
1757 2*sqrt(2)+3*sqrt(2);
1759 (1-sqrt(5))^3, expand;
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];
1769 2^(3/5+x)+2^(-2/5+x);
1772 /* -----------------------------------------------------------------------------
1773 * Bug ID: 1439566 - zerobern & bernpoly
1774 * Show that the option variable zerobern does not change the results.
1775 * -------------------------------------------------------------------------- */
1781 x^5-5*x^4/2+5*x^3/3-x/6$
1785 /* Show that bern no longer fails with zerobern:false.
1787 * The compared values are from A&S p810, Table 23.2.
1792 -261082718496449122051/13530$
1801 596451111593912163277961/282$
1808 /* -----------------------------------------------------------------------------
1809 * Bug ID: 2905929 - gcdex
1810 * -------------------------------------------------------------------------- */
1813 ratdisrep(gcdex(x-7, x-8));
1816 is(equal(gcdex(z^2-1, 0, z), [1,0,z^2-1]));
1819 is(equal(gcdex(0, z^2-1, z), [0, 1, z^2-1]));
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]));
1825 is(equal(gcdex(x*(y+1), y^2-1, x), [0,1/(y^2-1),1]));
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);
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)
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)
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);
1894 closeto(elliptic_e(float(%pi), .9) - 2*elliptic_ec(.9), 1e-15);
1896 closeto(elliptic_e(bfloat(%pi), .1b0) - 2*elliptic_ec(.1b0), 1e-16);
1898 closeto(elliptic_e(bfloat(%pi), .9b0) - 2*elliptic_ec(.9b0), 1e-16);
1901 closeto(elliptic_f(float(%pi), .1) - 2*elliptic_kc(.1), 1e-15);
1903 closeto(elliptic_f(float(%pi), .9) - 2*elliptic_kc(.9), 1e-15);
1905 closeto(elliptic_f(bfloat(%pi), .1b0) - 2*elliptic_kc(.1b0), 1e-16);
1907 closeto(elliptic_f(bfloat(%pi), .9b0) - 2*elliptic_kc(.9b0), 1e-16);
1911 * Bug 3526111 - float erf (%i) not working
1914 closeto(float(erf(%i)) - 1.650425758797543*%i, 1e-15);
1918 * Bug 3529992: Shi (sinh integral) wrong branch, integrate inconsistent
1920 closeto(float(expintegral_shi(1/2) - 0.50699674981966719583), 3e-16);
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);
1934 polarform((a+1)/2 - a/2 - 0.5b0);
1938 /* #2531 Integration with inf */
1939 errcatch(integrate((1+1/x)^(1/2),x,1,inf));
1943 ["defint: integral is divergent."];
1948 * ID: 3440046: elliptic_f(0.5,1) signals error
1950 * Add a few more tests for invalid values.
1952 closeto(elliptic_f(0.5,1)-elliptic_f(1/2,1), 1e-15);
1955 closeto(elliptic_f(0.5b0,1) - bfloat(elliptic_f(1/2,1)), 1b-16);
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
1971 integrate(bessel_y(1,z),z);
1974 integrate(bessel_j(1,z),z);
1977 integrate(bessel_k(1,z),z);
1980 integrate(bessel_i(1,z),z);
1984 * Bug 3381301: log(-1.0b0) has small realpart
1986 realpart(log(-1b0));
1990 * Bug 3559064: elliptic_f(2,1) is wrong.
1992 errcatch(elliptic_f(2,1));
1996 * Bug 2528: A variable should be real if it is both real and complex
1998 (declare(foo, real), declare(foo, complex), 0);
2001 [realpart(foo), imagpart(foo)];
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));
2027 /* #2602: some-bfloatp and some-floatp recursed wrongly on rat expressions */
2028 ?some\-bfloatp(rat(1/2));
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));
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);
2047 /* #2675 (1/3): Integration yields noun form with subscripted variable */
2048 integrate(exp(-(1+%i)*x[1]),x[1],0,inf);
2051 /* #2688: %e^^A returns element by element exponent */
2052 is(%e^^matrix([1,2],[3,4]) = %e^matrix([1,2],[3,4]));
2055 /* #2676: Integral incorrect when variable is subscripted */
2056 integrate(x[1]*exp(x[1]), x[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))));
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. */
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);
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.)
2110 /* Don't really care what the answer is as long as we don't signal an error */
2111 is(errcatch(exp(1b19)) # []);
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] */
2122 closeto(li[3](1.0) - zeta(3.0), 1e-15);
2125 closeto(li[3](0.5) - li[3](1/2), 1e-15);
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);
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);
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;
2146 closeto(li[2](2.0) - (%pi^2/4 - %i*%pi*log(2)), 2.513e-15), numer;
2149 closeto(li[2]((1-sqrt(5))/2) - (log((sqrt(5)-1)/2)^2/2-%pi^2/15), 1.1103e-16), numer;
2152 /* Catalan's constant: 0.915965594... */
2153 closeto(li[2](1.0*%i) - (-%pi^2/48 + %i*0.915965594177219015054603514932384110774149374281672134266), 1.3878e-15), numer;
2156 closeto(li[2](1.0-%i) - (%pi^2/16-%i*0.915965594177219015054603514932384110774149374281672134266 - %pi*%i*log(2)/4), 4.5e-16), numer;
2159 /* Make sure li[3](1/7),numer returns a float and not a bfloat */
2160 ?floatp(li[3](float(1/7)));
2163 ?floatp(realpart(li[2](1.0+1.0*%i)));
2166 closeto(li[3](0.5) - float((7*zeta(3))/8+log(2)^3/6-(%pi^2*log(2))/12), 1.1103e-16);
2169 closeto(float(li[3](exp(%pi*%i/3))) - float(zeta(3)/3 + %i*5*%pi^3/162), 5.6611e-16);
2173 * li[3] should not return a small imaginary part for this value.
2174 * (There are others, but the solution fixes those as well.
2176 imagpart(li[3](-.862));
2180 * Likewise li[s](-1.5) was returning small imaginary parts. In fact,
2181 * this was true for -2 < z < -1 because the log series was used to
2182 * compute the value. Check that we return exactly zero now for
2183 * select values of s
2186 makelist(imagpart(li[s](-1.5)), s, 4, 10);
2187 [0, 0, 0, 0, 0, 0, 0];
2189 /* Bug 3582: numerical evaluation of li[2] */
2190 /* this gave an infinite loop */
2191 closeto(li[2]( 0.5 + %i* 0.6) - ( 0.7535498331267791 * %i + 0.4081870726952078 ), 1e-15);
2194 /* Bug 3112: zeta(n) for negative even n is inaccurate */
2201 /* Bug 3105: li[s](1.0) doesn't simplify */
2202 closeto(li[4](1.0)-li[4](1), 1.11022e-16);
2205 closeto(li[4](-1.0)-li[4](-1), 1.11022e-16);
2208 closeto(li[4](1b0)-li[4](1), 10^-fpprec);
2211 closeto(li[4](-1b0)-li[4](-1), 10^-fpprec);
2216 * More numeric test for polylog function li[s](z).
2218 * The reference values were obtained from
2219 * http://functions.wolfram.com/webMathematica/FunctionEvaluation.jsp?name=PolyLog
2224 closeto(li[4](0.25) - 0.25411619074634353405967371315352,
2228 closeto(li[4](0.25b0) - 0.25411619074634353405967371315352b0,
2232 closeto(li[4](0.75) - 0.79222102797282777952948578955736,
2236 closeto(li[4](0.75b0) - 0.79222102797282777952948578955736b0,
2240 closeto(li[4](1.5) - (1.7347570807760620737768805117515 - 0.0349027048283367002627421237287*%i),
2244 closeto(li[4](1.5b0) - (1.7347570807760620737768805117515b0 - 0.0349027048283367002627421237287b0*%i),
2248 closeto(li[4](10.0) - (9.6140263862742968515251940747859 - 6.3921313179656069159740055708257*%i),
2252 closeto(li[4](10.0b0) - (9.6140263862742968515251940747859b0 - 6.3921313179656069159740055708257b0*%i),
2256 closeto(li[4](-5.0) - (-4.1064679790949702621073505378164),
2260 closeto(li[4](-5b0) - (-4.1064679790949702621073505378164b0),
2264 closeto(li[4](2.0*%i) - (-0.2113943747614829764326347997923 + 1.9289340331586646502356787803360*%i),
2268 closeto(li[4](2b0*%i) - (-0.2113943747614829764326347997923b0 + 1.9289340331586646502356787803360b0*%i),
2272 closeto(li[5](0.25) - 0.25202158817857420100669519623555,
2276 closeto(li[5](0.25b0) - 0.25202158817857420100669519623555b0,
2280 closeto(li[5](0.75) - 0.76973541059975738097269173152535,
2284 closeto(li[5](0.75b0) - 0.76973541059975738097269173152535b0,
2288 closeto(li[5](1.5) - (1.5961739456813534102689069143338 - 0.0035379572466222227823786042761*%i),
2292 closeto(li[5](1.5b0) - (1.5961739456813534102689069143338b0 - 0.0035379572466222227823786042761b0*%i),
2296 closeto(li[5](10.0) - (11.2390407376112991620107110964539 - 3.6796065713019972004384472107791*%i),
2300 closeto(li[5](10.0b0) - (11.2390407376112991620107110964539b0 - 3.6796065713019972004384472107791b0*%i),
2304 closeto(li[5](-5.0) - (-4.4800824065112010228046981292686),
2308 closeto(li[5](-5b0) - (-4.4800824065112010228046981292686b0),
2312 closeto(li[5](2.0*%i) - (-0.1139660114783041974283299769126 + 1.9734617121122917650272273558071*%i),
2316 closeto(li[5](2b0*%i) - (-0.1139660114783041974283299769126b0 + 1.9734617121122917650272273558071b0*%i),
2320 closeto(li[20](5.0) - (5.0000238783147176199891129814336 - 2.182054400942151422e-13*%i),
2324 closeto(li[20](5b0) - (5.0000238783147176199891129814336b0 - 2.182054400942151422b-13*%i),
2328 /* Bug #3194: No simplification of "tan(x+n*%pi)" and "cot(x+n*%pi)" with "n" being a declared integer */
2329 /* Also test that the "modulus 1/2" check in "%piargs-tan/cot" works correctly. */
2330 declare(i, integer, ei, even, oi, odd);
2332 [tan(x+i*%pi),cot(x+i*%pi)];
2334 [tan(x+ei*%pi),cot(x+ei*%pi)];
2336 [tan(x+oi*%pi),cot(x+oi*%pi)];
2338 [tan(x-3/2*%pi),tan(x-1/2*%pi),tan(x+1/2*%pi),tan(x+3/2*%pi)];
2339 [-cot(x),-cot(x),-cot(x),-cot(x)]$
2340 [cot(x-3/2*%pi),cot(x-1/2*%pi),cot(x+1/2*%pi),cot(x+3/2*%pi)];
2341 [-tan(x),-tan(x),-tan(x),-tan(x)]$
2345 /* Bug #3148: sign can't figure out sign(a - b) but it knows sign(b - a) where a and b are exponentials */
2348 sign(2^(500000*t)-2^(500007*t));
2350 sign(2^(500007*t)-2^(500000*t));
2355 /* Bug #3246: Integrating u'(x) * f(u(x) + c) fails for f any inverse trigonometric/hyperbolic function */
2356 /* Also make sure that all the antiderivatives of (inverse) trigonometric/hyperbolic functions are correct. */
2357 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);
2358 [(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)]$
2359 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;
2360 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]$
2362 /* Bug #3258: integrate's answer contains diff operator with negative order */
2363 freeof(diff, integrate(%e^(c*x-r^2/(4*x))/x^(3/2),x));
2366 /* Bug #3220: create_list doesn't bind variables properly */
2367 errcatch (create_list (%i, %i, [1, 2, 3]));
2370 create_list (bfloat (1 - 10^-50) - 1, fpprec, [16, 100]);
2373 create_list (bfloat (3.14), fpprec, 1, 3);
2374 [3.0b0, 3.1b0, 3.14b0]$
2376 /* Bug #3356: sign(nz * nz) = nz */
2377 assume(apos > 0, aneg < 0, apz >= 0, anz <= 0, notequal(apn, 0), bpos > 0, bneg < 0, bpz >= 0, bnz <= 0, notequal(bpn, 0));
2378 [apos > 0, aneg < 0, apz >= 0, anz <= 0, notequal(apn, 0), bpos > 0, bneg < 0, bpz >= 0, bnz <= 0, notequal(bpn, 0)]$
2381 apos * bpos, apos * bneg, apos * bpz, apos * bnz, apos * bpn, apos * bpnz,
2382 aneg * bpos, aneg * bneg, aneg * bpz, aneg * bnz, aneg * bpn, aneg * bpnz,
2383 apz * bpos, apz * bneg, apz * bpz, apz * bnz, apz * bpn, apz * bpnz,
2384 anz * bpos, anz * bneg, anz * bpz, anz * bnz, anz * bpn, anz * bpnz,
2385 apn * bpos, apn * bneg, apn * bpz, apn * bnz, apn * bpn, apn * bpnz,
2386 apnz * bpos, apnz * bneg, apnz * bpz, apnz * bnz, apnz * bpn, apnz * bpnz
2390 'pos, 'neg, 'pz, 'nz, 'pn, 'pnz,
2391 'neg, 'pos, 'nz, 'pz, 'pn, 'pnz,
2392 'pz, 'nz, 'pz, 'nz, 'pnz, 'pnz,
2393 'nz, 'pz, 'nz, 'pz, 'pnz, 'pnz,
2394 'pn, 'pn, 'pnz, 'pnz, 'pn, 'pnz,
2395 'pnz, 'pnz, 'pnz, 'pnz, 'pnz, 'pnz
2397 forget(apos > 0, aneg < 0, apz >= 0, anz <= 0, notequal(apn, 0), bpos > 0, bneg < 0, bpz >= 0, bnz <= 0, notequal(bpn, 0));
2398 [apos > 0, aneg < 0, apz >= 0, anz <= 0, notequal(apn, 0), bpos > 0, bneg < 0, bpz >= 0, bnz <= 0, notequal(bpn, 0)]$
2400 /* test cases mentioned in bug report #3356 */
2402 (kill (a, b), assume(a<=0, b<=0), sign(a*b));
2405 (kill (q, r), assume(q<0, r<0), sign(q*r));
2420 (forget (a <= 0, b <= 0, q < 0, r < 0), 0);
2423 /* Bug #3403: Function/lambda parameters declared constant cause error */
2424 declare(c, constant);
2426 emptyp(errcatch(f(c) := c));
2428 emptyp(errcatch(lambda([c], c)));
2430 emptyp(errcatch(f(%e) := %e));
2432 emptyp(errcatch(lambda([%e], %e)));
2437 /* Bug #3009: factoring exponentials causes MAKE-ARRAY error */
2438 /* a.k.a. Bug #3146: max() runs out of memory when comparing exponential functions */
2439 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);
2441 factor(a^1000000+a+1);
2443 max(2.0325-6.9825*%e^-(492380.0*t),2.103-7.053*%e^-(406810.0*t));
2444 'max(2.0325-6.9825*%e^-(492380.0*t),2.103-7.053*%e^-(406810.0*t))$
2445 sign(exp(-492380*t)-2793);
2448 /* Bug #3147: sign of expressions with exponents crashes */
2451 sign(2^(500005*t)-2^(500001*t));
2456 /* Test factor_max_degree. */
2457 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)]);
2458 [(x+1)^2, (x-1)*(x+1), (x+1)*(x+2), x^1999*(x+1)]$
2459 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)]);
2460 [(x+1)^2, x^2-1, x^2+3*x+2, x^1999*(x+1)]$
2461 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)]);
2462 [(x+1)^2, (x-1)*(x+1), (x+1)*(x+2), x^1999*(x+1)]$
2464 /* Bug #2928: Loops forever: ev(ratexpand(1/(x^(2/3)+1)), algebraic:true); */
2465 /* a.k.a. Bug #2994: Infinite loop: ratsimp(x/(sqrt(x^(2/3)+1)),x),algebraic; */
2466 /* a.k.a. Bug #3419: Endless loop in BPROG (rat(1/(x^(2/3)+1)), algebraic) */
2468 /* examples present in previous version of rtest16 */
2470 string (ev (rat (1/(x^(1/3)+1)), algebraic));
2471 "((x^(1/3))^2-x^(1/3)+1)/(x+1)";
2473 string (ev (rat (1/(x^(2/3)+1)), algebraic));
2474 "(x^(1/3)*x-(x^(1/3))^2+1)/(x^2+1)";
2476 string (ev (rat(1/((x-1)^(2/3)+1)), algebraic));
2477 "((x-1)^(1/3)*x-((x-1)^(1/3))^2-(x-1)^(1/3)+1)/(x^2-2*x+2)";
2479 string (ev (rat(x/(sqrt(x^(2/3)+1))), algebraic));
2480 "(sqrt(x^(2/3)+1)*x^(1/3)*x^2+((-sqrt(x^(2/3)+1)*(x^(1/3))^2)+sqrt(x^(2/3)+1))*x)/(x^2+1)";
2482 /* additional examples courtesy of M. Talon */
2484 string (ev (rat(1/(x^(2/5)+1)), algebraic));
2485 "(((x^(1/5))^3-x^(1/5))*x+(x^(1/5))^4-(x^(1/5))^2+1)/(x^2+1)";
2487 /* Maxima cannot yet handle this next one (incomplete factorization, gets one factor but misses the other)
2489 rat(1/(x^(3/5)+x^(1/3))),algebraic;
2492 string (ev (rat(1/(x^(4/5)+1)), algebraic));
2493 "(x^(1/5)*x^3-(x^(1/5))^2*x^2+(x^(1/5))^3*x-(x^(1/5))^4+1)/(x^4+1)";
2495 /* Bug #3431: error system variable holds unsimplified list, causing errors to be repeated when trying to access it */
2498 errcatch(print(error), true);
2501 /* SF bug #3458: "does not interpret addcol as it should but instead interprets same as addrow" */
2503 addcol (matrix (), [11, 22, 33]);
2504 matrix ([11], [22], [33]);
2506 /* additional tests for addcol and addrow */
2508 addcol (matrix (), [11, 22, 33], [111, 222, 333]);
2509 matrix ([11, 111], [22, 222], [33, 333]);
2511 addcol (matrix (), [11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2512 matrix ([11, 111, 1111], [22, 222, 2222], [33, 333, 3333]);
2514 addcol (matrix ([1, 2, 3]), [11, 22, 33]);
2515 matrix ([1, 2, 3, 11, 22, 33]);
2517 addcol (matrix ([1, 2, 3]), [11, 22, 33], [111, 222, 333]);
2518 matrix ([1, 2, 3, 11, 22, 33, 111, 222, 333]);
2520 addcol (matrix ([1, 2, 3]), [11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2521 matrix ([1, 2, 3, 11, 22, 33, 111, 222, 333, 1111, 2222, 3333]);
2523 addcol (matrix ([1], [2], [3]), [11, 22, 33]);
2524 matrix ([1, 11], [2, 22], [3, 33]);
2526 addcol (matrix ([1], [2], [3]), [11, 22, 33], [111, 222, 333]);
2527 matrix ([1, 11, 111], [2, 22, 222], [3, 33, 333]);
2529 addcol (matrix ([1], [2], [3]), [11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2530 matrix ([1, 11, 111, 1111], [2, 22, 222, 2222], [3, 33, 333, 3333]);
2532 addrow (matrix (), [11, 22, 33]);
2533 matrix ([11, 22, 33]);
2535 addrow (matrix (), [11, 22, 33], [111, 222, 333]);
2536 matrix ([11, 22, 33], [111, 222, 333]);
2538 addrow (matrix (), [11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2539 matrix ([11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2541 addrow (matrix ([1, 2, 3]), [11, 22, 33]);
2542 matrix ([1, 2, 3], [11, 22, 33]);
2544 addrow (matrix ([1, 2, 3]), [11, 22, 33], [111, 222, 333]);
2545 matrix ([1, 2, 3], [11, 22, 33], [111, 222, 333]);
2547 addrow (matrix ([1, 2, 3]), [11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2548 matrix ([1, 2, 3], [11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2551 * Seems like these should succeed, but they fail
2552 * with error about "incompatible structure", although similar calls succeed.
2553 * Just omit these tests unless addrow/addcol are ever revised for greater consistency.
2555 addrow (matrix ([1], [2], [3]), [11, 22, 33]);
2556 matrix ([1], [2], [3], [11], [22], [33]);
2558 addrow (matrix ([1], [2], [3]), [11, 22, 33], [111, 222, 333]);
2559 matrix ([1], [2], [3], [11], [22], [33], [111], [222], [333]);
2561 addrow (matrix ([1], [2], [3]), [11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2562 matrix ([1], [2], [3], [11], [22], [33], [111], [222], [333], [1111], [2222], [3333]);
2566 addcol (matrix (), matrix ([11], [22], [33]));
2567 matrix ([11], [22], [33]);
2569 addcol (matrix (), matrix ([11, 22, 33]));
2570 matrix ([11, 22, 33]);
2572 addcol (matrix (), matrix ([11], [22], [33]), matrix ([111], [222], [333]));
2573 matrix ([11, 111], [22, 222], [33, 333]);
2575 addcol (matrix (), matrix ([11, 22, 33]), matrix ([111, 222, 333]));
2576 matrix ([11, 22, 33, 111, 222, 333]);
2578 addcol (matrix (), matrix ([11], [22], [33]), matrix ([111], [222], [333]), matrix ([1111], [2222], [3333]));
2579 matrix ([11, 111, 1111], [22, 222, 2222], [33, 333, 3333]);
2581 addcol (matrix (), matrix ([11, 22, 33]), matrix ([111, 222, 333]), matrix ([1111, 2222, 3333]));
2582 matrix ([11, 22, 33, 111, 222, 333, 1111, 2222, 3333]);
2584 addcol (matrix ([1, 2, 3]), matrix ([11, 22, 33]));
2585 matrix ([1, 2, 3, 11, 22, 33]);
2587 addcol (matrix ([1, 2, 3]), matrix ([11, 22, 33]), matrix ([111, 222, 333]));
2588 matrix ([1, 2, 3, 11, 22, 33, 111, 222, 333]);
2590 addcol (matrix ([1, 2, 3]), matrix ([11, 22, 33]), matrix ([111, 222, 333]), matrix ([1111, 2222, 3333]));
2591 matrix ([1, 2, 3, 11, 22, 33, 111, 222, 333, 1111, 2222, 3333]);
2593 addrow (matrix (), matrix ([11], [22], [33]));
2594 matrix ([11], [22], [33]);
2596 addrow (matrix (), matrix ([11, 22, 33]));
2597 matrix ([11, 22, 33]);
2599 addrow (matrix (), matrix ([11], [22], [33]), matrix ([111], [222], [333]));
2600 matrix ([11], [22], [33], [111], [222], [333]);
2602 addrow (matrix (), matrix ([11, 22, 33]), matrix ([111, 222, 333]));
2603 matrix ([11, 22, 33], [111, 222, 333]);
2605 addrow (matrix (), matrix ([11], [22], [33]), matrix ([111], [222], [333]), matrix ([1111], [2222], [3333]));
2606 matrix ([11], [22], [33], [111], [222], [333], [1111], [2222], [3333]);
2608 addrow (matrix (), matrix ([11, 22, 33]), matrix ([111, 222, 333]), matrix ([1111, 2222, 3333]));
2609 matrix ([11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2611 addrow (matrix ([1, 2, 3]), [11, 22, 33]);
2612 matrix ([1, 2, 3], [11, 22, 33]);
2614 addrow (matrix ([1, 2, 3]), [11, 22, 33], [111, 222, 333]);
2615 matrix ([1, 2, 3], [11, 22, 33], [111, 222, 333]);
2617 addrow (matrix ([1, 2, 3]), [11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2618 matrix ([1, 2, 3], [11, 22, 33], [111, 222, 333], [1111, 2222, 3333]);
2620 /* addrow/addcol that should fail */
2622 errcatch (addrow (matrix ([1], [2], [3]), [11, 22, 33]));
2626 * Seems like these should fail, but they succeed.
2627 * Just omit these tests unless addrow/addcol are ever revised for greater consistency.
2629 errcatch (addrow (matrix ([1], [2], [3]), matrix ([11, 22, 33])));
2632 errcatch (addrow (matrix ([1, 2, 3]), matrix ([1], [2], [3])));
2635 errcatch (addcol (matrix ([1, 2, 3]), matrix ([1], [2], [3])));
2638 errcatch (addcol (matrix ([1], [2], [3]), matrix ([11, 22, 33])));
2643 /* Bug #3532: Integrator doesn't use a new variable internally, causing facts on the original variable to be used for the substitution variable */
2644 is(integrate(cos(x) * abs(cos(x)), x, 0, %pi) = %pi / 2);
2647 /* Bug found on mailing list thread "Wrong integral, but antiderivative and limits are correct" */
2648 integrate(x^8/(5+x^9)^2, x, 0, inf);
2651 /* Test case for bug mentioned at https://sourceforge.net/p/maxima/mailman/message/8488105/ */
2652 is(abs(integrate(1/(x^4+1), x, 0, 1/2) - 0.49396) < 0.00001);
2655 /* Another bug found on mailing list thread "Wrong integral, but antiderivative and limits are correct" */
2656 freeof(?xz, residue(plog(x)/(x-ratsimp(rectform(%e^(%i*%pi/9)))), x, %e^(%i*%pi/9)));
2659 /* Bug #3562: "integrate(1/(1+tan(x)), x, 0, %pi/2) gives complex result, should be %pi/4" */
2660 integrate(1/(1+tan(x)), x, 0, %pi/2);
2663 /* Also from bug #3562 */
2664 limit(log((x^2+1)/x^2)-2*log((x-1)/x), x, 0, minus);
2667 /* #3787 fixnump checks in simpexpt */
2668 (declare(n,integer),0);
2680 (remove(n,integer),0);
2684 * Check sech/csch don't overflow for large numbers. Use relative
2685 * error to test for accuracy.
2688 closetorel(actual, expected, tol) := block([numer:true, relerr: abs(actual-expected)/expected], if (relerr < tol) then true else relerr);
2689 closetorel(actual, expected, tol) := block([numer:true, relerr: abs(actual-expected)/expected], if (relerr < tol) then true else relerr);
2691 closeto(sech(715.0), 6.033b-311);
2693 closeto(csch(715.0), 6.033b-311);
2698 * Check acsch doesn't overflow for small numbers. But some lisps
2699 * like clisp don't support denormals, so we have to be careful.
2703 if (1e-309 = 0.0) then
2704 closetorel(acsch(1e-300), acsch(bfloat(1e-300)), 1.1375b-16)
2706 closetorel(acsch(1e-309), acsch(bfloat(1b-309)), 7.1559b-17);
2709 /* SF bug #3825: "apply('forget, facts()) gives Lisp error" */
2711 (kill (all), declare (F, increasing));
2715 [kind (F, increasing)];
2717 featurep (F, increasing);
2720 apply ('forget, facts ());
2721 [kind (F, increasing)];
2726 featurep (F, increasing);
2729 declare ([F, G], rational, [H, I], irrational);
2733 [kind (F, rational), kind (G, rational), kind (H, irrational), kind (I, irrational)];
2735 [featurep (F, rational),
2736 featurep (G, rational),
2737 featurep (H, irrational),
2738 featurep (I, irrational)];
2739 [true, true, true, true];
2741 forget (kind (G, rational), kind (I, irrational));
2742 [kind (G, rational), kind (I, irrational)];
2745 [kind (F, rational), kind (H, irrational)];
2747 forget (kind (F, rational), kind (H, irrational));
2748 [kind (F, rational), kind (H, irrational)];
2753 [featurep (F, rational),
2754 featurep (G, rational),
2755 featurep (H, irrational),
2756 featurep (I, irrational)];
2757 [false, false, false, false];
2759 /* Bug #3934: expand(1/(1+%i)^4) => (-4)^(-1) (unsimplified) */
2767 expand(4/(%i+1)^4)+1;
2770 expand(1/(1+%i)^8-1/16);
2773 expand((sqrt(-1/2)+sqrt(1/2))^-8);