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 errcatch( limit(gamma(1/x)/gamma(x),x,0,plus));
166 errcatch( 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 /* With the default value of lhospitallim, the calculation takes about 7 seconds.
185 Arguably, it's so slow, it's a bug. So we'll locally set lhospitallim to 1.*/
186 block([lhospitallim : 1], limit(rectform(asin(3+%i*x)),x,0,'plus));
187 -((%i*log(17-3*2^(5/2))-%pi)/2)$
189 block([lhospitallim : 1], limit(rectform(asin(3+%i*x)),x,0,'minus));
190 %pi/2-%i*log(2^(3/2)+3)$
192 /* #3838 limit(atan(sin(x)),x,inf,plus) --> atan(ind) */
193 limit(atan(sin(x)),x,inf,plus);
196 /* #3836 limit of a log expression with essential singularity */
197 limit(log(-2 + %i*x * sin(1/x)),x,0,plus);
200 /* #3824 limit of an antiderivative */
201 (xxx : integrate((x-%i)/((x-2*%i)*(x^2+1)),x),0);
204 limit(rectform(xxx),x,minf);
207 rectform(limit(xxx,x,minf));
210 /* #3816 limit of difference of logs */
211 (xxx : (%i*log(x^2+1))/6-(%i*log(x-2*%i))/3,0);
214 limit(rectform(xxx),x,minf,'plus);
217 rectform(limit(xxx,x,minf,'plus));
223 /* #3592 Wrong limit */
224 (declare(n,integer),assume(n > 0), 0);
227 limit((z^(2*n)-1)/(z^2-1),z,-1);
230 (remove(n,integer),forget(n > 0),0);
233 /* #3589 Stack overflow for a limit evaluation */
234 limit((sqrt(x)-2)*log(1-sqrt(x)/2),x,4,minus);
237 /* #3587 Wrong limit for logarithmic function */
238 limit(log(3-sqrt(x)),x,9,minus);
241 /* #3562 integrate(1/(1+tan(x)), x, 0, %pi/2) gives complex result, should be %pi/4 */
242 integrate(1/(1+tan(x)),x,0,%pi/2);
245 /* #3535 limit doesn't account for certain singularities in mexpt, log, gamma_incomplete, ... */
246 limit(log(%i*x - 1),x,0,minus);
249 limit(log(%i*x - 1),x,0,plus);
252 limit(rectform(log(%i*x - 1)),x,0,minus);
255 limit(rectform(log(%i*x - 1)),x,0,plus);
258 limit(sqrt((%i-x)^2),x,0,'minus);
261 limit(sqrt((%i-x)^2),x,0,'plus);
264 /* need tests for gamma_incomplete(1/2, %i*x - 1) */
266 /* #3534 integrate(x*exp(-x^2)*sin(x),x,minf,inf) gives zero */
267 integrate(x*exp(-x^2)*sin(x),x,minf,inf);
268 sqrt(%pi)/(2 * (%e)^(1/4))$
270 /* #3509 limits involving multiple non-finites sometimes give errors */
271 limit(1/(zeroa+zerob));
274 limit(1/(1/inf+1/minf));
277 limit(signum(zeroa+zerob));
280 /* #3483 limit apparently causes infinite loop
281 (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);
284 limit(ratsimp(X),t,1);
285 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
289 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
296 /* #3459 Wrong limit calculation */
297 limit(x / (x+2^x+cos(x)),x,-inf);
300 /* #3415 limit doesn't check for zero coefficients in limit((a*x+1)/(a*x+2),x,inf) */
302 (assume(equal(a,0)),0);
305 limit((a*x+1)/(a*x+2),x,inf);
308 (forget(equal(a,0)),0);
311 /* #3393 limit/tlimit give wrong result */
312 limit(log(log(x + exp(log(x) * log(log(x))))) / log(log(log(exp(x) + x))), x, inf);
315 /* #3345 bug in limit -- hard to test--works OK with an assume on y*/
317 /* #3313 limit fails with domain complex --bad failure; commented out for now:
318 block([domain : 'complex], limit((x*(4/log(x))^(2*log(x)/log(log(x)))),x,inf));
321 /* #3279 limit incorrect with domain:complex */
322 block([domain : 'real], limit((2^(2*x+1)+(2^x*x^100)^(3/2))/(4^x-100*2^x),x,inf));
325 block([domain : 'complex], limit((2^(2*x+1)+(2^x*x^100)^(3/2))/(4^x-100*2^x),x,inf));
328 /* #3203 limit(floor(n*x),x,0) for n > 10^8 */
329 limit(floor((10^8 +1)*x),x,0,minus);
332 /* #3153 Limits of erfc
333 integrate(exp(-%i*ω^2*ρ^2-(%i*t^2)/(4*ρ^2)),ρ,0,inf);
334 1/sqrt(%i/%pi)*1/(2*ω)*exp(-%i*ω*abs(t))$ */
336 limit(erfc(x*(1 + %i)), x, inf);
339 /* #3143 limit((x^(1/x) - 1)*sqrt(x), x, 0, minus) => inf */
340 limit((x^(1/x) - 1)*sqrt(x), x, 0, minus);
343 /* #3142 limit((x^(1/x) - 1)*sqrt(x), x, inf) => inf */
344 limit((x^(1/x) - 1)*sqrt(x), x, inf);
347 /* #3140 limit((x^(1/x) - 1)*sqrt(x), x, 0, minus) + domain:complex => stack overflow */
348 block([domain : 'real], limit((x^(1/x) - 1)*sqrt(x), x, 0, minus));
352 block([domain : 'complex], limit((x^(1/x) - 1)*sqrt(x), x, 0, minus));
355 /* #3137 gruntz(abs(sin(x))/sqrt(1-cos(x)), x, 0, plus) => stack overflow */
356 limit(abs(sin(x))/sqrt(1-cos(x)), x, 0, plus);
359 gruntz(abs(sin(x))/sqrt(1-cos(x)), x, 0, plus);
362 /* #3136 gruntz(atan2(x^2 - 2, x^3 - 2*x), x, sqrt(2), minus) => atan2(0,0) undefined */
363 limit(atan2(x^2 - 2, x^3 - 2*x), x, sqrt(2), minus);
366 gruntz(atan2(x^2 - 2, x^3 - 2*x), x, sqrt(2), minus);
369 /* #3135 gruntz(atan2(x^2 - 2, x^3 - 3*x), x, sqrt(2), minus) incorrect */
370 limit(atan2(x^2 - 2, x^3 - 3*x), x, sqrt(2), minus);
373 gruntz(atan2(x^2 - 2, x^3 - 3*x), x, sqrt(2), minus);
376 /* #3280 gruntz incorrect limit */
377 gruntz((2^(2*x+1)+(2^x*x^100)^(3/2))/(4^x-100*2^x),x,inf);
380 /* #3055 limit(exp((log(log(x + exp(log(x)*log(log(x)))))) / (log(log(log(exp(x) + x + log(x)))))), x, inf) */
381 limit(exp((log(log(x + exp(log(x)*log(log(x)))))) / (log(log(log(exp(x) + x + log(x)))))), x, inf);
384 /* #3054 limit(exp(exp(2*log(x**5 + x)*log(log(x)))) / exp(exp(10*log(x)*log(log(x)))), x, inf) */
386 limit(exp(exp(2*log(x**5 + x)*log(log(x)))) / exp(exp(10*log(x)*log(log(x)))), x, inf)$
390 /* #3053 limit with branch cuts */
391 block([domain : 'real], limit(sqrt(-1 + %i*x), x, 0,minus));
394 block([domain : 'real], limit(sqrt(-1 - %i*x), x, 0,plus));
397 block([domain : 'complex], limit(sqrt(-1 + %i*x), x, 0,minus));
400 block([domain : 'complex], limit(sqrt(-1 - %i*x), x, 0,plus));
403 /*#3051 limit(2/5*((3/4)^m - 1)*(a - 10) + 1/5*(3*(3/4)^m + 2)*a, m, inf) with domain: complex */
404 block([domain : 'real],limit(2/5*((3/4)^m - 1)*(a - 10) + 1/5*(3*(3/4)^m + 2)*a, m, inf));
407 block([domain : 'complex],limit(2/5*((3/4)^m - 1)*(a - 10) + 1/5*(3*(3/4)^m + 2)*a, m, inf));
410 /* #3041 limit(inf*(zeroa+inf)) => und, should be inf */
411 limit(inf*(zeroa+inf));
414 /* #2972 Wrong limits involving logs */
415 limit( 27^(log(n)/log(3))/n^3, n, inf);
418 limit( 27^(log(n)/log(3)+1)/n^3, n, inf);
421 limit( ((27^(log(n)/log(3)+1)-1)/26+n-log(n)/log(3)-1)/n^3,n,inf);
424 /* #2953 limit loops endlessly */
425 limit((a/x^b + (1-a)/y^b)^(-1/b),b,0);
426 %e^(a*log(x)-(a-1)*log(y))$
428 /* #2899 Limit that once worked is broken */
429 limit((1+sqrt(n+1))^(-n-1)/(1+sqrt(n))^(-n),n,inf);
432 /* #2898 limit of continuous --> und */
433 (e : log(x)^2+2*%gamma*log(x)-%pi^2/6+%gamma^2,0);
437 -((%pi^2-6*%gamma^2)/6)$
442 /* #2877 Limits behave incorrectly when applied to derivatives */
443 (dg: diff(g(x), x),0);
446 (lim: limit(dg, x, 0),0);
449 (limit(lim, x, 0),0);
453 limit('diff(g(x),x,1),x,0)$
455 /* #2849 limit(ind*XXX) and limit(ind/XXX) gives errors rather than results */
456 map('limit, [ind*inf, inf/ind,ind*minf,minf/ind,ind*inf,ind/inf,ind*minf,ind/minf]);
457 [und,und,und,und,und,und,und,und]$
468 /* #2847 limits of powers of constants */
469 limit((1+%i)^n,n,inf);
472 limit((5+%i)^n,n,inf);
475 /*#2653 Bug for limit */
476 limit((atan(x)/x)^(1/(x^2)), x, 0);
479 /* #2388 wrong limit */
480 limit(((9*x)^(1/3)-3)/(sqrt(3+x)-sqrt(2*x)),x,3);
481 (2^(3/2)*sqrt(6)*9^(1/3))/(sqrt(3)*(sqrt(2)*3^(7/6)-2*sqrt(6)*9^(1/3)))$
483 /* #2366 limit of gamma_incomplete */
484 limit(gamma_incomplete(sin(x),cos(x)),x,inf);
487 /* #2187 Inaccurate limit evaluation */
488 is(0 # limit(sin(x)/(x-a),x,0));
491 /* #1822 limit(inf+minf) should give und */
501 /* #1804 limit of x*floor(1/x) as x goes to 0 */
502 limit(x*floor(1/x),x,0);
505 /* #1743 limit of trig expression */
506 (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);
510 -(2*sin(x))/((4*cos(x)^2+4)*sin(x)^2+cos(x)^2+1)$
512 (remvalue(e,dg,lim),0);
515 limit(atan2(sin(x),cos(x)),x,0);
518 limit(atan2(cos(x),sin(x)),x,0);
521 limit(atan2(cos(x),cos(x)),x,0);
524 limit(atan2(1/x^2,sin(1/x)),x,0);
527 limit(atan2(sin(x) + x, cos(x) + x),x,inf);
530 limit(atan2(sin(x) - x, cos(x) + x),x,inf);
533 limit(atan2(sin(x) - x, cos(x) - x),x,inf);
536 limit(atan2(sin(x) - x, cos(x) + x),x,inf);
539 limit(atan2(cos(x),x),x,inf);
542 limit(atan2(sin(x),x),x,minf);
545 limit(atan2(sin(x)/x,x),x,minf);
548 limit(atan2(exp(x),x),x,minf);
551 limit(atan2(-exp(x),x),x,minf);
554 /* #3794 assuming zerob < 0 & zeroa > 0 gives bugs for some limits */
555 limit(atan2(x^2-2,x^3-2*x),x,sqrt(2),minus);
558 (assume(zeroa > 0, zerob < 0),0);
561 limit(atan2(x^2-2,x^3-2*x),x,sqrt(2),minus);
564 (forget(zeroa > 0, zerob < 0),0);
567 /* #3866 limit(log(sinh(x)),x,0,'plus) --> infinity */
569 limit(log(sinh(x)),x,0,'plus);
572 limit(log(sinh(x)),x,0,'minus);
575 limit(log(sinh(x)),x,0);
578 /* unit_step expressions */
580 limit(unit_step(x),x,minf);
583 limit(unit_step(x),x,-%pi);
586 limit(unit_step(x),x,%pi);
589 limit(unit_step(x),x,0,'minus);
592 limit(unit_step(x),x,0,'plus);
595 limit(23*unit_step(x),x,0,'minus);
598 limit(23*unit_step(x),x,0,'plus);
601 limit(23*unit_step(x) + 107,x,0,'minus);
604 limit(23*unit_step(x) + 107,x,0,'plus);
607 limit(unit_step(sin(x)),x,0);
610 /* limits of conjugate expressions */
611 limit(conjugate(sqrt(-1+%i*sin(x))),x,0,'minus);
614 limit(conjugate(sqrt(-1+%i*sin(x))),x,0,'plus);
617 limit(conjugate(sqrt(-1+%i*sin(x))),x,0);
620 (assume(a > 0), limit(conjugate(sqrt(a+%i*sin(x))),x,0));
623 limit(conjugate(sqrt(-a+%i*sin(x))),x,0,'minus);
626 limit(conjugate(sqrt(-a+%i*sin(x))),x,0,'plus);
629 limit(107+93*conjugate(sqrt(-a+%i*sin(x))),x,0,'minus);
630 107 + 93*conjugate(sqrt(-a))$
632 limit(107+93*conjugate(sqrt(-a+%i*sin(x))),x,0,'plus);
633 107 + 93*conjugate(sqrt(-a))$
637 /* #3865 crash from taking limit of factorial(x) + 1 */
638 limit(factorial(x) + 1, x, 0);
641 limit(atan2(0,1-3^x),x,0,'plus);
644 limit(atan2(0,1-3^x),x,0);
647 /* additional atan tests */
651 limit(atan(x),x,0,minus);
654 limit(atan(x),x,0,plus);
657 limit(atan(x),x,-2.0);
660 block([fpprec : 32], is(limit(atan(x),x,bfloat(sqrt(2))) = atan(bfloat(sqrt(2)))));
663 is(limit(atan(x),x,float(sqrt(2))) = atan(float(sqrt(2))));
666 limit(atan(sin(x)),x,inf);
669 limit(atan(x),x,minf);
672 limit(atan(x),x,inf);
675 limit(atan(x^2),x,inf);
678 limit(atan(1/x),x,0);
681 /* #3864 limit of atan2 expression */
682 limit(atan2(0,1-3^x),x,0,'minus);
686 limit((x^x-a^a)/(x-a), x, a);
689 limit((x^x-2^2)/(x-2), x, 2);
692 tlimit((x^x-a^a)/(x-a), x, a);
695 /* #3844 Wrong limit involving gamma function */
696 limit(gamma(1/x) - x, x, inf);
699 /* #3838 limit(atan(sin(x)),x,inf,plus) --> atan(ind) */
700 limit(atan(sin(x)),x,inf,plus);
703 /* #3483 limit apparently causes infinite loop */
704 (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);
708 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
711 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
714 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
717 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
719 block([algebraic : true], limit(ratsimp(X),t,1));
720 log(sqrt(2)+1)-log(1-sqrt(2))-sqrt(2)$
725 /* #2953 limit loops endlessly */
726 limit((a/x^b + (1-a)/y^b)^(-1/b),b,0);
727 %e^(a*log(x)-(a-1)*log(y))$
729 /* #2706 Limit runs forever, never returning (simplified bug) */
730 block([ans1,ans2, ans3],
732 ans1 : limit((%e^(-sqrt(-zzz))*(w3*sqrt(-zzz)*%e^(2*sqrt(-zzz))-w3*sqrt(-zzz)))/(2*zzz),zzz,0),
735 ans2 : limit((%e^(-sqrt(-zzz))*(w3*sqrt(-zzz)*%e^(2*sqrt(-zzz))-w3*sqrt(-zzz)))/(2*zzz),zzz,0),
738 ans3 : limit((%e^(-sqrt(-zzz))*(w3*sqrt(-zzz)*%e^(2*sqrt(-zzz))-w3*sqrt(-zzz)))/(2*zzz),zzz,0),
743 /* #2388 wrong limit */
744 X : limit(((9*x)^(1/3)-3)/(sqrt(3+x)-sqrt(2*x)),x,3);
745 (2^(3/2)*sqrt(6)*9^(1/3))/(sqrt(3)*(sqrt(2)*3^(7/6)-2*sqrt(6)*9^(1/3)));
749 /* #3861 function simplimsubst problems */
750 limit(log(-1+%i*x) * ceiling(a),x,0,minus);
753 limit(log(-1+%i*x) * a,x,0,minus);
756 /* #484 limit(x=0,x,0) wrong */
757 is(equal(0=0, limit(x=0,x,0)));
760 is(equal(0<0, limit(x<0,x,0)));
763 is(equal(0#0, limit(x#0,x,0)));
769 block([ans],declare(z,complex), ans : limit(atan(x),x,z), remove(z,complex),ans);