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 block([ans : limit((a/x^b + (1-a)/y^b)^(-1/b),b,0)],
407 [ans, ratsimp(ans)]);
408 [(x^(a-1)*%e^((log(x)/log(y)+1)*log(y)))/y^a,x^a*y^(1-a)]$
410 /* #2899 Limit that once worked is broken */
411 limit((1+sqrt(n+1))^(-n-1)/(1+sqrt(n))^(-n),n,inf);
414 /* #2898 limit of continuous --> und */
415 (e : log(x)^2+2*%gamma*log(x)-%pi^2/6+%gamma^2,0);
419 -((%pi^2-6*%gamma^2)/6)$
424 /* #2877 Limits behave incorrectly when applied to derivatives */
425 (dg: diff(g(x), x),0);
428 (lim: limit(dg, x, 0),0);
431 (limit(lim, x, 0),0);
435 limit('diff(g(x),x,1),x,0)$
437 /* #2849 limit(ind*XXX) and limit(ind/XXX) gives errors rather than results */
438 map('limit, [ind*inf, inf/ind,ind*minf,minf/ind,ind*inf,ind/inf,ind*minf,ind/minf]);
439 [und,und,und,und,und,und,und,und]$
450 /* #2847 limits of powers of constants */
451 limit((1+%i)^n,n,inf);
454 limit((5+%i)^n,n,inf);
457 /*#2653 Bug for limit */
458 limit((atan(x)/x)^(1/(x^2)), x, 0);
461 /* #2388 wrong limit */
462 limit(((9*x)^(1/3)-3)/(sqrt(3+x)-sqrt(2*x)),x,3);
465 /* #2366 limit of gamma_incomplete */
466 limit(gamma_incomplete(sin(x),cos(x)),x,inf);
469 /* #2187 Inaccurate limit evaluation */
470 is(0 # limit(sin(x)/(x-a),x,0));
473 /* #1822 limit(inf+minf) should give und */
483 /* #1804 limit of x*floor(1/x) as x goes to 0 */
484 limit(x*floor(1/x),x,0);
487 /* #1743 limit of trig expression */
488 (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);
492 (4*sin(x))/(cos(4*x)+3*cos(2*x)-8)$
494 (remvalue(e,dg,lim),0);
497 limit(atan2(sin(x),cos(x)),x,0);
500 limit(atan2(cos(x),sin(x)),x,0);
503 limit(atan2(cos(x),cos(x)),x,0);
506 limit(atan2(1/x^2,sin(1/x)),x,0);
509 limit(atan2(sin(x) + x, cos(x) + x),x,inf);
512 limit(atan2(sin(x) - x, cos(x) + x),x,inf);
515 limit(atan2(sin(x) - x, cos(x) - x),x,inf);
518 limit(atan2(sin(x) - x, cos(x) + x),x,inf);
521 limit(atan2(cos(x),x),x,inf);
524 limit(atan2(sin(x),x),x,minf);
527 limit(atan2(sin(x)/x,x),x,minf);
530 limit(atan2(exp(x),x),x,minf);
533 limit(atan2(-exp(x),x),x,minf);
536 /* #3794 assuming zerob < 0 & zeroa > 0 gives bugs for some limits */
537 limit(atan2(x^2-2,x^3-2*x),x,sqrt(2),minus);
540 (assume(zeroa > 0, zerob < 0),0);
543 limit(atan2(x^2-2,x^3-2*x),x,sqrt(2),minus);
546 (forget(zeroa > 0, zerob < 0),0);
549 /* #3866 limit(log(sinh(x)),x,0,'plus) --> infinity */
551 limit(log(sinh(x)),x,0,'plus);
554 limit(log(sinh(x)),x,0,'minus);
557 limit(log(sinh(x)),x,0);
560 /* unit_step expressions */
562 limit(unit_step(x),x,minf);
565 limit(unit_step(x),x,-%pi);
568 limit(unit_step(x),x,%pi);
571 limit(unit_step(x),x,0,'minus);
574 limit(unit_step(x),x,0,'plus);
577 limit(23*unit_step(x),x,0,'minus);
580 limit(23*unit_step(x),x,0,'plus);
583 limit(23*unit_step(x) + 107,x,0,'minus);
586 limit(23*unit_step(x) + 107,x,0,'plus);
589 limit(unit_step(sin(x)),x,0);
592 /* limits of conjugate expressions */
593 limit(conjugate(sqrt(-1+%i*sin(x))),x,0,'minus);
596 limit(conjugate(sqrt(-1+%i*sin(x))),x,0,'plus);
599 limit(conjugate(sqrt(-1+%i*sin(x))),x,0);
602 (assume(a > 0), limit(conjugate(sqrt(a+%i*sin(x))),x,0));
605 limit(conjugate(sqrt(-a+%i*sin(x))),x,0,'minus);
608 limit(conjugate(sqrt(-a+%i*sin(x))),x,0,'plus);
611 limit(107+93*conjugate(sqrt(-a+%i*sin(x))),x,0,'minus);
614 limit(107+93*conjugate(sqrt(-a+%i*sin(x))),x,0,'plus);
619 /* #3865 crash from taking limit of factorial(x) + 1 */
620 limit(factorial(x) + 1, x, 0);
623 limit(atan2(0,1-3^x),x,0,'plus);
626 limit(atan2(0,1-3^x),x,0);
629 /* additional atan tests */
633 limit(atan(x),x,0,minus);
636 limit(atan(x),x,0,plus);
639 limit(atan(x),x,-2.0);
642 block([fpprec : 32], float_approx_equal(limit(atan(x),x,bfloat(sqrt(2))), atan(bfloat(sqrt(2)))));
645 is(limit(atan(x),x,float(sqrt(2))) = atan(float(sqrt(2))));
648 limit(atan(sin(x)),x,inf);
651 limit(atan(x),x,minf);
654 limit(atan(x),x,inf);
657 limit(atan(x^2),x,inf);
660 limit(atan(1/x),x,0);
663 /* #3864 limit of atan2 expression */
664 limit(atan2(0,1-3^x),x,0,'minus);
668 limit((x^x-a^a)/(x-a), x, a);
671 limit((x^x-2^2)/(x-2), x, 2);
674 tlimit((x^x-a^a)/(x-a), x, a);
677 /* #3844 Wrong limit involving gamma function */
678 limit(gamma(1/x) - x, x, inf);
681 /* #3838 limit(atan(sin(x)),x,inf,plus) --> atan(ind) */
682 limit(atan(sin(x)),x,inf,plus);
685 /* #3483 limit apparently causes infinite loop */
686 (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);
690 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
693 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
696 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
699 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
701 block([algebraic : true], limit(ratsimp(X),t,1));
702 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
707 /* #2953 limit loops endlessly */
708 block([ans : limit((a/x^b + (1-a)/y^b)^(-1/b),b,0)],
709 [ans, ratsimp(ans)]);
710 [(x^(a-1)*%e^((log(x)/log(y)+1)*log(y)))/y^a,x^a*y^(1-a)]$
712 /* #2706 Limit runs forever, never returning (simplified bug) */
713 block([ans1,ans2, ans3],
715 ans1 : limit((%e^(-sqrt(-zzz))*(w3*sqrt(-zzz)*%e^(2*sqrt(-zzz))-w3*sqrt(-zzz)))/(2*zzz),zzz,0),
718 ans2 : limit((%e^(-sqrt(-zzz))*(w3*sqrt(-zzz)*%e^(2*sqrt(-zzz))-w3*sqrt(-zzz)))/(2*zzz),zzz,0),
721 ans3 : limit((%e^(-sqrt(-zzz))*(w3*sqrt(-zzz)*%e^(2*sqrt(-zzz))-w3*sqrt(-zzz)))/(2*zzz),zzz,0),
726 /* #2388 wrong limit */
727 X : limit(((9*x)^(1/3)-3)/(sqrt(3+x)-sqrt(2*x)),x,3);
730 block([ans : radcan(X)], remvalue(X),ans);
733 /* #3861 function simplimsubst problems */
734 limit(log(-1+%i*x) * ceiling(a),x,0,minus);
737 limit(log(-1+%i*x) * a,x,0,minus);
740 /* #484 limit(x=0,x,0) wrong */
741 is(equal(0=0, limit(x=0,x,0)));
744 is(equal(0<0, limit(x<0,x,0)));
747 is(equal(0#0, limit(x#0,x,0)));
753 block([ans],declare(z,complex), ans : limit(atan(x),x,z), remove(z,complex),ans);
756 limit(fib(x+1)/fib(x),x,inf);
759 limit(fib(x+2)/fib(x),x,inf);
762 /* #4029 limit(cos(1/x)^2 + sin(1/x)^2 + cos(x),x,0) --> ind */
763 limit(cos(1/x)^2 + sin(1/x)^2,x,0);
766 limit(cos(1/x)^2 + sin(1/x)^2 + cos(x),x,0);
769 block([ans], assume(a > 0),ans : limit(sin(x)^(a),x,inf),forget(a > 0), ans);
772 block([ans], assume(a > 0),ans : limit(sin(x)^(-a),x,inf),forget(a > 0), ans);
775 limit((2+sin(x))^(-9),x,inf);
778 limit((2+sin(x))^(9),x,inf);
781 /* #4099 gruntz called on algebraic */
782 gruntz(((9*x)^(1/3)-3)/(sqrt(3+x)-sqrt(2*x)),x,3,plus);
785 /* This bug is mentioned in the tlimit source code, but I don't think it's reported.*/
786 tlimit(2^n/n^5,n,inf);
789 /* #3927 tlimit(exp(x)/x^5,x,inf) = 0 */
790 tlimit(exp(x)/x^5,x,inf);
793 block([lhospitallim : 8], tlimit(exp(x)/x^5,x,inf));
796 block([lhospitallim : 1], tlimit(exp(x)/x^5,x,inf));
799 block([lhospitallim : 1], tlimit(exp(x)/x^46,x,inf));
802 block([lhospitallim : 1], tlimit(exp(x)/x^107,x,inf));
805 /* See #3932 inconsistent limit results with trig */
806 (QQ: (-rr*csc(rr)^2)+%pi*csc(rr)^2+cot(rr)-%pi/rr^2,0);
812 limit(trigsimp(QQ),rr,0);
815 limit(map('trigsimp,QQ),rr,0);
821 /* #3903 A limit toward infinity gives a nounform */
822 limit((sin(x)+x)/sqrt(x*(2*sin(x)+2*cos(x))+2*x^2+1),x,inf);
825 tlimit((sin(x)+x)/sqrt(x*(2*sin(x)+2*cos(x))+2*x^2+1),x,inf);
828 gruntz((sin(x)+x)/sqrt(x*(2*sin(x)+2*cos(x))+2*x^2+1),x,inf);
831 /* #3826 limit returns temp variable expression */
833 block([ans], assume(q > 0), ans : limit(x^q/(a*x^q- 1),x,inf), forget(q > 0),ans);
836 block([ans], assume(q > 0), ans : tlimit(x^q/(a*x^q- 1),x,inf), forget(q > 0),ans);
839 block([ans], assume(q > 0), ans : gruntz(x^q/(a*x^q- 1),x,inf), forget(q > 0),ans);
842 /* #3393 limit/tlimit give wrong result */
843 limit(log(log(x + exp(log(x) * log(log(x))))) / log(log(log(exp(x) + x))), x, inf);
846 tlimit(log(log(x + exp(log(x) * log(log(x))))) / log(log(log(exp(x) + x))), x, inf);
849 gruntz(log(log(x + exp(log(x) * log(log(x))))) / log(log(log(exp(x) + x))), x, inf);
852 /* #2561 limit(log(x^2),x,-20) gives 2*log(-20) */
853 block([logexpand : false], limit(log(x^2),x,-20));
856 block([logexpand : false], tlimit(log(x^2),x,-20));
859 block([logexpand : false], gruntz(log(x^2),x,-20,minus));
862 /* #2389 incorect limit
863 Commented out for now becuase it calls asksign when it should not
867 ans : limit(((t+1)^k-t^k-k*t^(k-1)-(k*(k-1)/2)*t^(k-2))/t^(k-3),t,inf),
873 /* #2273 limit gives the wrong answer
874 (This bug was fixed long ago, but I'm not sure there was a rtest for it.) */
875 limit((sqrt(t^2+4)*(((t+2/t^2)^2+4)^(3/2)-(t+2/t^2)^3-4*(t+2/t^2)))/
876 (sqrt((t+2/t^2)^2+4)*((t^2+4)^(3/2)-t^3-4*t)),t,inf);
879 tlimit((sqrt(t^2+4)*(((t+2/t^2)^2+4)^(3/2)-(t+2/t^2)^3-4*(t+2/t^2)))/
880 (sqrt((t+2/t^2)^2+4)*((t^2+4)^(3/2)-t^3-4*t)),t,inf);
883 gruntz((sqrt(t^2+4)*(((t+2/t^2)^2+4)^(3/2)-(t+2/t^2)^3-4*(t+2/t^2)))/
884 (sqrt((t+2/t^2)^2+4)*((t^2+4)^(3/2)-t^3-4*t)),t,inf);
887 /* #4109 Limits of polylogarithms */
888 limit(li[2](x)/log(-x)^2,x,inf);
891 limit(li[3](x)/log(-x)^3,x,inf);
894 limit(li[2](x),x,%e/2);
897 /* #4108 limit code & nondefault value of taylor_logexpand */
898 block([taylor_logexpand : false], limit((1/%pi*(atan(n/%pi)+%pi/2))^n,n,inf));
901 block([taylor_logexpand : true], limit((1/%pi*(atan(n/%pi)+%pi/2))^n,n,inf));
904 /* #4103 limit(acot(x),x,0) should be IND (not UND) */
908 /* #4087 limit((%i+1)^a/(2^(a/2)),a,inf) => 0 (wrong) */
909 limit((%i+1)^a*2^(-a/2),a,inf);
912 limit((%i+1)^(2*a)*2^-a,a,inf);
915 /* #4085 limit((2-%i)^a/a!,a,inf) */
916 errcatch(limit((2-%i)^a/a!,a,inf));
919 /* #4081 limit((2+sin(x))^(-2),x,inf) --> und */
920 limit((2+sin(x))^(-2),x,inf);
923 /* #4073 limit(log(sin(x)+9),x,inf) --> und could be ind */
924 limit(log(sin(x)+9),x,inf);
927 /*#4029 limit(cos(1/x)^2 + sin(1/x)^2 + cos(x),x,0) --> ind */
928 limit(cos(1/x)^2 + sin(1/x)^2,x,0);
931 limit(cos(1/x)^2 + sin(1/x)^2 + cos(x),x,0);
934 /* #4024 integrate(x*sin(x)*exp(-x^2),x,0, inf) */
935 integrate(x*sin(x)*exp(-x^2),x,minf, inf);
936 (%e^(-1/4)*sqrt(%pi))/2$
938 /* #4021 limit(inf^(2+1/inf)) should be inf */
939 limit(inf^(2+1/inf));
942 /* #4020 various limit bugs with exp(%i*x) */
943 limit(x*exp(%i*x),x,inf);
946 limit(x+x*exp(%i*x),x,inf);
949 limit(1+x*exp(%i*x),x,inf);
952 limit(sin(x) + x*cos(x),x,inf);
955 /* #4004 a cosine of arcsin limit that is evaluated incorrectly */
958 assume(equal(cos((4 * %pi * m + %pi)/2), 0)),
959 ans : limit(cos((4*m + 1) * asin(1/sqrt(x^2 + 1)))/abs(x), x, 0),
961 forget(equal(cos((4 * %pi * m + %pi)/2), 0)),
965 /* Also mentioned in #4004 */
968 ans : limit(a/x + 1, x, 0),
975 ans : limit(a*x + 1, x, inf),
982 ans : limit((2*x + a)/(x + a), x, 0),
987 /* #4003 limit bug with on-default values for ratsimpexpons and ratfac */
988 block([ratsimpexpons : true, ratfac : true],
989 limit(2/5*((3/4)^m - 1)*(a - 10) + 1/5*(3*(3/4)^m + 2)*a, m, inf));
992 /* #4001 limit(sin(x)/x + sin(x) + cos(x),x,inf) = 0 */
993 limit(sin(x)/x + sin(x) + cos(x),x,inf);
996 /* #4151 limit bug as x tend to inf for trigonometric expressions */
997 limit((4*x^3+2*x^2*sin(x)+1)/(x+1)^2 - 4*x,x,inf);
1000 limit(expand((4*x^3+2*x^2*sin(x)+1)/(x+1)^2 - 4*x),x,inf);
1003 /* #4137 simplimplus bugs */
1004 limit(3^x * cos(x) + sin(x),x,inf);
1007 limit(3^x * cos(x) + 2^x,x,inf);
1010 errcatch(limit(3^x + (9+%i)^x,x,inf));
1013 /* See mailing list https://sourceforge.net/p/maxima/mailman/message/37868153/ */
1014 integrate(tan(x)^(1/3)/(cos(x)+sin(x))^2,x,0,%pi/2);
1015 %pi/(2*sqrt(3))+%pi/(2*3^(3/2))$
1017 /* #4147 integrate(log(sin(x))/cos(x),x,0,%pi/2) */
1018 integrate(log(sin(x))/cos(x),x,0,%pi/2);
1021 /* #4138 limit((1+1/x)^x,x,6/5) is "und" in complex domain */
1022 block([domain : 'complex], limit((1+1/x)^x,x,6/5));
1025 /* #4133 limit(abs(cos(a*x)),x,inf) */
1026 block([ans], (assume(a < 0), ans : limit(abs(cos(a*x)),x,inf), forget(a < 0), ans));
1029 block([ans], (assume(equal(a,0)), ans : limit(abs(cos(a*x)),x,inf), forget(equal(a,0)), ans));
1032 block([ans], (assume(a > 0), ans : limit(abs(cos(a*x)),x,inf), forget(a > 0), ans));
1035 /* #4103 limit(acot(x),x,0) should be IND (not UND) */
1039 /* #4222 limit(6^x, x, 1) and similar cases: stack overflow crash */
1040 integrate(1/10^x, x, 0, 1);
1046 limit(2^x * 3^x, x, 1);
1049 limit(2^x * 3^x + 28,x,1);
1052 limit((2^x * 3^x + 28)/(x+2),x,1);
1055 limit(%pi^2*%i*cos(x-1)*6^x,x,1);
1057 /* end of tests for #4222 */
1059 /* #4227 limit(abs(sin(x))/sin(x), x, inf) = 1 */
1060 limit(abs(sin(x))/sin(x), x, inf);
1063 /* #4133 limit(abs(cos(a*x)),x,inf) */
1064 block([ans], assume(a < 0), ans : limit(abs(cos(a*x)),x,inf), forget(a < 0), ans);
1067 block([ans], assume(a > 0), ans : limit(abs(cos(a*x)),x,inf), forget(a > 0), ans);
1070 block([ans], assume(equal(a,0)), ans : limit(abs(cos(a*x)),x,inf), forget(equal(a,0)), ans);
1073 limit(abs(sin(x) + abs(cos(x))),x,inf);
1076 /* #3824 limit of an antiderivative */
1077 block([xxx : integrate((x-%i)/((x-2*%i)*(x^2+1)),x)],
1078 [limit(rectform(xxx),x,minf), rectform(limit(xxx,x,minf))]);
1081 /* #3483 limit apparently causes infinite loop */
1082 (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);
1085 limit(ratsimp(X),t,1);
1086 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
1088 /* doesn't finish! */
1090 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
1095 /* #4238 limit((abs(sin(x)*cos(x)-x^4) -x)/x^3,x,0,plus) gives internal error
1096 This test exercises the function mabs-subst. */
1097 limit((abs(sin(x)*cos(x)-x^4) -x)/x^3,x,0,plus);
1100 limit(log(cos(x)),x,inf);
1103 /* #3153 Limits of erfc */
1104 (domain : complex, block([ans],
1105 assume(t > 0,ω > 0),
1106 ans : integrate(exp(-%i*ω^2*ρ^2-(%i*t^2)/(4*ρ^2)),ρ,0,inf),
1107 forget(t > 0, ω > 0),
1109 (-1/2)*((sqrt(-(%i*%pi*ω^2))*%e^-(2*sqrt(-((t^2*ω^2)/4))))/(ω^2))$
1111 (domain : real, block([ans],
1112 assume(t > 0,ω > 0),
1113 ans : integrate(exp(-%i*ω^2*ρ^2-(%i*t^2)/(4*ρ^2)),ρ,0,inf),
1114 forget(t > 0, ω > 0),
1116 -(((-1)^(1/4)*sqrt(%pi)*%e^-(%i*t*ω))/(2*ω))$
1118 /* #4277 limit misses some constant expressions */
1119 block([limsubst : false], limit(sum(f(x),x,1,inf),x, 3));
1122 block([limsubst : true], limit(sum(f(x),x,1,inf),x, 3));
1125 limit(integrate(f(x),x),x,%pi);
1126 'limit('integrate(f(x),x),x,%pi)$
1128 block([limsubst : false], limit(integrate(f(x,t),t),x,%pi));
1129 'limit('integrate(f(x,t),t),x,%pi)$
1131 block([limsubst : true], limit(integrate(f(x,t),t),x,%pi));
1132 'limit('integrate(f(x,t),t),x,%pi)$
1134 block([limsubst : false], limit(diff(g(x,t),t,3),x,42));
1135 'limit('diff(g(x,t),t,3),x,42)$
1137 block([limsubst : true], limit(diff(g(x,t),t,3),x,42));
1140 /* #4210 tlimit consults global assumptions for limit variable*/
1141 tlimit(atan(1/x),x,0,'minus);
1144 tlimit(atan(1/x),x,0,'plus);
1149 ans : tlimit(atan(1/x),x,0,'minus),
1156 ans : limit(atan(1/x),x,0,'minus),
1161 /* #4191 limits of gamma_incomplete */
1162 limit(gamma_incomplete(3,x),x,minf);
1165 limit(gamma_incomplete(3,sin(x)),x,inf);
1168 limit(gamma_incomplete(3, sin(x)*exp(x)),x,inf);
1171 /* #4185 limit of the form ind/ind */
1172 limit((5+cos(x))/(7+cos(x)),x,inf);
1175 limit((5+cos(x))/(1+cos(x)),x,inf);
1178 limit((5+cos(x))/(cos(x)),x,inf);
1181 /* #4197 limits of erfi expressions & extended reals*/
1182 limit(erfi(sin(x)*exp(x)),x,inf);
1185 limit(erfi(sin(x)),x,inf);
1188 /* #4321 limits of Newton quotients for some inverse trig */
1190 limit((cos(3+h)-cos(3))/h,h,0);
1193 limit((acos(3+h)-acos(3))/h,h,0);
1196 limit((asin(3+h)-asin(3))/h,h,0);
1199 limit((acos(x+h) - acos(x))/h,h,0);
1200 sqrt(1-x^2)/(x^2-1)$
1202 tlimit((acos(x+h) - acos(x))/h,h,0);
1203 sqrt(1-x^2)/(x^2-1)$
1205 limit((asin(x+h)-asin(x))/h,h,0);
1206 -sqrt(1-x^2)/(x^2-1)$
1208 tlimit((asin(x+h)-asin(x))/h,h,0);
1209 -sqrt(1-x^2)/(x^2-1)$
1211 /* #4338 limit((1+%i)^(2*a)*2^(-a),x,inf) when logexpand is true */
1212 block([logexpand : true], limit((1+%i)^(2*a)*2^(-a),a,inf));
1215 block([logexpand : false], limit((1+%i)^(2*a)*2^(-a),a,inf));
1218 block([logexpand : true], tlimit((1+%i)^(2*a)*2^(-a),a,inf));
1221 block([logexpand : false], tlimit((1+%i)^(2*a)*2^(-a),a,inf));
1228 /* Did any values, facts, or contexts leak?*/