Difference between revisions of "Distance to integers"
From specialfunctionswiki
Line 2: | Line 2: | ||
$$\mathrm{dist}_{\mathbb{Z}}(x)=\inf_{n \in \mathbb{Z}} |x-n|,$$ | $$\mathrm{dist}_{\mathbb{Z}}(x)=\inf_{n \in \mathbb{Z}} |x-n|,$$ | ||
where $\inf$ denotes the [[infimum]]. This function can be computed using the [[floor]] and [[ceiling]] functions: | where $\inf$ denotes the [[infimum]]. This function can be computed using the [[floor]] and [[ceiling]] functions: | ||
− | $$\mathrm{dist}_{\mathbb{Z}}(x)=\min \left( | + | $$\mathrm{dist}_{\mathbb{Z}}(x)=\min \left( x - \lfloor x \rfloor, \lceil x \rceil - x \right).$$ |
[[Category:SpecialFunction]] | [[Category:SpecialFunction]] |
Latest revision as of 03:12, 6 July 2016
Define the function $\mathrm{dist}_{\mathbb{Z}} \colon \mathbb{R} \rightarrow \mathbb{R}$ by $$\mathrm{dist}_{\mathbb{Z}}(x)=\inf_{n \in \mathbb{Z}} |x-n|,$$ where $\inf$ denotes the infimum. This function can be computed using the floor and ceiling functions: $$\mathrm{dist}_{\mathbb{Z}}(x)=\min \left( x - \lfloor x \rfloor, \lceil x \rceil - x \right).$$