2 A collection of tests to stress $limit and friends
8 Tests to check how limit deals with weird combinations of
9 infinitesimals and infinities. See bug 2563
18 /* Tests from Bug 1036900 */
19 /* These bugs were fixed in limit.lisp rev 1.7, 2004/10/04 */
22 limit(7^(n^2)/8^n,n,inf);
24 limit((10^n+9^n+8^n)^(1/n),n,inf);
26 limit(4^n/2^(2*n),n,inf);
29 /* Test from Bug 1052308 */
30 /* Fixed in limit.lisp rev 1.11 */
33 limit(erf(nn*zz), nn, inf);
35 limit(tanh(nn*zz), nn, inf);
40 /* Bug 1281737, fixed in limit.lisp rev 1.15 */
41 limit(atan(x)/(1/exp(1)-exp(-(1+x)^2)),x,inf,plus);
45 limit(atan2(y,x),y,minf);
49 limit(abs(sqrt(1-1/x)-1),x,0);
53 limit(x*atan(x)/(x+1),x,inf);
55 limit(x*atan(x)-log(x),x,inf);
63 limit(sin(x)/x,x,0,plus);
65 limit(sin(x)/x,x,0,minus);
70 /* #2504 wrong answer for simple limit, limit(sin(x)+1/x, x, inf)=0 */
71 limit(1/x + sin(x), x, inf);
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.
88 limit(exp(-1/x)/x^4,x,0,'plus);
92 limit(x*(atan(x)-%pi/2),x,inf);
95 limit((atan(x)-(%pi/2))/(sin(10/x)),x,inf);
98 /* [ 1498047 ] limit(a/n,n,inf); */
103 * [ 1646761 ] limit atanh @ -1 / 1 all wrong...
105 /* Limit at 1 is (complex) infinity). But one-sided limit can be inf (real infinity). */
108 limit(atanh(x),x,1,'minus);
110 limit(atanh(x),x,-1);
112 limit(atanh(x),x,-1,'plus);
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);
118 limit(2*atanh(x),x,1,'minus);
121 limit(atanh(a-1)-log(a)/2,a,0,'plus),logarc:true;
124 /* [ 1606731 ] limit of algebraic when algebraic : true */
125 limit(x*(sqrt(1+x^2)-x),x,inf), algebraic : true, gcd : subres;
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);
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);
160 /* [ 1665657 ] limit fails to find easy limit */
161 limit(x/(x-1)-1/log(x),x,1,plus);
164 /* [ 611411 ] limit asks sign of IND */
165 limit(abs(sin(x)),x,inf);
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);
176 /* #3866 limit(log(sinh(x)),x,0,'plus) --> infinity */
177 limit(log(sinh(x)),x,0,'plus);
180 /* [ 1528607 ] limit(a^x,x,inf) can't solve for a : abs(a) < 1 */
181 limit((-2/3)^x,x,inf);
184 limit(signum(x), x, 0, plus);
187 limit(signum(x), x, 0, minus);
190 limit((-1/%pi)^x,x,inf);
193 tlimit(exp(%i*t), t, inf);
196 tlimit(exp(-t+%i*t),t,inf);
199 /* [ 1811503 ] computing a wrong result */
200 limit((((1+1/x)^(x^2))+1)^(1/x),x,inf);
203 /* [ 1760232 ] limit(1/n * n!^(1/n), n, inf); */
204 limit(1/n * n!^(1/n), n, inf);
207 /* #3681 limit(n^n/(n^n+(n-1)^n),n,inf) wrong */
208 limit(n^n/(n^n+(n-1)^n), n, inf);
211 /* #3682 limit(n^(n-1)/(n^n+(n-1)^n),n,inf) gives Lisp error */
212 limit(n^(n-1)/(n^n+(n-1)^n),n,inf);
215 /* Apparently wrong limit with factorial - ID: 3198530 */
216 limit(1/(2+1/factorial(n)),n,inf);
219 limit(t*(erf((t))-1),t,inf);
222 /* #3153 Limits of erfc */
223 limit(erfc(x*(1 + %i)), x, inf);
226 limit(erfc(x*(1 + %i)), x, minf);
229 limit(exp(x)*(sin(1/x+exp(-x))-sin(1/x+exp(-x^2))), x, inf);
232 /* it would be nice to handle this someday
233 limit(n - exp(psi[0](n)), n, inf);
237 limit(x*gamma(x), x, 0);
240 /* [ 744679 ] limit overflows memory? */
241 (assume(a>1), limit((a^(1/n)+1)^n/2^n, n, inf));
244 /* [ 702512 ] limit(1/(1/a*2^(%i*a)+1),a,inf) => UND */
245 limit(1/(1/a*2^(%i*a)+1),a,inf);
248 /* [ 923407 ] limit(atan(sqrt(x))/sqrt(x),x,0) wrong */
249 limit(atan(sqrt(x))/sqrt(x),x,0);
252 /* [ 1102908 ] limit/atan/exp returns complex expr with wrong principal val */
253 limit(atan(x)/(1/exp(1)-exp(-(1+x)^2)),x,inf,plus);
256 limit( (3^(1/x) + 5^(1/x))^x, x, 0, minus);
259 limit( (3^(1/x) + 5^(1/x))^x, x, 0, plus);
262 limit( (3^(1/x) + 5^(1/x))^x, x, 0);
265 /* [ 1852415 ] limit(sqrt(1-%e^(-x^2)), x, inf) = 0 */
266 limit(sqrt(1-%e^(-x^2)), x, inf);
269 /* [ 1515712 ] tlimit (x*atan(x)/(x+1),x,inf) => 3 %pi/2, etc */
270 tlimit(x*atan(x)/(x+1),x,inf);
273 tlimit(x*(atan(x)-%pi/2),x,inf);
276 tlimit(atan(x^-1), x, 0, minus);
279 /* [ 1973399 ] F(x) := 1/%pi*(atan(x) + %pi/2) */
280 (assume(c>0), limit(((1/%pi)*(atan(n/%pi) + %pi/2))^n, n, inf));
283 /* [ 1103515 ] limit(atan2(x,-1),x,0) wrong */
284 limit(atan2(x,-1), x, 0, minus);
287 limit(atan2(x,-1), x, 0, plus);
290 limit(atan2(x,-1), x, 0);
293 /* limit of atan2 - ID: 3539699 */
294 limit(atan2(x^2-2,x^3-3*x), x, sqrt(2), minus);
297 limit(atan2(x^2-2,x^3-3*x), x, sqrt(2), plus);
300 limit(atan2((x^2-2), x^3-2*x), x, sqrt(2), minus);
303 limit(atan2((x^2-2), x^3-2*x), x, sqrt(2), plus);
306 limit(atan2(-(x^2-2), x^3-2*x), x, sqrt(2), minus);
309 limit(atan2(-(x^2-2), x^3-2*x), x, sqrt(2), plus);
312 /* #3864 limit of atan2 expression */
313 limit(atan2(0,1-3^x),x,0);
316 limit(floor(x), x, 5, minus);
319 limit(floor(x), x, 5, plus);
322 limit(ceiling(x), x, 5, minus);
325 limit(ceiling(x), x, 5, plus);
328 limit(round(x), x, 5/2, minus);
331 limit(round(x), x, 5/2, plus);
334 limit(floor(sin(x)), x, 0, minus);
337 /* #3616 limit with floor problems */
338 limit(floor(atan(x)),x,1);
341 limit(ceiling(cos(x)),x,0);
344 limit(floor(cos(x)),x,0);
347 limit(ceiling(cos(x)^2),x,0);
350 /* [ 2914296 ] Limit gets Maxima stuck */
351 /* caused blow-up in behavior-by-diff with loop up to 5th derivative */
352 limit( (log(1+x^2)-2+2*cos(x))/((sin(x))^2+2*sqrt(1-x^2)-2),x,0);
355 /* [ 1587235 ] limit(floor(x),x,1) wrong */
359 /* [ 1885377 ] wrong limit evaluation in 5.14.0 */
360 limit((3/4)^(5*n+1), n, inf);
363 limit(-%e^x/x, x, inf);
366 /* [ 2083561 ] Limit of the Wallis product */
367 limit((%pi*4^N*N!^2)/(2*2^(2*N)*gamma(N+1/2)*gamma(N+3/2)), N, inf);
370 /* wrong limit(log(gamma(x+1))/x,x,0) - ID: 2727078 */
371 limit(log(gamma(x+1))/x, x, 0);
374 /* log has a branch cut on negative real axis */
375 limit(log(-1+x*%i), x, 0, plus);
378 limit(log(-1+x*%i), x, 0, minus);
381 limit((log(y+h)-log(y))/h,h,0,plus);
385 limit(log(3-sqrt(x)),x,9,minus);
389 limit((sqrt(x)-2)*log(1-sqrt(x)/2),x,4,minus);
393 limit(log((sqrt(x^2+1))/2),x,1);
396 /* limit of incomplete gamma */
397 /* function simplim%gamma_incomplete in gamma.lisp */
399 /* sin(x^2)/(x^2) improper integral incorrect? - ID: 3397562 */
400 limit( gamma_incomplete(-1/2, -%i*x^2), x, inf);
403 /* should be complex infinity */
404 limit( gamma_incomplete(2, -%i*x), x, inf);
405 'limit(gamma_incomplete(2,-%i*x),x,inf);
407 /* Error integrating exp(-x)*sinh(sqrt(x)) with domain: complex - ID: 3529144 */
408 /* need taylor expansion of gamma_incomplete(1/2, x) at x=0 */
409 limit(gamma_incomplete(1/2,(1-2*sqrt(x))^2/4)*(1-2*sqrt(x))
410 /(sqrt((1-2*sqrt(x))^2)), x, 1/4, minus),domain:complex;
413 limit(gamma_incomplete(1/2,(1-2*sqrt(x))^2/4)*(1-2*sqrt(x))
414 /(sqrt((1-2*sqrt(x))^2)), x, 1/4, plus),domain:complex;
417 /* [ 635606 ] limit(abs(log(x))) internal error, UND */
418 limit(abs(log(x)), x, 0);
421 limit(exp(-x)*(x*sin(x)+cos(x)), x, inf);
424 /* tex(t[1]) shouldn't change t to true */
427 "; /* tex output contains embedded newline */
429 /* tex(x[1]^2) shouldn't get confused by debug info in expression CAR */
430 (foo : x[1]^2, tex (foo, false));
432 "; /* tex output contains embedded newline */
434 /* [ 2084910 ] limit bugs */
435 limit((%pi*N^(2*N+1)*2^(2*N))/((2*N-1)^(2*N)*(2*%e*N+%e)), N, inf);
438 /* [ 1977992 ] no limit calculation */
439 limit(abs(sin(x))/sqrt(1-cos(x)), x, 0);
442 /* [ 1973399 ] F(x) := 1/%pi*(atan(x) + %pi/2) */
443 /* only works with taylor_logexpand:true */
444 limit( ((1/%pi)*(atan(n/%pi) + %pi/2))^n, n, inf);
447 /* limit(x*expintegral_ei(x),x,0) --> Error - ID: 2801821 */
448 limit(x*expintegral_ei(x), x, 0);
451 /* #3865 crash from taking limit of factorial(x) + 1 */
452 limit(factorial(x) + 1, x, 0);
455 limit(1/(1-factorial(x)), x, 0, minus);
458 limit(1/(1-factorial(x)), x, 0, plus);
461 /* Limit of the factorial function - 4 problems - ID: 2841504 */
462 limit(factorial(x),x,-2,plus);
465 /* Calculus mistake: wrong answer: limit - ID: 3534858 */
466 limit((sin(x)-tan(x))/(x*(cos(x)-1)),x,0);
469 /* #2639 limit asks about internal variable */
470 limit(tan(x)/sqrt(tan(x)^2+1),x,%pi/2,plus);
473 limit(1/psi[1](x), x, inf);
476 /* limit of psi[i] - ID: 2843705 */
477 limit(psi[i](x),x,inf);
478 'limit(psi[i](x),x,inf);
480 /* tests for gruntz limit algorithm */
481 gruntz(exp(x), x, inf);
484 gruntz(exp(-x), x, inf);
487 gruntz( (x + 2^x) / 3^x, x, inf);
490 gruntz( x^2/(x + 2*x^2), x, inf);
493 gruntz( x/x^log(x), x, inf);
496 gruntz( (2^x)/(x + exp(x)) , x, 0, plus);
499 gruntz( (erf(x))/sqrt(1-cos(x)) , x, 0, minus);
500 -2*sqrt(2)/sqrt(%pi);
502 gruntz( (erf(x))/sqrt(1-cos(x)) , x, 0, plus);
505 gruntz( x*(x^(1/x)-1)/log(x), x, inf);
508 gruntz( (x*x^(1/x)-x)/log(x), x, inf);
511 gruntz(exp(-1/x)/x^6,x,0,plus);
514 /* limit gives the wrong answer - ID: 3410704 */
515 limit(sqrt(t^2+4)*(((t+2/t^2)^2+4)^(3/2)-(t+2/t^2)^3-4*(t+2/t^2))
516 /(sqrt((t+2/t^2)^2+4)*((t^2+4)^(3/2)-t^3-4*t)), t, inf);
519 /* Inaccurate Limit Evaluation - ID: 3276461 */
520 radcan(limit((-4*x^2-10*x+24)/((4*x+8)^(1/3)+2), x, -4));
523 limit(-(3*n^2 + 1)*(-1)^n/sqrt(n^5 + 8*n^3 + 8),n,inf);
527 * Bug ID: 1315837 limit(?foo)
528 * Bug ID: 1119228 limit(1/zeraoa)
543 * Bug ID: 1797296 - Crazy results when doing limit of 'diff
545 limit('diff(x+1,x),x,2);
548 limit('integrate(x+1,x),x,2);
551 /* #3767 incorrect limit (radius of convergence) */
552 limit(diff(exp(n * x), x,n)/n,n,inf);
553 'limit(diff(exp(n * x), x,n)/n,n,inf);
555 limit(integrate(f(t),t,0,x),x,0,plus);
558 limit(integrate(t,t,0,x)/x,x,inf);
561 (assume(a>2), limit(integrate(t/log(t),t,2,a)/a,a,inf));
564 /* limit(1/inf-1/minf) => 0+0 - ID: 903074 */
569 1-arg limit: limit(a*inf-inf) => minf - ID: 1385306
571 The original fix for this bug sent it to inf, assuming that the two
572 different "inf" occurrences were the same. I disagree: inf - inf
573 probably shouldn't ever be simplified to zero, but we can avoid it
579 /* limit(1 - (-1/2)^inf) --> inf - ID: 2853506 */
580 limit(1 - (-1/2)^inf);
582 /* ideally should be 1 */
584 /* definition of derivative in terms of limit */
585 limit((sin(3*(x+h)) - sin(3*(x)))/h, h, 0, plus);
588 /* limit incorrect for -x/sqrt(1-x^2) - ID: 2869955 */
589 limit(-x/sqrt(1-x^2), x, 1, minus);
592 /* limit(%i*log(a),a,0) nounform (%i*und problem) - ID: 816797 */
593 limit(%i*log(x),x,0);
596 /* limit(sqrt(x),x,minf) not fully evaluated - ID: 2901855 */
597 limit(sqrt(x), x, minf);
600 /* #2847 limits of powers of constants */
601 limit((5+%i)^n,n,inf);
604 /* limit bug - ID: 3101075 */
605 limit((2+cos(x))/(x^3*sin(x))-3/x^4,x,0,plus);
608 /* #2527 exponent too big in limit */
609 limit ((cosh(sqrt(x+1))-cosh(sqrt(x)))^(1/sqrt(x)),x,inf );
612 /* #2561 limit(log(x^2),x,-20) gives 2*log(-20) */
613 limit(log(x^2),x,-20),logexpand:false;
616 /* #2412 Problems with integral (x/(exp(x)+1),x,0,inf) */
617 limit(-x*log(%e^x+1)-li[2](-%e^x)+x^2/2, x, inf);
621 /* #4109 Limits of polylogarithms */
622 limit(li[3](x)/log(-x)^3,x,inf);
625 /* The initial problem which triggers this bug */
628 limit ((sin(n*x) - n*x*cos(n*x))/n^2, x, %pi);
631 /* #2503 Declaring x as an integer changes result of limit from 3 to inf */
632 limit((2^n+3^n)^(1/n), n,inf);
635 /* #2624 Erroneous limit result */
636 (assume(n>2), limit(x-x*(1-1/x)^n, x, inf));
642 /* Bug ID: 593351 - limit/sin(inf)etc. should give 0, not IND
644 limit(cos(1/x)*sin(x)-sin(x),x,inf);
646 limit(cos(1/x)*sin(x)-sin(x)+a,x,inf);
649 /* Bug ID: 1376392 - limit(x/(2+sin(1/x)), x, 0); wrong result
651 limit(x/(2+sin(1/x)),x,0);
654 /* #3680 limit(x/sin(1/x),x,0); wrong */
655 limit(x/sin(1/x), x, 0, plus);
658 /* Bug ID: 1106912 - limit(x/sin(x)^2,x,inf)
659 I think the limit is not defined because the func is not defined
660 for all x > any constant.
662 limit(x/sin(x)^2,x,inf);
665 /* Bug ID: #3459 Wrong limit calculation */
666 limit(x / (x+2^x+cos(x)),x,-inf);
669 /* #Bug ID: #3984 limit for und + something yields something instead of und */
670 limit(x*sin(x) + erf(x), x, inf);
673 /* Bug ID: 811522 - redundant question in limit
674 * b is assumed to be zero. Maxima now can deduce from the database
675 * that b-2 is an even number.
677 (assume(equal(b,0),notequal(x,0)),0);
679 limit(r^(b-2)*(x-r)^2,r,0);
681 (forget(equal(b,0)),notequal(x,0),0);
684 /* Bug ID: 221642 limit needs %piargs to be true
685 * The implementation of simp-%atan and simpatan2 has been revised.
686 * We get more limits independent of the value of %piargs.
690 limit(atan2(0,y),y,0,plus);
692 limit(atan2(0,y),y,0,minus);
694 limit(atan2(x,0),x,0,plus);
696 limit(atan2(x,0),x,0,minus);
701 /* Bug ID: 3002971 - limit fails where rat+subst works
703 limit(min(x,x+2,sin(x)/x),x,0);
705 limit(max(x,x+2,sin(x)/x),x,0);
708 /* Bug ID: 1969790 - limits and subscripts
710 limit(mu[inf],x,inf);
714 * Bug 3509430: limit of tanh(x) at 0 makes no sense
716 limit(tanh(x), x, 0);
719 /* bug 2535: stack exhausted when computing limit(log(..)) */
721 limit(log(-1/3125*((-1/2*sqrt(5) + 1/2)^n - (1/2*sqrt(5) +
722 1/2)^n)^9*sqrt(5))/log(-1/5*((-1/2*sqrt(5) + 1/2)^(8*n) - (1/2*sqrt(5) +
723 1/2)^(8*n))*((-1/2*sqrt(5) + 1/2)^n - (1/2*sqrt(5) + 1/2)^n) -
724 1/5*((-1/2*sqrt(5) + 1/2)^(9*n) - (1/2*sqrt(5) +
725 1/2)^(9*n))*sqrt(5)),n,inf);
728 /* #2675 maxima will not do the simplest of definite integrals
729 and will not factor otherwise */
730 limit(x^2*exp(-%i*x - x), x, inf);
733 /* bug #2621 gamma limit error */
735 limit(gamma(x+1/2)/(sqrt(x)*gamma(x)), x, inf);
738 /* Triggered by #2849. This result isn't great, but it's better than
739 an error. A more useful result would be und. */
743 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);
746 /* Bug #2898: limit of continuous --> und */
748 limit(log(x)^2+2*log(x)+q/2+1,x,1);
751 limit(log(x)^2+2*%gamma*log(x)-%pi^2/6+%gamma^2,x,1);
754 /* #2972 Wrong limits involving logs */
755 limit( 27^(log(n)/log(3))/n^3, n, inf);
758 limit( 27^(log(n)/log(3)+1)/n^3, n, inf);
761 limit( ((27^(log(n)/log(3)+1)-1)/26+n-log(n)/log(3)-1)/n^3,n,inf);
764 /* examples from mailing list 2014-10-10: "Re: bug in limit code" */
767 kill (beta, hbar, omega, delta, n),
768 assume (beta > 0, hbar > 0, omega > 0, delta > 0, 2*n - 1 > 0),
772 limit (%e^(beta*hbar*omega-beta*(hbar*(2*n+1)*omega+delta))
773 /(1/(1-%e^-(beta*hbar*omega))^2
774 +(%e^-(beta*delta)-1)/(1-%e^-(2*beta*hbar*omega))), beta, inf);
778 assume (h > 0, d > 0, z > 0, 2*h*z > d),
782 limit ((%e^-(b*d)-1)/(1-%e^-(2*b*h*z)), b, inf);
785 (kill (a), assume (a < 0), 0);
788 limit (exp (b*a), b, inf);
791 limit((exp(a*x)-1)/(exp(a*x)+1),x,inf) ;
794 (forget (a < 0), assume (a > 0), 0);
797 limit((exp(a*x)-1)/(exp(a*x)+1),x,inf) ;
800 (forget (a > 0), assume (equal (a, 0)), 0);
803 limit((exp(a*x)-1)/(exp(a*x)+1),x,inf) ;
806 (forget (equal (a, 0)), assume (a > 0), 0);
809 integrate(%e^(-a*r)*sin(k*r),r,0,inf);
815 (forget (a > 0), assume (a < 0), limit (a*x, x, inf));
818 (forget (a < 0), assume (equal (a, 0)), limit (a*x, x, inf));
821 killcontext (context);
824 /* SF bug #3104: "limit(log(1 - exp(x)), x, 0, plus), numer => stack overflow" */
826 limit(log(1 - exp(x)), x, 0, plus);
829 limit(log(1 - exp(x)), x, 0, plus), numer;
832 limit(log(1 + exp(x)), x, 0, plus);
835 limit(log(1 + exp(x)), x, 0, plus), numer;
838 /* inspired by this example from #3103; for the present purpose,
839 * it's not too important to get these specific results,
840 * only that numer doesn't cause an error here.
843 integrate(x^3/(exp(x)-1),x,0,inf);
844 '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,
845 x,inf,minus) -%pi^4/15$
847 integrate(x^3/(exp(x)-1),x,0,inf), numer;
848 'limit(6.0*li[4](%e^x)-6.0*x*li[3](%e^x)+3.0*x^2*li[2](%e^x)
849 +1.0*x^3*log(1-%e^x)-0.25*x^4,x,inf,minus)
852 /* #3142 limit((x^(1/x) - 1)*sqrt(x), x, inf) => inf */
853 limit((x^(1/x) - 1)*sqrt(x), x, inf);
856 /* #3143 limit((x^(1/x) - 1)*sqrt(x), x, 0, minus) => inf */
857 /* should really be '$infinity */
858 limit((x^(1/x) - 1)*sqrt(x), x, 0, minus);
859 'limit((x^(1/x) - 1)*sqrt(x), x, 0, minus);
861 /* SF bug #3185: "Error in sum with non-false modulus" */
863 block([modulus:7], sum(i^-2,i,1,inf));
866 block([modulus:7], limit(inf));
869 /* SF bug #3235: "ECL lisp arithmetic error in definite integration with large limits"
870 * the bug is actually in ECL (https://gitlab.com/embeddable-common-lisp/ecl/issues/299);
871 * here we'll test a work around.
874 block ([actual, expected],
875 actual : limit(x*exp(x)*log(exp(x)+1),x,-1000,plus),
876 expected : -1000*%e^-1000*log(%e^-1000*(%e^1000+1)),
877 if ev (equal (actual, expected), logexpand='super) then true else [actual, expected]);
880 /* accommodate different equivalent forms via 'equal' */
881 block ([actual, expected],
882 actual : integrate((x^2)*exp(x) / (1 + exp(x))^2,x,-1000,1000),
883 expected : (-(2000*%e^1000*log(%e^-1000*(%e^1000+1)))/(%e^1000+1))
884 -(2000*log(%e^-1000*(%e^1000+1)))/(%e^1000+1)
885 -((2000*%e^1000+2000)*log(%e^1000+1)
886 +(2*%e^1000+2)*li[2](-%e^1000)-1000000*%e^1000)
887 /(%e^1000+1)+(2*%e^1000*li[2](-%e^-1000))/(%e^1000+1)
888 +(2*li[2](-%e^-1000))/(%e^1000+1)-1000000/(%e^1000+1),
889 if ev (equal (actual, expected), logexpand='super) then true else [actual, expected]);
892 /* SF bug #3244: "error trying to promote float infinity to bigfloat in sign comparison"
893 * same as test under #3235 but ensure that bigfloat assume is present to trigger bug
896 block ([actual, expected, ctxt:newcontext()],
897 assume (xfoo > 200b0),
898 actual : limit(xfoo*exp(xfoo)*log(exp(xfoo)+1),xfoo,-1000,plus),
899 expected : -1000*%e^-1000*log(%e^-1000*(%e^1000+1)),
901 if ev (equal (actual, expected), logexpand='super) then true else [actual, expected]);
904 /* SF bug #3826: "limit returns temp variable expression" */
909 limit(x^q/(a*x^q- 1),x,inf));
910 'limit(x^q/(a*x^q- 1),x,inf);
912 tlimit(x^q/(a*x^q- 1),x,inf);
913 'limit(x^q/(a*x^q- 1),x,inf);
916 declare (q, integer),
917 limit(x^q/(a*x^q- 1),x,inf));
920 (remove (q, integer),
921 declare (q, noninteger),
922 limit(x^q/(a*x^q- 1),x,inf));
926 * limit(li[3](sin(x)), x, %pi/2) was returning a noun form.
928 makelist(subst(n=k, limit(li[n](sin(x)), x, %pi/2)), k, 2, 5);
929 [zeta(2), zeta(3), zeta(4), zeta(5)];
931 limit(li[3](sin(x)+x-%pi/2), x, %pi/2);
934 (remove (q, noninteger),
938 /* Bug #3926: Various limits give UND where they should give IND */
940 limit(unit_step(x),x,0);
952 limit(exp(1/x)*sin(1/x),x,0);
955 limit(exp(-1/x)*sin(1/x),x,0);
958 /* Bug #3071: limit of expressions with signum not very powerful */
960 limit(signum(x)^a,x,0); /* It would be better if this asked about a */
963 limit(signum(x)*x/sin(x),x,0);