Test floor function on negative numbers:
(*assumefractionpartofnegativexisϵ,whichisin(-1,0]*)FractionalPart[-5.7]
Out[]=
-0.7
(*assumek=floor[x]fornegativenumber*)
In[]:=
Floor[-5.7]
Out[]=
-6
(*thenumeratoris-2k-1-ϵ*)
In[]:=
5.7-Floor[-5.7]
Out[]=
11.7
Ranges for each interval for k: (-1,0], (-2,-1], (-3,-2] ...
In[]:=
gl=Table,,{k,-7,0}
-2*k-1
2-k
-2*k
2-k
Out[]=
,,,3,,,4,,,2,,,-,0
13
3
14
3
11
2
2
2
,9
7
10
7
7
6
2
3
5
,6
5
3
2
1
3
2
3
1
2
Test if the intervals are disjoint: lower for next is larger than the upper bound of the previous interval:
In[]:=
Reduce>&&k<=-1,k,Integers
-2*(k-1)-1
2-(k-1)
-2*k
2-k
Out[]=
k∈&&k≤-1
In[]:=
Plot,{x,-6.5,0},GridLines->{Range[-6,0],Join@@gl},GridLinesStyle->Directive[{Thickness[0.002],Dashed,Opacity[0.5]}]
Abs[x]-Floor[x]
2-Floor[x]
Out[]=