ceiling(-x) == -floor(x) is an exact identity for real x (no case split, unlike floor(x) + floor(-x) which is -1 for non-integer x and 0 for integer x). So floor(x) + ceiling(-x) should always simplify to 0.
>>> from sympy import Symbol, floor, ceiling, simplify
>>> x = Symbol('x', real=True)
>>> simplify(floor(x) + ceiling(-x))
ceiling(-x) + floor(x)
Expected: 0.
sympy already has the identity internally, simplify just isn't using it:
>>> ceiling(-x).rewrite(floor)
-floor(x)
Checked numerically for both integer and non-integer, positive and negative x, all give 0:
>>> [floor(v) + ceiling(-v) for v in (2.5, 0.3, -2.7, 3.0, -5)]
[0, 0, 0, 0, 0]
Related but distinct issues (checked before filing, none cover this case): #27564 (frac/floor/ceiling inequality simplification gaps), #27888 (general refine gaps), #9118 (solving floor+ceiling equations, not simplifying them).
ceiling(-x) == -floor(x)is an exact identity for real x (no case split, unlikefloor(x) + floor(-x)which is -1 for non-integer x and 0 for integer x). Sofloor(x) + ceiling(-x)should always simplify to0.Expected:
0.sympy already has the identity internally,
simplifyjust isn't using it:Checked numerically for both integer and non-integer, positive and negative x, all give 0:
Related but distinct issues (checked before filing, none cover this case): #27564 (frac/floor/ceiling inequality simplification gaps), #27888 (general refine gaps), #9118 (solving floor+ceiling equations, not simplifying them).