I noticed that Limit can return nonsense when using inexact parameters. In the following code, a is my (exact/inexact) parameter, and I want to know the limit for b -> 1 (or b -> 1., this does not matter).
expr := Limit[(-b*Cos[a*b] Sin[a/2] + Sin[a*b] Cos[a/2])/(b^2 - 1), b -> 1];
a = 2. Pi;
expr (* Returns -Infinity *)
a = 2 Pi;
expr (* Returns -Pi *)
I observe this behavior in Mathematica 8, 9, and 10.
I then turned to the documentation of Limit, which states:
Limit may return an incorrect answer for an inexact input:
Limit[Log[1 - (Log[Exp[z]/z - 1] + Log[z])/z]/z, z -> 100.] (* -Infinity *)The result is correct when an exact input is used:
Limit[Log[1 - (Log[Exp[z]/z - 1] + Log[z])/z]/z, z -> 100] (* 1/100 Log[1 - 1/100 Log[-100 + E^100]] *)
I can see why Limit fails here: The subexpression 1 - 1/100*Log[-100 + E^100] evaluates to approximately 4*10^-44, which is prohibitively small (in single precision, but not in double - this confuses me a bit).
In my example, however, I can't see tiny or huge numbers that could cause this sort of problem. Can you help me see my error?
Edit: I found this problem when I was calculating the Fourier transform of an RF-pulse to find the maximum power density of its spectrum.
Trace[expr]should help to clarify why the approximate case gives what it gives. – Daniel Lichtblau Jan 27 '16 at 18:05a = 2. [Pi]mean? I see that the output is different, but I am unfamiliar with that syntax (and could not find it here or here). Further, I don't see different output when not using the semicolon, or why2 Piis not equal to2*Pi. – Martin J.H. Jan 27 '16 at 18:59ato2*Pi+eto see an odd result: apparently, there's a sign change in the limit near 2*Pi. – Jan 27 '16 at 19:04