Windows installer: update wxMaxima.
[maxima/cygwin.git] / tests / rtest_limit.mac
blob14f65b62660f6c9e5912532d0558106070ed6667
1 /*
2   A collection of tests to stress $limit and friends
3 */
4 (kill(all),0);
5 0$
7 /*
8   Tests to check how limit deals with weird combinations of
9   infinitesimals and infinities. See bug 2563
11 limit(zeroa*inf);
12 und$
13 limit(zerob^zerob);
14 und$
15 limit(zerob^zeroa);
16 und$
18 /* Tests from Bug 1036900 */
19 /* These bugs were fixed in limit.lisp rev 1.7, 2004/10/04 */
20 limit(7^n/8^n,n,inf);
22 limit(7^(n^2)/8^n,n,inf);
23 inf$
24 limit((10^n+9^n+8^n)^(1/n),n,inf);
25 10$
26 limit(4^n/2^(2*n),n,inf);
29 /* Test from Bug 1052308 */
30 /* Fixed in limit.lisp rev 1.11 */
31 assume(equal(zz,0));
32 [equal(zz,0)]$
33 limit(erf(nn*zz), nn, inf);
35 limit(tanh(nn*zz), nn, inf);
37 limit(nn^zz, nn, 0);
40 /* Bug 1281737, fixed in limit.lisp rev 1.15 */
41 limit(atan(x)/(1/exp(1)-exp(-(1+x)^2)),x,inf,plus);
42 %e*%pi/2;
44 /* Bug 626697 */
45 limit(atan2(y,x),y,minf);
46 -%pi/2;
48 /* Bug 1548643 */
49 limit(abs(sqrt(1-1/x)-1),x,0);
50 inf;
52 /* Bug 671574 */
53 limit(x*atan(x)/(x+1),x,inf);
54 %pi/2;
55 limit(x*atan(x)-log(x),x,inf);
56 inf;
58 /* Bug 1152668 */
59 numer:true;
60 true;
61 limit(sin(x)/x,x,0);
63 limit(sin(x)/x,x,0,plus);
65 limit(sin(x)/x,x,0,minus);
67 numer:false;
68 false;
70 /* #2504 wrong answer for simple limit, limit(sin(x)+1/x, x, inf)=0 */
71 limit(1/x + sin(x), x, inf);
72 ind;
74 /* Bug 593344 */
75 limit(abs(infinity));
76 inf;
78 /* Bug 1469411 */
79 limit(t^2*exp(-4*t/3-8*exp(-t)),t,inf);
83  * From bug 535363, but this isn't really fixed.  The fix for 1469411
84  * broke this test, so we're adding it to make sure we don't break it.
85  *
88 limit(exp(-1/x)/x^4,x,0,'plus);
91 /* Bug 1594330 */
92 limit(x*(atan(x)-%pi/2),x,inf);
93 -1;
95 limit((atan(x)-(%pi/2))/(sin(10/x)),x,inf);
96 -1/10;
98 /* [ 1498047 ] limit(a/n,n,inf); */
99 limit(a/n, n, inf);
103  * [ 1646761 ] limit atanh @ -1 / 1 all wrong...
104  */
105 /* Limit at 1 is (complex) infinity).  But one-sided limit can be inf (real infinity). */
106 limit(atanh(x),x,1);
107 infinity;
108 limit(atanh(x),x,1,'minus);
109 inf;
110 limit(atanh(x),x,-1);
111 infinity;
112 limit(atanh(x),x,-1,'plus);
113 minf;
115 /* There shouldn't be an error message printed out here.  Need to look at output to see. */
116 limit(2*atanh(x),x,1);
117 infinity;
118 limit(2*atanh(x),x,1,'minus);
119 inf;
121 limit(atanh(a-1)-log(a)/2,a,0,'plus),logarc:true;
122 -log(2)/2;
124 /* [ 1606731 ] limit of algebraic when algebraic : true */
125 limit(x*(sqrt(1+x^2)-x),x,inf), algebraic : true, gcd : subres;
126 1/2;
128 /* [ 1097982 ] limit(x/(x^(log(x)))); returns wrong answer */
129 limit(x/(x^log(x)), x, inf);
132 /* [ 1039965 ] limit(4^n/2^(2*n),n,inf) is wrong */
133 limit(4^n/2^(2*n),n,inf);
136 /* [ 1731127 ] limit((1 + 1/x)*(sqrt(x + 1) + 1), x, inf) => 0 (not inf) */
137 limit((1 + 1/x)*(sqrt(x + 1) + 1), x, inf);
138 inf;
140 /* [ 1593083 ] tlimit(t^2*exp(-4*t/3-8*exp(-t)),t,inf) gives error */
141 tlimit(t^2*exp(-4*t/3-8*exp(-t)),t,inf);
144 /* [ 1786774 ] tlimit((5^x + 3^x)^(1/x), x, inf) => Error */
145 tlimit((5^x + 3^x)^(1/x), x, inf);
148 /* [ 1603900 ] taylor/tlimit (4^n+1)/2^(2*n) internal error */
149 tlimit((4^n+1)/2^(2*n),n,inf);
152 /* [ 1281736 ] limit((x/log(x))*(x^(1/x)-1),x,inf) - wrong result */
153 limit((x/log(x))*(x^(1/x)-1),x,inf);
156 /* [ 1036901 ] tlimit(7^(n^2)/8^n,n,inf); wrong result */
157 tlimit(7^(n^2)/8^n, n, inf);
158 inf;
160 /* [ 1665657 ] limit fails to find easy limit */
161 limit(x/(x-1)-1/log(x),x,1,plus);
162 1/2;
164 /* [ 611411 ] limit asks sign of IND */
165 limit(abs(sin(x)),x,inf);
166 ind;
168 /* [ 1629723 ] bug in limit, asks sign of IND, encountered in integrator */
169 limit(abs(sin(x))/x, x, inf);
172 /* [ 782099 ] limit returns expression in IND */
173 limit(sinh(exp(%i*x)),x,inf);
174 ind;
176 /* [ 1528607 ] limit(a^x,x,inf) can't solve for a : abs(a) < 1 */
177 limit((-2/3)^x,x,inf);
180 limit(signum(x), x, 0, plus);
183 limit(signum(x), x, 0, minus);
186 limit((-1/%pi)^x,x,inf);
189 tlimit(exp(%i*t), t, inf);
190 ind;
192 tlimit(exp(-t+%i*t),t,inf);
195 /* [ 1811503 ] computing a wrong result */
196 limit((((1+1/x)^(x^2))+1)^(1/x),x,inf);
199 /* [ 1760232 ] limit(1/n * n!^(1/n), n, inf); */
200 limit(1/n * n!^(1/n), n, inf);
201 %e^-1;
203 /* Apparently wrong limit with factorial - ID: 3198530 */
204 limit(1/(2+1/factorial(n)),n,inf);
205 1/2;
207 limit(t*(erf((t))-1),t,inf);
210 /* #3153 Limits of erfc */
211 limit(erfc(x*(1 + %i)), x, inf);
214 limit(erfc(x*(1 + %i)), x, minf);
217 limit(exp(x)*(sin(1/x+exp(-x))-sin(1/x+exp(-x^2))), x, inf);
220 /* it would be nice to handle this someday
221   limit(n - exp(psi[0](n)), n, inf);
222   1/2;
225 limit(x*gamma(x), x, 0);
228 /* [ 744679 ] limit overflows memory? */
229 (assume(a>1), limit((a^(1/n)+1)^n/2^n, n, inf));
230 'sqrt(a);
232 /* [ 702512 ] limit(1/(1/a*2^(%i*a)+1),a,inf) =&gt; UND */
233 limit(1/(1/a*2^(%i*a)+1),a,inf);
236 /* [ 923407 ] limit(atan(sqrt(x))/sqrt(x),x,0) wrong */
237 limit(atan(sqrt(x))/sqrt(x),x,0);
240 /* [ 1102908 ] limit/atan/exp returns complex expr with wrong principal val */
241 limit(atan(x)/(1/exp(1)-exp(-(1+x)^2)),x,inf,plus);
242 %e*%pi/2;
244 limit( (3^(1/x) + 5^(1/x))^x, x, 0, minus);
247 limit( (3^(1/x) + 5^(1/x))^x, x, 0, plus);
250 limit( (3^(1/x) + 5^(1/x))^x, x, 0);
251 und;
253 /* [ 1852415 ] limit(sqrt(1-%e^(-x^2)), x, inf) = 0 */
254 limit(sqrt(1-%e^(-x^2)), x, inf);
257 /* [ 1515712 ] tlimit (x*atan(x)/(x+1),x,inf) => 3 %pi/2, etc */
258 tlimit(x*atan(x)/(x+1),x,inf);
259 %pi/2;
261 tlimit(x*(atan(x)-%pi/2),x,inf);
264 tlimit(atan(x^-1), x, 0, minus);
265 -%pi/2;
267 /* [ 1973399 ] F(x) := 1/%pi*(atan(x) + %pi/2) */
268 (assume(c>0), limit(((1/%pi)*(atan(n/%pi) + %pi/2))^n, n, inf));
269 %e^(-1);
271 /* [ 1103515 ] limit(atan2(x,-1),x,0) wrong */
272 limit(atan2(x,-1), x, 0, minus);
273 -%pi;
275 limit(atan2(x,-1), x, 0, plus);
276 %pi;
278 limit(atan2(x,-1), x, 0);
279 und;
280 /* ideally should be ind */
282 /* limit of atan2 - ID: 3539699 */
283 limit(atan2(x^2-2,x^3-3*x), x, sqrt(2), minus);
284 -%pi;
286 limit(atan2(x^2-2,x^3-3*x), x, sqrt(2), plus);
287 %pi;
289 limit(atan2((x^2-2), x^3-2*x), x, sqrt(2), minus);
290 atan(1/sqrt(2))-%pi;
292 limit(atan2((x^2-2), x^3-2*x), x, sqrt(2), plus);
293 atan(1/sqrt(2));
295 limit(atan2(-(x^2-2), x^3-2*x), x, sqrt(2), minus);
296 %pi-atan(1/sqrt(2));
298 limit(atan2(-(x^2-2), x^3-2*x), x, sqrt(2), plus);
299 -atan(1/sqrt(2));
301 limit(floor(x), x, 5, minus);
304 limit(floor(x), x, 5, plus);
307 limit(ceiling(x), x, 5, minus);
310 limit(ceiling(x), x, 5, plus);
313 limit(round(x), x, 5/2, minus);
316 limit(round(x), x, 5/2, plus);
319 limit(floor(sin(x)), x, 0, minus);
322 /* [ 1587235 ] limit(floor(x),x,1) wrong */
323 limit(floor(x),x,0);
324 und;
326 /* [ 1885377 ] wrong limit evaluation in 5.14.0 */
327 limit((3/4)^(5*n+1), n, inf);
330 limit(-%e^x/x, x, inf);
331 minf;
333 /* [ 2083561 ] Limit of the Wallis product */
334 limit((%pi*4^N*N!^2)/(2*2^(2*N)*gamma(N+1/2)*gamma(N+3/2)), N, inf);
335 %pi/2;
337 /* wrong limit(log(gamma(x+1))/x,x,0) - ID: 2727078 */
338 limit(log(gamma(x+1))/x, x, 0);
339 -%gamma;
341 /* log has a branch cut on negative real axis */
342 limit(log(-1+x*%i), x, 0, plus);
343 %i*%pi;
345 limit(log(-1+x*%i), x, 0, minus);
346 -%i*%pi;
348 limit((log(y+h)-log(y))/h,h,0,plus);
349 1/y;
351 /* Bug 3587 */
352 limit(log(3-sqrt(x)),x,9,minus);
353 minf;
355 /* Bug 3589 */
356 limit((sqrt(x)-2)*log(1-sqrt(x)/2),x,4,minus);
360 /* limit of incomplete gamma */
361 /* function simplim%gamma_incomplete in gamma.lisp */
363 /* sin(x^2)/(x^2) improper integral incorrect? - ID: 3397562 */
364 limit( gamma_incomplete(-1/2, -%i*x^2), x, inf);
367 /* should be complex infinity */
368 limit( gamma_incomplete(2, -%i*x), x, inf);
369 'limit(gamma_incomplete(2,-%i*x),x,inf);
371 /* Error integrating exp(-x)*sinh(sqrt(x)) with domain: complex - ID: 3529144 */
372 /* need taylor expansion of gamma_incomplete(1/2, x) at x=0 */
373 limit(gamma_incomplete(1/2,(1-2*sqrt(x))^2/4)*(1-2*sqrt(x))
374                  /(sqrt((1-2*sqrt(x))^2)), x, 1/4, minus),domain:complex;
375 sqrt(%pi);
377 limit(gamma_incomplete(1/2,(1-2*sqrt(x))^2/4)*(1-2*sqrt(x))
378                  /(sqrt((1-2*sqrt(x))^2)), x, 1/4, plus),domain:complex;
379 -sqrt(%pi);
381 /* [ 635606 ] limit(abs(log(x))) internal error, UND */
382 limit(abs(log(x)), x, 0);
383 inf;
385 limit(exp(-x)*(x*sin(x)+cos(x)), x, inf);
388 /* tex(t[1]) shouldn't change t to true */
389 tex (t[1], false);
390 "$$t_{1}$$
391 "; /* tex output contains embedded newline */
393 /* tex(x[1]^2) shouldn't get confused by debug info in expression CAR */
394 (foo : x[1]^2, tex (foo, false));
395 "$$x_{1}^2$$
396 "; /* tex output contains embedded newline */
398 /* [ 2084910 ] limit bugs */
399 limit((%pi*N^(2*N+1)*2^(2*N))/((2*N-1)^(2*N)*(2*%e*N+%e)), N, inf);
400 %pi/2;
402 /* [ 1977992 ] no limit calculation */
403 limit(abs(sin(x))/sqrt(1-cos(x)), x, 0);
404 sqrt(2);
406 /* [ 1973399 ] F(x) := 1/%pi*(atan(x) + %pi/2) */
407 /* only works with taylor_logexpand:true */
408 limit( ((1/%pi)*(atan(n/%pi) + %pi/2))^n, n, inf);
409 %e^-1;
411 /* limit(x*expintegral_ei(x),x,0) --> Error - ID: 2801821 */
412 limit(x*expintegral_ei(x), x, 0);
415 /* Limit of the factorial function - 4 problems - ID: 2841504 */
416 limit(factorial(x),x,-2,plus);
417 minf;
419 /* Calculus mistake: wrong answer: limit - ID: 3534858 */
420 limit((sin(x)-tan(x))/(x*(cos(x)-1)),x,0);
423 /* #2639 limit asks about internal variable */
424 limit(tan(x)/sqrt(tan(x)^2+1),x,%pi/2,plus);
427 limit(1/psi[1](x), x, inf);
428 inf;
430 /* limit of psi[i] - ID: 2843705 */
431 limit(psi[i](x),x,inf);
432 'limit(psi[i](x),x,inf);
434 /* tests for gruntz limit algorithm */
435 gruntz(exp(x), x, inf);
436 inf;
438 gruntz(exp(-x), x, inf);
441 gruntz( (x + 2^x) / 3^x, x, inf);
444 gruntz( x^2/(x + 2*x^2), x, inf);
445 1/2;
447 gruntz( x/x^log(x), x, inf);
450 gruntz( (2^x)/(x + exp(x)) , x, 0, plus);
453 gruntz( (erf(x))/sqrt(1-cos(x)) , x, 0, minus);
454 -2*sqrt(2)/sqrt(%pi);
456 gruntz( (erf(x))/sqrt(1-cos(x)) , x, 0, plus);
457 2*sqrt(2)/sqrt(%pi);
459 gruntz( x*(x^(1/x)-1)/log(x), x, inf);
462 gruntz( (x*x^(1/x)-x)/log(x), x, inf);
465 gruntz(exp(-1/x)/x^6,x,0,plus);
468 /* limit gives the wrong answer - ID: 3410704 */
469 limit(sqrt(t^2+4)*(((t+2/t^2)^2+4)^(3/2)-(t+2/t^2)^3-4*(t+2/t^2))
470          /(sqrt((t+2/t^2)^2+4)*((t^2+4)^(3/2)-t^3-4*t)), t, inf);
473 /* Inaccurate Limit Evaluation - ID: 3276461 */
474 radcan(limit((-4*x^2-10*x+24)/((4*x+8)^(1/3)+2), x, -4));
477 limit(-(3*n^2 + 1)*(-1)^n/sqrt(n^5 + 8*n^3 + 8),n,inf);
481  * Bug ID: 1315837 limit(?foo)
482  * Bug ID: 1119228 limit(1/zeraoa)
483  */
485 limit(?foo);
486 ?foo;
487 limit(true);
488 true;
489 limit(false);
490 false;
491 limit(1/zeroa);
492 inf;
493 limit(1/zerob);
494 minf;
497  * Bug ID: 1797296 - Crazy results when doing limit of 'diff
498  */
499 limit('diff(x+1,x),x,2);
500 'limit('diff(x+1,x),x,2);
502 limit('integrate(x+1,x),x,2);
503 'limit('integrate(x+1,x),x,2);
505 limit(integrate(f(t),t,0,x),x,0,plus);
506 'limit(integrate(f(t),t,0,x),x,0,plus);
508 limit(integrate(t,t,0,x)/x,x,inf);
509 inf;
511 (assume(a>2), limit(integrate(t/log(t),t,2,a)/a,a,inf));
512 inf;
514 /* limit(1/inf-1/minf) => 0+0 - ID: 903074 */
515 limit(1/inf-1/minf);
519  1-arg limit: limit(a*inf-inf) => minf - ID: 1385306
521  The original fix for this bug sent it to inf, assuming that the two
522  different "inf" occurrences were the same. I disagree: inf - inf
523  probably shouldn't ever be simplified to zero, but we can avoid it
524  here so we do.
526 limit(a*inf-inf);
527 und$
529 /* limit(1 - (-1/2)^inf) --> inf - ID: 2853506 */
530 limit(1 - (-1/2)^inf);
531 1-(-1)^inf/2^inf;
532 /* ideally should be 1 */
534 /* definition of derivative in terms of limit */
535 limit((sin(3*(x+h)) - sin(3*(x)))/h, h, 0, plus);
536 3*cos(3*x);
538 /* limit incorrect for -x/sqrt(1-x^2) - ID: 2869955 */
539 limit(-x/sqrt(1-x^2), x, 1, minus);
540 minf;
542 /* limit(%i*log(a),a,0) nounform (%i*und problem) - ID: 816797 */
543 limit(%i*log(x),x,0);
544 infinity;
546 /* limit(sqrt(x),x,minf) not fully evaluated - ID: 2901855 */
547 limit(sqrt(x), x, minf);
548 infinity;
550 /* #2847 limits of powers of constants */
551 limit((5+%i)^n,n,inf);
552 infinity;
554 /* limit bug - ID: 3101075 */
555 limit((2+cos(x))/(x^3*sin(x))-3/x^4,x,0,plus);
556 1/60;
558 /* #2527 exponent too big in limit */
559 limit ((cosh(sqrt(x+1))-cosh(sqrt(x)))^(1/sqrt(x)),x,inf );
562 /* #2561 limit(log(x^2),x,-20) gives 2*log(-20) */
563 limit(log(x^2),x,-20),logexpand:false;
564 log(400);
566 /* #2412 Problems with integral (x/(exp(x)+1),x,0,inf) */
567 limit(-x*log(%e^x+1)-li[2](-%e^x)+x^2/2, x, inf);
568 %pi^2/6;
570 /* The initial problem which triggers this bug */
571 declare(n,integer);
572 done;
573 limit ((sin(n*x) - n*x*cos(n*x))/n^2, x, %pi);
574 -%pi*(-1)^n/n;
576 /* #2503 Declaring x as an integer changes result of limit from 3 to inf */
577 limit((2^n+3^n)^(1/n), n,inf);
580 /* #2624 Erroneous limit result */
581 (assume(n>2), limit(x-x*(1-1/x)^n, x, inf));
584 (forget(n>2),0);
587 /* Bug ID: 593351 - limit/sin(inf)etc. should give 0, not IND
588  */
589 limit(cos(1/x)*sin(x)-sin(x),x,inf);
591 limit(cos(1/x)*sin(x)-sin(x)+a,x,inf);
594 /* Bug ID: 1376392 - limit(x/(2+sin(1/x)), x, 0); wrong result
595  */
596 limit(x/(2+sin(1/x)),x,0);
599 /* Bug ID: 1106912 - limit(x/sin(x)^2,x,inf)
600    I think the limit is not defined because the func is not defined
601    for all x > any constant.
602  */
603 limit(x/sin(x)^2,x,inf);
604 und;
606 /* Bug ID: #3459 Wrong limit calculation */
607 limit(x / (x+2^x+cos(x)),x,-inf);
610 /* Bug ID: 811522 - redundant question in limit
611  * b is assumed to be zero. Maxima now can deduce from the database
612  * that b-2 is an even number.
613  */
614 assume(equal(b,0));
615 [equal(b,0)];
616 limit(r^(b-2)*(x-r)^2,r,0);
617 'limit(r^(b-2)*(x-r)^2,r,0);
618 forget(equal(b,0));
619 [equal(b,0)];
621 /* Bug ID: 221642 limit needs %piargs to be true
622  * The implementation of simp-%atan and simpatan2 has been revised.
623  * We get more limits independent of the value of %piargs.
624  */
625 %piargs:false;
626 false;
627 limit(atan2(0,y),y,0,plus);
628 atan(0);
629 limit(atan2(0,y),y,0,minus);
630 %pi;
631 limit(atan2(x,0),x,0,plus);
632 %pi/2;
633 limit(atan2(x,0),x,0,minus);
634 -%pi/2;
635 reset(%piargs);
636 [%piargs];
638 /* Bug ID: 3002971 - limit fails where rat+subst works
639  */
640 limit(min(x,x+2,sin(x)/x),x,0);
642 limit(max(x,x+2,sin(x)/x),x,0);
645 /* Bug ID: 1969790 - limits and subscripts
646  */
647 limit(mu[inf],x,inf);
648 mu[inf];
651  * Bug 3509430: limit of tanh(x) at 0 makes no sense
652  */
653 limit(tanh(x), x, 0);
656 /* bug 2535: stack exhausted when computing limit(log(..)) */
658 limit(log(-1/3125*((-1/2*sqrt(5) + 1/2)^n - (1/2*sqrt(5) +
659 1/2)^n)^9*sqrt(5))/log(-1/5*((-1/2*sqrt(5) + 1/2)^(8*n) - (1/2*sqrt(5) +
660 1/2)^(8*n))*((-1/2*sqrt(5) + 1/2)^n - (1/2*sqrt(5) + 1/2)^n) -
661 1/5*((-1/2*sqrt(5) + 1/2)^(9*n) - (1/2*sqrt(5) +
662 1/2)^(9*n))*sqrt(5)),n,inf);
665 /* #2675 maxima will not do the simplest of definite integrals 
666    and will not factor otherwise */
667 limit(x^2*exp(-%i*x - x), x, inf);
670 /* bug #2621 gamma limit error */
672 limit(gamma(x+1/2)/(sqrt(x)*gamma(x)), x, inf);
675 /* Triggered by #2849. This result isn't great, but it's better than
676    an error. A more useful result would be und. */
677 limit (ind * inf);
678 ind * inf $
680 limit((a*exp(a*x)*sin(b*x))/(b^2+a^2)-(b*exp(a*x)*cos(b*x))/(b^2+a^2), x, 0, plus);
681 -(b/(a^2 + b^2));
683 /* Bug #2898: limit of continuous --> und */
685 limit(log(x)^2+2*log(x)+q/2+1,x,1);
686 (q+2)/2$
688 limit(log(x)^2+2*%gamma*log(x)-%pi^2/6+%gamma^2,x,1);
689 -((%pi^2-6*%gamma^2)/6)$
691 /* #2972 Wrong limits involving logs */
692 limit( 27^(log(n)/log(3))/n^3, n, inf);
695 limit( 27^(log(n)/log(3)+1)/n^3, n, inf);
698 limit( ((27^(log(n)/log(3)+1)-1)/26+n-log(n)/log(3)-1)/n^3,n,inf);
699 27/26;
701 /* examples from mailing list 2014-10-10: "Re: bug in limit code" */
703 (newcontext (), 
704  kill (beta, hbar, omega, delta, n),
705  assume (beta > 0, hbar > 0, omega > 0, delta > 0, 2*n - 1 > 0),
706  0);
709 limit (%e^(beta*hbar*omega-beta*(hbar*(2*n+1)*omega+delta))
710  /(1/(1-%e^-(beta*hbar*omega))^2
711  +(%e^-(beta*delta)-1)/(1-%e^-(2*beta*hbar*omega))), beta, inf);
714 (kill (h, d, z),
715  assume (h > 0, d > 0, z > 0, 2*h*z > d),
716  0);
719 limit ((%e^-(b*d)-1)/(1-%e^-(2*b*h*z)), b, inf);
722 (kill (a), assume (a < 0), 0);
725 limit (exp (b*a), b, inf);
728 limit((exp(a*x)-1)/(exp(a*x)+1),x,inf) ;
731 (forget (a < 0), assume (a > 0), 0);
734 limit((exp(a*x)-1)/(exp(a*x)+1),x,inf) ;
737 (forget (a > 0), assume (equal (a, 0)), 0);
740 limit((exp(a*x)-1)/(exp(a*x)+1),x,inf) ;
743 (forget (equal (a, 0)), assume (a > 0), 0);
746 integrate(%e^(-a*r)*sin(k*r),r,0,inf);
747 k/(k^2+a^2);
749 limit (a*x, x, inf);
750 inf;
752 (forget (a > 0), assume (a < 0), limit (a*x, x, inf));
753 minf;
755 (forget (a < 0), assume (equal (a, 0)), limit (a*x, x, inf));
758 killcontext (context);
759 done;
761 /* SF bug #3104: "limit(log(1 - exp(x)), x, 0, plus), numer => stack overflow" */
763 limit(log(1 - exp(x)), x, 0, plus);
764 infinity;
766 limit(log(1 - exp(x)), x, 0, plus), numer;
767 infinity;
769 limit(log(1 + exp(x)), x, 0, plus);
770 log(2);
772 limit(log(1 + exp(x)), x, 0, plus), numer;
773 0.6931471805599453;
775 /* inspired by this example from #3103; for the present purpose,
776  * it's not too important to get these specific results,
777  * only that numer doesn't cause an error here.
778  */
780 integrate(x^3/(exp(x)-1),x,0,inf);
781 'limit(6*li[4](%e^x)-6*x*li[3](%e^x)+3*x^2*li[2](%e^x)+x^3*log(1-%e^x)-x^4/4,
782        x,inf,minus) -%pi^4/15$
784 integrate(x^3/(exp(x)-1),x,0,inf), numer;
785 'limit(6.0*li[4](%e^x)-6.0*x*li[3](%e^x)+3.0*x^2*li[2](%e^x)
786                       +1.0*x^3*log(1-%e^x)-0.25*x^4,x,inf,minus)
787  -6.49393940226683$
789 /* #3142 limit((x^(1/x) - 1)*sqrt(x), x, inf) => inf */
790 limit((x^(1/x) - 1)*sqrt(x), x, inf);
793 /* #3143 limit((x^(1/x) - 1)*sqrt(x), x, 0, minus) => inf */
794 /* should really be '$infinity */
795 limit((x^(1/x) - 1)*sqrt(x), x, 0, minus);
796 'limit((x^(1/x) - 1)*sqrt(x), x, 0, minus);
798 /* SF bug #3185: "Error in sum with non-false modulus" */
800 block([modulus:7], sum(i^-2,i,1,inf));
801 'sum(i^-2,i,1,inf);
803 block([modulus:7], limit(inf));
804 inf;
806 /* SF bug #3235: "ECL lisp arithmetic error in definite integration with large limits"
807  * the bug is actually in ECL (https://gitlab.com/embeddable-common-lisp/ecl/issues/299);
808  * here we'll test a work around.
809  */
811 block ([actual, expected],
812   actual : limit(x*exp(x)*log(exp(x)+1),x,-1000,plus),
813   expected : -1000*%e^-1000*log(%e^-1000*(%e^1000+1)),
814   if ev (equal (actual, expected), logexpand='super) then true else [actual, expected]);
815 true;
817 /* accommodate different equivalent forms via 'equal' */
818 block ([actual, expected],
819   actual : integrate((x^2)*exp(x) / (1 + exp(x))^2,x,-1000,1000),
820   expected : (-(2000*%e^1000*log(%e^-1000*(%e^1000+1)))/(%e^1000+1))
821   -(2000*log(%e^-1000*(%e^1000+1)))/(%e^1000+1)
822    -((2000*%e^1000+2000)*log(%e^1000+1)
823     +(2*%e^1000+2)*li[2](-%e^1000)-1000000*%e^1000)
824      /(%e^1000+1)+(2*%e^1000*li[2](-%e^-1000))/(%e^1000+1)
825      +(2*li[2](-%e^-1000))/(%e^1000+1)-1000000/(%e^1000+1),
826   if ev (equal (actual, expected), logexpand='super) then true else [actual, expected]);
827 true;
829 /* SF bug #3244: "error trying to promote float infinity to bigfloat in sign comparison"
830  * same as test under #3235 but ensure that bigfloat assume is present to trigger bug
831  */
833 block ([actual, expected, ctxt:newcontext()],
834   assume (xfoo > 200b0),
835   actual : limit(xfoo*exp(xfoo)*log(exp(xfoo)+1),xfoo,-1000,plus),
836   expected : -1000*%e^-1000*log(%e^-1000*(%e^1000+1)),
837   killcontext (ctxt),
838   if ev (equal (actual, expected), logexpand='super) then true else [actual, expected]);
839 true;