1 /* limits of log expressions */
9 limit(log(x),x,0,'minus);
12 limit(log(x),x,0,'plus);
18 limit(log(-2+%i*x),x,0);
21 limit(46*log(-2+%i*x),x,0);
24 limit(107+log(-2+%i*x),x,0);
27 limit(log(-2+%i*x),x,0,'minus);
30 limit(46*log(-2+%i*x),x,0,'minus);
33 limit(107+log(-2+%i*x),x,0,'minus);
34 107 + log(2) - %i*%pi$
36 limit(log(-2+%i*x),x,0,'plus);
39 limit(46*log(-2+%i*x),x,0,'plus);
42 limit(107+log(-2+%i*x),x,0,'plus);
43 107 + log(2) + %i*%pi$
45 /* #3831 limit(log((sqrt(x^2+1))/2),x,1) hangs related bugs */
46 limit(log((sqrt(x^2+1))/2),x,1,'minus);
49 limit(log((sqrt(x^2+1))/2),x,1,'plus);
52 limit(log((sqrt(x^2+1))/2),x,1);
55 limit(log((sqrt(x^4+1))/2),x,1,'minus);
58 limit(log((sqrt(x^4+1))/2),x,1,'plus);
61 limit(log((sqrt(x^4+1))/2),x,1);
64 block([logarc : true], integrate(1/sqrt(9+x^2),x,0,3));
67 block([logarc : false], integrate(1/sqrt(9+x^2),x,0,3));
70 limit(log((sqrt(x^2+9)+x)/3),x,1,'minus);
73 limit(log((sqrt(x^2+9)+x)/3),x,1,'plus);
76 limit(log((sqrt(x^2+9)+x)/3),x,1);
79 /* Tests associated with the fix to bug 3831 limit(log((sqrt(x^2+1))/2),x,1) hangs */
80 limit(log(x),x,1,'minus);
83 limit(log(x),x,1,'plus);
95 limit(log(x),x,0,'minus);
98 limit(log(x),x,0,'plus);
101 limit(log(signum(x)),x,0);
104 limit(log(107+sin(x)),x,inf);
107 /* far too complex result, but it's not the fault of simplimln */
108 limit(log((x-%i)/(x+%i)),x,2);
109 log((5*%i+10)/(11*%i+2))$
111 limit(log(-46 + %i*x),x,0,'minus);
114 limit(log(-46 + %i*x),x,0,'plus);
117 limit(log(-46 + %i*exp(x)),x,0);
120 limit(log(-46 + %i*(exp(x)-1)),x,0,'plus);
123 limit(log(-46 + %i*(exp(x)-1)),x,0,'minus);
126 limit(log(-46 + %i*(exp(x)-1)),x,0);
129 limit(log(-1 + %i*x*sin(1/x)),x,0,'minus);
132 limit(log(-1 + %i*signum(x)),x,0,'minus);
135 limit(log(-1 + %i*signum(x)),x,0,'plus);
138 limit(log(-1 + %i*signum(x)),x,0);
141 limit(log(-51 + %i* sin(x)), x, 0, 'plus);
144 limit(log(-51 + %i* sin(x)), x, 0, 'minus);
147 /* End of tests associated with the fix to bug 3831 */
149 /* #3844 Wrong limit involving gamma function */
150 limit(gamma(1/x) - x, x, 'inf);
153 limit(x*(gamma(1/x) - (x - %gamma)),x,inf);
154 (%pi^2+6*%gamma^2)/12$
156 limit(x^(3/2)*(gamma(1/x) - (x - %gamma)),x,inf);
159 limit(x^2*(gamma(1/x) - (x - %gamma + (6*%gamma^2+%pi^2)/(12*x))),x,inf);
160 -((4*zeta(3)+%gamma*%pi^2+2*%gamma^3)/12)$
162 /* #3846 limit gives quotient by zero error */
163 limit(gamma(1/x)/gamma(x),x,0,plus);
166 limit(gamma(x)/gamma(1/x),x,0,plus);
169 /* #3842 limit(atan(x),x,%i) --> error. That was determined to be a non-bug, but
170 here are two related limit problems. */
171 limit(atan(%i + x),x,0);
174 limit(atan(%i - x),x,0);
177 /* #3839 limits of asin expressions */
178 limit(asin(3+%i*x),x,0,plus);
181 limit(asin(3+%i*x),x,0,minus);
184 /* Once the next two tests were slow (7 seconds) with the default value for
185 lhospitallim. At that time, locally these tests set lhospitallim : 1. These
186 tests are no longer slow with the defaulty value of lhospitallim. */
187 limit(rectform(asin(3+%i*x)),x,0,'plus);
188 %pi/2-(%i*log(17-3*2^(5/2)))/2$
190 limit(rectform(asin(3+%i*x)),x,0,'minus);
191 %pi/2-%i*log(2^(3/2)+3)$
193 /* #3838 limit(atan(sin(x)),x,inf,plus) --> atan(ind) */
194 limit(atan(sin(x)),x,inf,plus);
197 /* #3836 limit of a log expression with essential singularity */
198 limit(log(-2 + %i*x * sin(1/x)),x,0,plus);
201 /* #3824 limit of an antiderivative */
202 (xxx : integrate((x-%i)/((x-2*%i)*(x^2+1)),x),0);
205 limit(rectform(xxx),x,minf);
208 rectform(limit(xxx,x,minf));
211 /* #3816 limit of difference of logs */
212 (xxx : (%i*log(x^2+1))/6-(%i*log(x-2*%i))/3,0);
215 limit(rectform(xxx),x,minf,'plus);
218 rectform(limit(xxx,x,minf,'plus));
224 /* #3592 Wrong limit */
225 (declare(n,integer),assume(n > 0), 0);
228 limit((z^(2*n)-1)/(z^2-1),z,-1);
231 (remove(n,integer),forget(n > 0),0);
234 /* #3589 Stack overflow for a limit evaluation */
235 limit((sqrt(x)-2)*log(1-sqrt(x)/2),x,4,minus);
238 /* #3587 Wrong limit for logarithmic function */
239 limit(log(3-sqrt(x)),x,9,minus);
242 /* #3562 integrate(1/(1+tan(x)), x, 0, %pi/2) gives complex result, should be %pi/4 */
243 integrate(1/(1+tan(x)),x,0,%pi/2);
246 /* #3535 limit doesn't account for certain singularities in mexpt, log, gamma_incomplete, ... */
247 limit(log(%i*x - 1),x,0,minus);
250 limit(log(%i*x - 1),x,0,plus);
253 limit(rectform(log(%i*x - 1)),x,0,minus);
256 limit(rectform(log(%i*x - 1)),x,0,plus);
259 limit(sqrt((%i-x)^2),x,0,'minus);
262 limit(sqrt((%i-x)^2),x,0,'plus);
265 /* need tests for gamma_incomplete(1/2, %i*x - 1) */
267 /* #3534 integrate(x*exp(-x^2)*sin(x),x,minf,inf) gives zero */
268 integrate(x*exp(-x^2)*sin(x),x,minf,inf);
269 sqrt(%pi)/(2 * (%e)^(1/4))$
271 /* #3509 limits involving multiple non-finites sometimes give errors */
272 limit(1/(zeroa+zerob));
275 limit(1/(1/inf+1/minf));
278 limit(signum(zeroa+zerob));
281 /* #3459 Wrong limit calculation */
282 limit(x / (x+2^x+cos(x)),x,-inf);
285 /* #3415 limit doesn't check for zero coefficients in limit((a*x+1)/(a*x+2),x,inf) */
287 (assume(equal(a,0)),0);
290 limit((a*x+1)/(a*x+2),x,inf);
293 (forget(equal(a,0)),0);
296 /* #3393 limit/tlimit give wrong result */
297 limit(log(log(x + exp(log(x) * log(log(x))))) / log(log(log(exp(x) + x))), x, inf);
300 /* #3345 bug in limit -- hard to test--works OK with an assume on y*/
302 /* #3313 limit fails with domain complex --bad failure; commented out for now:
303 block([domain : 'complex], limit((x*(4/log(x))^(2*log(x)/log(log(x)))),x,inf));
306 /* #3279 limit incorrect with domain:complex */
307 block([domain : 'real], limit((2^(2*x+1)+(2^x*x^100)^(3/2))/(4^x-100*2^x),x,inf));
310 block([domain : 'complex], limit((2^(2*x+1)+(2^x*x^100)^(3/2))/(4^x-100*2^x),x,inf));
313 /* #3203 limit(floor(n*x),x,0) for n > 10^8 */
314 limit(floor((10^8 +1)*x),x,0,minus);
317 limit(erfc(x*(1 + %i)), x, inf);
320 /* #3143 limit((x^(1/x) - 1)*sqrt(x), x, 0, minus) => inf */
321 limit((x^(1/x) - 1)*sqrt(x), x, 0, minus);
324 /* #3142 limit((x^(1/x) - 1)*sqrt(x), x, inf) => inf */
325 limit((x^(1/x) - 1)*sqrt(x), x, inf);
328 /* #3140 limit((x^(1/x) - 1)*sqrt(x), x, 0, minus) + domain:complex => stack overflow */
329 block([domain : 'real], limit((x^(1/x) - 1)*sqrt(x), x, 0, minus));
333 block([domain : 'complex], limit((x^(1/x) - 1)*sqrt(x), x, 0, minus));
336 /* #3137 gruntz(abs(sin(x))/sqrt(1-cos(x)), x, 0, plus) => stack overflow */
337 limit(abs(sin(x))/sqrt(1-cos(x)), x, 0, plus);
340 gruntz(abs(sin(x))/sqrt(1-cos(x)), x, 0, plus);
343 /* #3136 gruntz(atan2(x^2 - 2, x^3 - 2*x), x, sqrt(2), minus) => atan2(0,0) undefined */
344 limit(atan2(x^2 - 2, x^3 - 2*x), x, sqrt(2), minus);
347 gruntz(atan2(x^2 - 2, x^3 - 2*x), x, sqrt(2), minus);
350 /* #3135 gruntz(atan2(x^2 - 2, x^3 - 3*x), x, sqrt(2), minus) incorrect */
351 limit(atan2(x^2 - 2, x^3 - 3*x), x, sqrt(2), minus);
354 gruntz(atan2(x^2 - 2, x^3 - 3*x), x, sqrt(2), minus);
357 /* #3280 gruntz incorrect limit */
358 gruntz((2^(2*x+1)+(2^x*x^100)^(3/2))/(4^x-100*2^x),x,inf);
361 /* #3055 limit(exp((log(log(x + exp(log(x)*log(log(x)))))) / (log(log(log(exp(x) + x + log(x)))))), x, inf) */
362 limit(exp((log(log(x + exp(log(x)*log(log(x)))))) / (log(log(log(exp(x) + x + log(x)))))), x, inf);
365 /* #3054 limit(exp(exp(2*log(x**5 + x)*log(log(x)))) / exp(exp(10*log(x)*log(log(x)))), x, inf) */
367 limit(exp(exp(2*log(x**5 + x)*log(log(x)))) / exp(exp(10*log(x)*log(log(x)))), x, inf)$
371 /* #3053 limit with branch cuts */
372 block([domain : 'real], limit(sqrt(-1 + %i*x), x, 0,minus));
375 block([domain : 'real], limit(sqrt(-1 - %i*x), x, 0,plus));
378 block([domain : 'complex], limit(sqrt(-1 + %i*x), x, 0,minus));
381 block([domain : 'complex], limit(sqrt(-1 - %i*x), x, 0,plus));
384 /*#3051 limit(2/5*((3/4)^m - 1)*(a - 10) + 1/5*(3*(3/4)^m + 2)*a, m, inf) with domain: complex */
385 block([domain : 'real],limit(2/5*((3/4)^m - 1)*(a - 10) + 1/5*(3*(3/4)^m + 2)*a, m, inf));
388 block([domain : 'complex],limit(2/5*((3/4)^m - 1)*(a - 10) + 1/5*(3*(3/4)^m + 2)*a, m, inf));
391 /* #3041 limit(inf*(zeroa+inf)) => und, should be inf */
392 limit(inf*(zeroa+inf));
395 /* #2972 Wrong limits involving logs */
396 limit( 27^(log(n)/log(3))/n^3, n, inf);
399 limit( 27^(log(n)/log(3)+1)/n^3, n, inf);
402 limit( ((27^(log(n)/log(3)+1)-1)/26+n-log(n)/log(3)-1)/n^3,n,inf);
405 /* #2953 limit loops endlessly */
406 limit((a/x^b + (1-a)/y^b)^(-1/b),b,0);
409 /* #2899 Limit that once worked is broken */
410 limit((1+sqrt(n+1))^(-n-1)/(1+sqrt(n))^(-n),n,inf);
413 /* #2898 limit of continuous --> und */
414 (e : log(x)^2+2*%gamma*log(x)-%pi^2/6+%gamma^2,0);
418 -((%pi^2-6*%gamma^2)/6)$
423 /* #2877 Limits behave incorrectly when applied to derivatives */
424 (dg: diff(g(x), x),0);
427 (lim: limit(dg, x, 0),0);
430 (limit(lim, x, 0),0);
434 limit('diff(g(x),x,1),x,0)$
436 /* #2849 limit(ind*XXX) and limit(ind/XXX) gives errors rather than results */
437 map('limit, [ind*inf, inf/ind,ind*minf,minf/ind,ind*inf,ind/inf,ind*minf,ind/minf]);
438 [und,und,und,und,und,und,und,und]$
449 /* #2847 limits of powers of constants */
450 limit((1+%i)^n,n,inf);
453 limit((5+%i)^n,n,inf);
456 /*#2653 Bug for limit */
457 limit((atan(x)/x)^(1/(x^2)), x, 0);
460 /* #2388 wrong limit */
461 limit(((9*x)^(1/3)-3)/(sqrt(3+x)-sqrt(2*x)),x,3);
464 /* #2366 limit of gamma_incomplete */
465 limit(gamma_incomplete(sin(x),cos(x)),x,inf);
468 /* #2187 Inaccurate limit evaluation */
469 is(0 # limit(sin(x)/(x-a),x,0));
472 /* #1822 limit(inf+minf) should give und */
482 /* #1804 limit of x*floor(1/x) as x goes to 0 */
483 limit(x*floor(1/x),x,0);
486 /* #1743 limit of trig expression */
487 (e : (2*sin(x)*z+cos(x)*sin(2*x)-2*cos(x)^2*sin(x))/(z^2+(-sin(2*x)^2-4*sin(x)^2-cos(x)^2-1)*z+sin(2*x)^2-4*cos(x)*sin(x)*sin(2*x)+4*cos(x)^2*sin(x)^2),0);
491 (4*sin(x))/(cos(4*x)+3*cos(2*x)-8)$
493 (remvalue(e,dg,lim),0);
496 limit(atan2(sin(x),cos(x)),x,0);
499 limit(atan2(cos(x),sin(x)),x,0);
502 limit(atan2(cos(x),cos(x)),x,0);
505 limit(atan2(1/x^2,sin(1/x)),x,0);
508 limit(atan2(sin(x) + x, cos(x) + x),x,inf);
511 limit(atan2(sin(x) - x, cos(x) + x),x,inf);
514 limit(atan2(sin(x) - x, cos(x) - x),x,inf);
517 limit(atan2(sin(x) - x, cos(x) + x),x,inf);
520 limit(atan2(cos(x),x),x,inf);
523 limit(atan2(sin(x),x),x,minf);
526 limit(atan2(sin(x)/x,x),x,minf);
529 limit(atan2(exp(x),x),x,minf);
532 limit(atan2(-exp(x),x),x,minf);
535 /* #3794 assuming zerob < 0 & zeroa > 0 gives bugs for some limits */
536 limit(atan2(x^2-2,x^3-2*x),x,sqrt(2),minus);
539 (assume(zeroa > 0, zerob < 0),0);
542 limit(atan2(x^2-2,x^3-2*x),x,sqrt(2),minus);
545 (forget(zeroa > 0, zerob < 0),0);
548 /* #3866 limit(log(sinh(x)),x,0,'plus) --> infinity */
550 limit(log(sinh(x)),x,0,'plus);
553 limit(log(sinh(x)),x,0,'minus);
556 limit(log(sinh(x)),x,0);
559 /* unit_step expressions */
561 limit(unit_step(x),x,minf);
564 limit(unit_step(x),x,-%pi);
567 limit(unit_step(x),x,%pi);
570 limit(unit_step(x),x,0,'minus);
573 limit(unit_step(x),x,0,'plus);
576 limit(23*unit_step(x),x,0,'minus);
579 limit(23*unit_step(x),x,0,'plus);
582 limit(23*unit_step(x) + 107,x,0,'minus);
585 limit(23*unit_step(x) + 107,x,0,'plus);
588 limit(unit_step(sin(x)),x,0);
591 /* limits of conjugate expressions */
592 limit(conjugate(sqrt(-1+%i*sin(x))),x,0,'minus);
595 limit(conjugate(sqrt(-1+%i*sin(x))),x,0,'plus);
598 limit(conjugate(sqrt(-1+%i*sin(x))),x,0);
601 (assume(a > 0), limit(conjugate(sqrt(a+%i*sin(x))),x,0));
604 limit(conjugate(sqrt(-a+%i*sin(x))),x,0,'minus);
607 limit(conjugate(sqrt(-a+%i*sin(x))),x,0,'plus);
610 limit(107+93*conjugate(sqrt(-a+%i*sin(x))),x,0,'minus);
613 limit(107+93*conjugate(sqrt(-a+%i*sin(x))),x,0,'plus);
618 /* #3865 crash from taking limit of factorial(x) + 1 */
619 limit(factorial(x) + 1, x, 0);
622 limit(atan2(0,1-3^x),x,0,'plus);
625 limit(atan2(0,1-3^x),x,0);
628 /* additional atan tests */
632 limit(atan(x),x,0,minus);
635 limit(atan(x),x,0,plus);
638 limit(atan(x),x,-2.0);
641 block([fpprec : 32], float_approx_equal(limit(atan(x),x,bfloat(sqrt(2))), atan(bfloat(sqrt(2)))));
644 is(limit(atan(x),x,float(sqrt(2))) = atan(float(sqrt(2))));
647 limit(atan(sin(x)),x,inf);
650 limit(atan(x),x,minf);
653 limit(atan(x),x,inf);
656 limit(atan(x^2),x,inf);
659 limit(atan(1/x),x,0);
662 /* #3864 limit of atan2 expression */
663 limit(atan2(0,1-3^x),x,0,'minus);
667 limit((x^x-a^a)/(x-a), x, a);
670 limit((x^x-2^2)/(x-2), x, 2);
673 tlimit((x^x-a^a)/(x-a), x, a);
676 /* #3844 Wrong limit involving gamma function */
677 limit(gamma(1/x) - x, x, inf);
680 /* #3838 limit(atan(sin(x)),x,inf,plus) --> atan(ind) */
681 limit(atan(sin(x)),x,inf,plus);
684 /* #3483 limit apparently causes infinite loop */
685 (X : log((sqrt(t)*sqrt(t+1)+t)/t)/(t+1)-(t*(log((t-sqrt(t)*sqrt(t+1))/t)-log((sqrt(t)*sqrt(t+1)+t)/t)))/(t+1)-log((t-sqrt(t)*sqrt(t+1))/t)/(t+1)-(2*sqrt(t))/sqrt(t+1),0);
689 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
692 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
695 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
698 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
700 block([algebraic : true], limit(ratsimp(X),t,1));
701 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
706 /* #2953 limit loops endlessly */
707 limit((a/x^b + (1-a)/y^b)^(-1/b),b,0);
710 /* #2706 Limit runs forever, never returning (simplified bug) */
711 block([ans1,ans2, ans3],
713 ans1 : limit((%e^(-sqrt(-zzz))*(w3*sqrt(-zzz)*%e^(2*sqrt(-zzz))-w3*sqrt(-zzz)))/(2*zzz),zzz,0),
716 ans2 : limit((%e^(-sqrt(-zzz))*(w3*sqrt(-zzz)*%e^(2*sqrt(-zzz))-w3*sqrt(-zzz)))/(2*zzz),zzz,0),
719 ans3 : limit((%e^(-sqrt(-zzz))*(w3*sqrt(-zzz)*%e^(2*sqrt(-zzz))-w3*sqrt(-zzz)))/(2*zzz),zzz,0),
724 /* #2388 wrong limit */
725 X : limit(((9*x)^(1/3)-3)/(sqrt(3+x)-sqrt(2*x)),x,3);
728 block([ans : radcan(X)], remvalue(X),ans);
731 /* #3861 function simplimsubst problems */
732 limit(log(-1+%i*x) * ceiling(a),x,0,minus);
735 limit(log(-1+%i*x) * a,x,0,minus);
738 /* #484 limit(x=0,x,0) wrong */
739 is(equal(0=0, limit(x=0,x,0)));
742 is(equal(0<0, limit(x<0,x,0)));
745 is(equal(0#0, limit(x#0,x,0)));
751 block([ans],declare(z,complex), ans : limit(atan(x),x,z), remove(z,complex),ans);
754 limit(fib(x+1)/fib(x),x,inf);
757 limit(fib(x+2)/fib(x),x,inf);
760 /* #4029 limit(cos(1/x)^2 + sin(1/x)^2 + cos(x),x,0) --> ind */
761 limit(cos(1/x)^2 + sin(1/x)^2,x,0);
764 limit(cos(1/x)^2 + sin(1/x)^2 + cos(x),x,0);
767 block([ans], assume(a > 0),ans : limit(sin(x)^(a),x,inf),forget(a > 0), ans);
770 block([ans], assume(a > 0),ans : limit(sin(x)^(-a),x,inf),forget(a > 0), ans);
773 limit((2+sin(x))^(-9),x,inf);
776 limit((2+sin(x))^(9),x,inf);
779 /* #4099 gruntz called on algebraic */
780 gruntz(((9*x)^(1/3)-3)/(sqrt(3+x)-sqrt(2*x)),x,3,plus);
783 /* This bug is mentioned in the tlimit source code, but I don't think it's reported.*/
784 tlimit(2^n/n^5,n,inf);
787 /* #3927 tlimit(exp(x)/x^5,x,inf) = 0 */
788 tlimit(exp(x)/x^5,x,inf);
791 block([lhospitallim : 8], tlimit(exp(x)/x^5,x,inf));
794 block([lhospitallim : 1], tlimit(exp(x)/x^5,x,inf));
797 block([lhospitallim : 1], tlimit(exp(x)/x^46,x,inf));
800 block([lhospitallim : 1], tlimit(exp(x)/x^107,x,inf));
803 /* See #3932 inconsistent limit results with trig */
804 (QQ: (-rr*csc(rr)^2)+%pi*csc(rr)^2+cot(rr)-%pi/rr^2,0);
810 limit(trigsimp(QQ),rr,0);
813 limit(map('trigsimp,QQ),rr,0);
819 /* #3903 A limit toward infinity gives a nounform */
820 limit((sin(x)+x)/sqrt(x*(2*sin(x)+2*cos(x))+2*x^2+1),x,inf);
823 tlimit((sin(x)+x)/sqrt(x*(2*sin(x)+2*cos(x))+2*x^2+1),x,inf);
826 gruntz((sin(x)+x)/sqrt(x*(2*sin(x)+2*cos(x))+2*x^2+1),x,inf);
829 /* #3826 limit returns temp variable expression */
831 block([ans], assume(q > 0), ans : limit(x^q/(a*x^q- 1),x,inf), forget(q > 0),ans);
834 block([ans], assume(q > 0), ans : tlimit(x^q/(a*x^q- 1),x,inf), forget(q > 0),ans);
837 block([ans], assume(q > 0), ans : gruntz(x^q/(a*x^q- 1),x,inf), forget(q > 0),ans);
840 /* #3393 limit/tlimit give wrong result */
841 limit(log(log(x + exp(log(x) * log(log(x))))) / log(log(log(exp(x) + x))), x, inf);
844 tlimit(log(log(x + exp(log(x) * log(log(x))))) / log(log(log(exp(x) + x))), x, inf);
847 gruntz(log(log(x + exp(log(x) * log(log(x))))) / log(log(log(exp(x) + x))), x, inf);
850 /* #2561 limit(log(x^2),x,-20) gives 2*log(-20) */
851 block([logexpand : false], limit(log(x^2),x,-20));
854 block([logexpand : false], tlimit(log(x^2),x,-20));
857 block([logexpand : false], gruntz(log(x^2),x,-20,minus));
860 /* #2389 incorect limit
861 Commented out for now becuase it calls asksign when it should not
865 ans : limit(((t+1)^k-t^k-k*t^(k-1)-(k*(k-1)/2)*t^(k-2))/t^(k-3),t,inf),
871 /* #2273 limit gives the wrong answer
872 (This bug was fixed long ago, but I'm not sure there was a rtest for it.) */
873 limit((sqrt(t^2+4)*(((t+2/t^2)^2+4)^(3/2)-(t+2/t^2)^3-4*(t+2/t^2)))/
874 (sqrt((t+2/t^2)^2+4)*((t^2+4)^(3/2)-t^3-4*t)),t,inf);
877 tlimit((sqrt(t^2+4)*(((t+2/t^2)^2+4)^(3/2)-(t+2/t^2)^3-4*(t+2/t^2)))/
878 (sqrt((t+2/t^2)^2+4)*((t^2+4)^(3/2)-t^3-4*t)),t,inf);
881 gruntz((sqrt(t^2+4)*(((t+2/t^2)^2+4)^(3/2)-(t+2/t^2)^3-4*(t+2/t^2)))/
882 (sqrt((t+2/t^2)^2+4)*((t^2+4)^(3/2)-t^3-4*t)),t,inf);
885 /* #4109 Limits of polylogarithms */
886 limit(li[2](x)/log(-x)^2,x,inf);
889 limit(li[3](x)/log(-x)^3,x,inf);
892 limit(li[2](x),x,%e/2);
895 /* #4108 limit code & nondefault value of taylor_logexpand */
896 block([taylor_logexpand : false], limit((1/%pi*(atan(n/%pi)+%pi/2))^n,n,inf));
899 block([taylor_logexpand : true], limit((1/%pi*(atan(n/%pi)+%pi/2))^n,n,inf));
902 /* #4103 limit(acot(x),x,0) should be IND (not UND) */
906 /* #4087 limit((%i+1)^a/(2^(a/2)),a,inf) => 0 (wrong) */
907 limit((%i+1)^a*2^(-a/2),a,inf);
910 limit((%i+1)^(2*a)*2^-a,a,inf);
913 /* #4085 limit((2-%i)^a/a!,a,inf) */
914 errcatch(limit((2-%i)^a/a!,a,inf));
917 /* #4081 limit((2+sin(x))^(-2),x,inf) --> und */
918 limit((2+sin(x))^(-2),x,inf);
921 /* #4073 limit(log(sin(x)+9),x,inf) --> und could be ind */
922 limit(log(sin(x)+9),x,inf);
925 /*#4029 limit(cos(1/x)^2 + sin(1/x)^2 + cos(x),x,0) --> ind */
926 limit(cos(1/x)^2 + sin(1/x)^2,x,0);
929 limit(cos(1/x)^2 + sin(1/x)^2 + cos(x),x,0);
932 /* #4024 integrate(x*sin(x)*exp(-x^2),x,0, inf) */
933 integrate(x*sin(x)*exp(-x^2),x,minf, inf);
934 (%e^(-1/4)*sqrt(%pi))/2$
936 /* #4021 limit(inf^(2+1/inf)) should be inf */
937 limit(inf^(2+1/inf));
940 /* #4020 various limit bugs with exp(%i*x) */
941 limit(x*exp(%i*x),x,inf);
944 limit(x+x*exp(%i*x),x,inf);
947 limit(1+x*exp(%i*x),x,inf);
950 limit(sin(x) + x*cos(x),x,inf);
953 /* #4004 a cosine of arcsin limit that is evaluated incorrectly */
956 assume(equal(cos((4 * %pi * m + %pi)/2), 0)),
957 ans : limit(cos((4*m + 1) * asin(1/sqrt(x^2 + 1)))/abs(x), x, 0),
959 forget(equal(cos((4 * %pi * m + %pi)/2), 0)),
963 /* Also mentioned in #4004 */
966 ans : limit(a/x + 1, x, 0),
973 ans : limit(a*x + 1, x, inf),
980 ans : limit((2*x + a)/(x + a), x, 0),
985 /* #4003 limit bug with on-default values for ratsimpexpons and ratfac */
986 block([ratsimpexpons : true, ratfac : true],
987 limit(2/5*((3/4)^m - 1)*(a - 10) + 1/5*(3*(3/4)^m + 2)*a, m, inf));
990 /* #4001 limit(sin(x)/x + sin(x) + cos(x),x,inf) = 0 */
991 limit(sin(x)/x + sin(x) + cos(x),x,inf);
994 /* #4151 limit bug as x tend to inf for trigonometric expressions */
995 limit((4*x^3+2*x^2*sin(x)+1)/(x+1)^2 - 4*x,x,inf);
998 limit(expand((4*x^3+2*x^2*sin(x)+1)/(x+1)^2 - 4*x),x,inf);
1001 /* #4137 simplimplus bugs */
1002 limit(3^x * cos(x) + sin(x),x,inf);
1005 limit(3^x * cos(x) + 2^x,x,inf);
1008 errcatch(limit(3^x + (9+%i)^x,x,inf));
1011 /* See mailing list https://sourceforge.net/p/maxima/mailman/message/37868153/ */
1012 integrate(tan(x)^(1/3)/(cos(x)+sin(x))^2,x,0,%pi/2);
1013 %pi/(2*sqrt(3))+%pi/(2*3^(3/2))$
1015 /* #4147 integrate(log(sin(x))/cos(x),x,0,%pi/2) */
1016 integrate(log(sin(x))/cos(x),x,0,%pi/2);
1019 /* #4138 limit((1+1/x)^x,x,6/5) is "und" in complex domain */
1020 block([domain : 'complex], limit((1+1/x)^x,x,6/5));
1023 /* #4133 limit(abs(cos(a*x)),x,inf) */
1024 block([ans], (assume(a < 0), ans : limit(abs(cos(a*x)),x,inf), forget(a < 0), ans));
1027 block([ans], (assume(equal(a,0)), ans : limit(abs(cos(a*x)),x,inf), forget(equal(a,0)), ans));
1030 block([ans], (assume(a > 0), ans : limit(abs(cos(a*x)),x,inf), forget(a > 0), ans));
1033 /* #4103 limit(acot(x),x,0) should be IND (not UND) */
1037 /* #4222 limit(6^x, x, 1) and similar cases: stack overflow crash */
1038 integrate(1/10^x, x, 0, 1);
1044 limit(2^x * 3^x, x, 1);
1047 limit(2^x * 3^x + 28,x,1);
1050 limit((2^x * 3^x + 28)/(x+2),x,1);
1053 limit(%pi^2*%i*cos(x-1)*6^x,x,1);
1055 /* end of tests for #4222 */
1057 /* #4227 limit(abs(sin(x))/sin(x), x, inf) = 1 */
1058 limit(abs(sin(x))/sin(x), x, inf);
1061 /* #4133 limit(abs(cos(a*x)),x,inf) */
1062 block([ans], assume(a < 0), ans : limit(abs(cos(a*x)),x,inf), forget(a < 0), ans);
1065 block([ans], assume(a > 0), ans : limit(abs(cos(a*x)),x,inf), forget(a > 0), ans);
1068 block([ans], assume(equal(a,0)), ans : limit(abs(cos(a*x)),x,inf), forget(equal(a,0)), ans);
1071 limit(abs(sin(x) + abs(cos(x))),x,inf);
1074 /* #3824 limit of an antiderivative */
1075 block([xxx : integrate((x-%i)/((x-2*%i)*(x^2+1)),x)],
1076 [limit(rectform(xxx),x,minf), rectform(limit(xxx,x,minf))]);
1079 /* #3483 limit apparently causes infinite loop */
1080 (X : log((sqrt(t)*sqrt(t+1)+t)/t)/(t+1)-(t*(log((t-sqrt(t)*sqrt(t+1))/t)-log((sqrt(t)*sqrt(t+1)+t)/t)))/(t+1)-log((t-sqrt(t)*sqrt(t+1))/t)/(t+1)-(2*sqrt(t))/sqrt(t+1),0);
1083 limit(ratsimp(X),t,1);
1084 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
1086 /* doesn't finish! */
1088 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
1093 /* #4238 limit((abs(sin(x)*cos(x)-x^4) -x)/x^3,x,0,plus) gives internal error
1094 This test exercises the function mabs-subst. */
1095 limit((abs(sin(x)*cos(x)-x^4) -x)/x^3,x,0,plus);
1098 limit(log(cos(x)),x,inf);
1101 /* #3153 Limits of erfc */
1102 (domain : complex, block([ans],
1103 assume(t > 0,ω > 0),
1104 ans : integrate(exp(-%i*ω^2*ρ^2-(%i*t^2)/(4*ρ^2)),ρ,0,inf),
1105 forget(t > 0, ω > 0),
1107 (-1/2)*((sqrt(-(%i*%pi*ω^2))*%e^-(2*sqrt(-((t^2*ω^2)/4))))/(ω^2))$
1109 (domain : real, block([ans],
1110 assume(t > 0,ω > 0),
1111 ans : integrate(exp(-%i*ω^2*ρ^2-(%i*t^2)/(4*ρ^2)),ρ,0,inf),
1112 forget(t > 0, ω > 0),
1114 -(((-1)^(1/4)*sqrt(%pi)*%e^-(%i*t*ω))/(2*ω))$
1116 /* #4277 limit misses some constant expressions */
1117 block([limsubst : false], limit(sum(f(x),x,1,inf),x, 3));
1120 block([limsubst : true], limit(sum(f(x),x,1,inf),x, 3));
1123 limit(integrate(f(x),x),x,%pi);
1124 'limit('integrate(f(x),x),x,%pi)$
1126 block([limsubst : false], limit(integrate(f(x,t),t),x,%pi));
1127 'limit('integrate(f(x,t),t),x,%pi)$
1129 block([limsubst : true], limit(integrate(f(x,t),t),x,%pi));
1130 'limit('integrate(f(x,t),t),x,%pi)$
1132 block([limsubst : false], limit(diff(g(x,t),t,3),x,42));
1133 'limit('diff(g(x,t),t,3),x,42)$
1135 block([limsubst : true], limit(diff(g(x,t),t,3),x,42));
1138 /* #4210 tlimit consults global assumptions for limit variable*/
1139 tlimit(atan(1/x),x,0,'minus);
1142 tlimit(atan(1/x),x,0,'plus);
1147 ans : tlimit(atan(1/x),x,0,'minus),
1154 ans : limit(atan(1/x),x,0,'minus),
1159 /* #4191 limits of gamma_incomplete */
1160 limit(gamma_incomplete(3,x),x,minf);
1163 limit(gamma_incomplete(3,sin(x)),x,inf);
1166 limit(gamma_incomplete(3, sin(x)*exp(x)),x,inf);
1169 /* #4185 limit of the form ind/ind */
1170 limit((5+cos(x))/(7+cos(x)),x,inf);
1173 limit((5+cos(x))/(1+cos(x)),x,inf);
1176 limit((5+cos(x))/(cos(x)),x,inf);
1179 /* #4197 limits of erfi expressions & extended reals*/
1180 limit(erfi(sin(x)*exp(x)),x,inf);
1183 limit(erfi(sin(x)),x,inf);
1190 /* Did any values, facts, or contexts leak?*/