# Inconsistent behavior of Limit function when evaluating a directed limit at a discontinuity

Consider the following expression:

(* In *) expr1 = Hold[Limit[Sign[x], x -> y, Direction -> "FromAbove"] == Sign[y]]


Now let's substitute a specific value to y:

(* In *) expr2 = expr1 /. y -> 0


If I now evaluate it I get inconsistent results:

(* In *) ReleaseHold[expr1]
(* Out *) True
(* In *) ReleaseHold[expr2]
(* Out *) False


In my opinion, expr1 is wrongly evaluated. I suppose that the Limit function somehow "forgets" about the special case being possible for y == 0 which leads to this problem. How could I avoid this? I would expect to get something like the following for Limit[Sign[x], x -> y, Direction -> "FromAbove"] as a correct result:

(* Out *) Piecewise[{{Sign[y], y != 0}, {1, y == 0}}]

• Even using GenerateConditions -> True doesn't yield the correct answer for the limit "FromAbove". I believe this is a bug. Aug 20, 2020 at 16:54

## 1 Answer

You want to use the GenerateConditions option for Limit, like so:

limit = Limit[Sign[x], x -> y, GenerateConditions -> True]
(* ConditionalExpression[Sign[y], y != 0] *)

limit /. y -> 0
(* Undefined *)


This works with many symbolic functions. In my opinion, it should default to True across the board, but the current default is Automatic, which does different things with different functions.

• Thanks, I guess this will have to do, but I am still not completely happy with it since the directed limit is actually defined at y=0 and that information is not included in the input. Aug 20, 2020 at 12:43
• Oh, I see. I forgot that option and the answer is still wrong! I'll mark it as a bug. Aug 20, 2020 at 16:53