# Strange behavior when plotting Floor or Ceiling function

Why the following two codes plot different graphs?

Plot[Floor[x], {x, -5, 5}]
Plot[Floor[x] /. a -> b, {x, -5, 5}]


a and b did not have any assigned value.

It is same for Floor, Ceiling, Round and IntegerPart... all are stepwise function. But for example we have another stepwise function PrimePi and the graphs are same for both cases.

What is wrong with Mathematica? Notice that "/. a -> b" does nothing at all, you can replace it with anything as long the "/." is there.

• This is determined by the Exclusions option. The function you plot has 2 new variables so it doesn't know what not to plot. – Carl Lange Nov 26 '18 at 19:02
• It is not because of variables a and b. You can also have this: Plot[Floor[x] /. (1 -> 1), {x, -5, 5}] – azerbajdzan Nov 26 '18 at 19:04
• Definitely it has something to do with Exclusions, but all stepwise functions should behave the same when plotted. Why is PrimePi treated different than Floor? – azerbajdzan Nov 26 '18 at 19:08
• You're right; that's definitely an interesting corner case! – Carl Lange Nov 26 '18 at 19:20
• It may have to do with the HoldAll attribute of Plot. Plot[Evaluate[func[x] /. a -> b], {x, -5, 5}] plots the same as Plot[Floor[x], {x, -5, 5}]. Presumably, the HoldAll prevents the automatic application of the Exclusions with the exception of the PrimePi case. – Bob Hanlon Nov 26 '18 at 19:50

• numeric solvers: NIntegrate, FindMinimum, NDSolve, ...
• looping constructs: Map, Table, While, Nest, ...
• assignments: Set, Increment, ...
• replacements: Replace, ReplaceAll, ...
• "functions": CompiledFunction, InterpolatingFunction, ...