Preply — Study more efficiently by working with a personal tutor. Get 50% off.Affiliate

Wikipedia

Floor and ceiling functions

Floor and ceiling functions

In mathematics, the floor function is the function that takes a real number x as input and returns the greatest integer less than or equal to x, written ⌊x⌋ or floor(x). Similarly, the ceiling function returns the least integer greater than or equal to x, written ⌈x⌉ or ceil(x). For example, for floor: ⌊2.4⌋ = 2, ⌊−2.4⌋ = −3, and for ceiling: ⌈2.4⌉ = 3, and ⌈−2.4⌉ = −2. The floor of x is also called the integral part, integer part, greatest integer, or entier of x, and was historically denoted [x] (among other notations). However, the term "integer part" is ambiguous, as it can also mean truncation towards zero, which differs from the floor function for negative numbers. For an integer n, ⌊n⌋ = ⌈n⌉ = n. Although floor(x + 1) and ceil(x) are equal for non-integer values of x, and thus produce graphs that appear exactly alike, they differ when x is an integer. For example, when x = 2.0001, ⌊2.0001 + 1⌋ = ⌈2.0001⌉ = 3. However, if x = 2, then ⌊2 + 1⌋ = 3 but ⌈2⌉ = 2.

Notation The integral part or integer part of a number (partie entière in the original) was first defined in 1798 by Adrien-Marie Legendre in his proof of the Legendre's formula. Carl Friedrich Gauss introduced the square bracket notation [x] in his third proof of quadratic reciprocity (1808). This remained the standard in mathematics until Kenneth E. Iverson introduced, in his 1962 book A Programming Language, the names "floor" and "ceiling" and the corresponding notations ⌊x⌋ and ⌈x⌉. (Iverson used square brackets for a different purpose, the Iverson bracket notation.) Both notations are now used in mathematics, although Iverson's notation will be followed in this article. In some sources, boldface or double brackets ⟦x⟧ are used for floor, and reversed brackets ⟧x⟦ or ]x[ for ceiling. The fractional part is the sawtooth function, denoted by {x} for real x and defined by the formula

{x} = x − ⌊x⌋ For all x,

0 ≤ {x} < 1. These characters are provided in Unicode and HTML entities:

U+2308 ⌈ LEFT CEILING (&lceil;, &LeftCeiling;) U+2309 ⌉ RIGHT CEILING (&rceil;, &RightCeiling;) U+230A ⌊ LEFT FLOOR (&LeftFloor;, &lfloor;) U+230B ⌋ RIGHT FLOOR (&rfloor;, &RightFloor;) In the LaTeX typesetting system, these symbols can be specified with the \lceil, \rceil, \lfloor, and \rfloor commands in math mode. LaTeX has supported UTF-8 since 2018, so the Unicode characters can now be used directly. Larger versions are\left\lceil, \right\rceil, \left\lfloor, and \right\rfloor.

Definition and properties Given real numbers x and y, integers m and n and the set of integers Z {\displaystyle \mathbb {Z} } , floor and ceiling may be defined by the equations

⌊ x ⌋ = max { m ∈ Z ∣ m ≤ x } , {\displaystyle \lfloor x\rfloor =\max\{m\in \mathbb {Z} \mid m\leq x\},}

⌈ x ⌉ = min { n ∈ Z ∣ n ≥ x } . {\displaystyle \lceil x\rceil =\min\{n\in \mathbb {Z} \mid n\geq x\}.}

Since there is exactly one integer in a half-open interval of length one, for any real number x, there are unique integers m and n satisfying the equation

x − 1 < m ≤ x ≤ n < x + 1 , {\displaystyle x-1<m\leq x\leq n<x+1,}

where ⌊ x ⌋ = m {\displaystyle \lfloor x\rfloor =m} and ⌈ x ⌉ = n {\displaystyle \lceil x\rceil =n} may also be taken as the definition of floor and ceiling.

Equivalences These formulas can be used to simplify expressions involving floors and ceilings.

⌊ x ⌋ = m if and only if m ≤ x < m + 1 , ⌈ x ⌉ = n if and only if n − 1 < x ≤ n , ⌊ x ⌋ = m if and only if x − 1 < m ≤ x , ⌈ x ⌉ = n if and only if x ≤ n < x + 1. {\displaystyle {\begin{alignedat}{3}\lfloor x\rfloor &=m\ \ &&{\mbox{ if and only if }}&m&\leq x<m+1,\\\lceil x\rceil &=n&&{\mbox{ if and only if }}&\ \ n-1&<x\leq n,\\\lfloor x\rfloor &=m&&{\mbox{ if and only if }}&x-1&<m\leq x,\\\lceil x\rceil &=n&&{\mbox{ if and only if }}&x&\leq n<x+1.\end{alignedat}}}

In the language of order theory, the floor function is a residuated mapping, that is, part of a Galois connection: it is the upper adjoint of the function that embeds the integers into the reals.

x < n if and only if ⌊ x ⌋ < n , n < x if and only if n < ⌈ x ⌉ , x ≤ n if and only if ⌈ x ⌉ ≤ n , n ≤ x if and only if n ≤ ⌊ x ⌋ . {\displaystyle {\begin{aligned}x<n&\;\;{\mbox{ if and only if }}&\lfloor x\rfloor &<n,\\n<x&\;\;{\mbox{ if and only if }}&n&<\lceil x\rceil ,\\x\leq n&\;\;{\mbox{ if and only if }}&\lceil x\rceil &\leq n,\\n\leq x&\;\;{\mbox{ if and only if }}&n&\leq \lfloor x\rfloor .\end{aligned}}}

These formulas show how adding an integer n to the arguments affects the functions:

⌊ x + n ⌋ = ⌊ x ⌋ + n , ⌈ x + n ⌉ = ⌈ x ⌉ + n , { x + n } = { x } . {\displaystyle {\begin{aligned}\lfloor x+n\rfloor &=\lfloor x\rfloor +n,\\\lceil x+n\rceil &=\lceil x\rceil +n,\\\{x+n\}&=\{x\}.\end{aligned}}}

The above are never true if n is not an integer; however, for every x and y, the following inequalities hold:

⌊ x ⌋ + ⌊ y ⌋ ≤ ⌊ x + y ⌋ ≤ ⌊ x ⌋ + ⌊ y ⌋ + 1 , ⌈ x ⌉ + ⌈ y ⌉ − 1 ≤ ⌈ x + y ⌉ ≤ ⌈ x ⌉ + ⌈ y ⌉ . {\displaystyle {\begin{aligned}\lfloor x\rfloor +\lfloor y\rfloor &\leq \lfloor x+y\rfloor \leq \lfloor x\rfloor +\lfloor y\rfloor +1,\\[3mu]\lceil x\rceil +\lceil y\rceil -1&\leq \lceil x+y\rceil \leq \lceil x\rceil +\lceil y\rceil .\end{aligned}}}

Monotonicity Both floor and ceiling functions are monotonically non-decreasing functions:

x 1 ≤ x 2 ⇒ ⌊ x 1 ⌋ ≤ ⌊ x 2 ⌋ , x 1 ≤ x 2 ⇒ ⌈ x 1 ⌉ ≤ ⌈ x 2 ⌉ . {\displaystyle {\begin{aligned}x_{1}\leq x_{2}&\Rightarrow \lfloor x_{1}\rfloor \leq \lfloor x_{2}\rfloor ,\\x_{1}\leq x_{2}&\Rightarrow \lceil x_{1}\rceil \leq \lceil x_{2}\rceil .\end{aligned}}}

Relations among the functions It is clear from the definitions that

⌊ x ⌋ ≤ ⌈ x ⌉ , {\displaystyle \lfloor x\rfloor \leq \lceil x\rceil ,} with equality if and only if x is an integer, i.e.

⌈ x ⌉ − ⌊ x ⌋ = { 0 if x ∈ Z 1 if x ∉ Z {\displaystyle \lceil x\rceil -\lfloor x\rfloor ={\begin{cases}0&{\mbox{ if }}x\in \mathbb {Z} \\1&{\mbox{ if }}x\not \in \mathbb {Z} \end{cases}}}

In fact, for integers n, both floor and ceiling functions are the identity:

⌊ n ⌋ = ⌈ n ⌉ = n . {\displaystyle \lfloor n\rfloor =\lceil n\rceil =n.}

Negating the argument switches floor and ceiling and changes the sign:

⌊ x ⌋ + ⌈ − x ⌉ = 0 − ⌊ x ⌋ = ⌈ − x ⌉ − ⌈ x ⌉ = ⌊ − x ⌋ {\displaystyle {\begin{aligned}\lfloor x\rfloor +\lceil -x\rceil &=0\\-\lfloor x\rfloor &=\lceil -x\rceil \\-\lceil x\rceil &=\lfloor -x\rfloor \end{aligned}}}

and:

⌊ x ⌋ + ⌊ − x ⌋ = { 0 if x ∈ Z − 1 if x ∉ Z , {\displaystyle \lfloor x\rfloor +\lfloor -x\rfloor ={\begin{cases}0&{\text{if }}x\in \mathbb {Z} \\-1&{\text{if }}x\not \in \mathbb {Z} ,\end{cases}}}

⌈ x ⌉ + ⌈ − x ⌉ = { 0 if x ∈ Z 1 if x ∉ Z . {\displaystyle \lceil x\rceil +\lceil -x\rceil ={\begin{cases}0&{\text{if }}x\in \mathbb {Z} \\1&{\text{if }}x\not \in \mathbb {Z} .\end{cases}}}

Negating the argument complements the fractional part:

{ x } + { − x } = { 0 if x ∈ Z 1 if x ∉ Z . {\displaystyle \{x\}+\{-x\}={\begin{cases}0&{\text{if }}x\in \mathbb {Z} \\1&{\text{if }}x\not \in \mathbb {Z} .\end{cases}}}

The floor, ceiling, and fractional part functions are idempotent:

⌊ ⌊ x ⌋ ⌋ = ⌊ x ⌋ , ⌈ ⌈ x ⌉ ⌉ = ⌈ x ⌉ , { { x } } = { x } . {\displaystyle {\begin{aligned}{\big \lfloor }\lfloor x\rfloor {\big \rfloor }&=\lfloor x\rfloor ,\\{\big \lceil }\lceil x\rceil {\big \rceil }&=\lceil x\rceil ,\\{\big \{}\{x\}{\big \}}&=\{x\}.\end{aligned}}}

The result of nested floor or ceiling functions is the innermost function:

⌊ ⌈ x ⌉ ⌋ = ⌈ x ⌉ , ⌈ ⌊ x ⌋ ⌉ = ⌊ x ⌋ {\displaystyle {\begin{aligned}{\big \lfloor }\lceil x\rceil {\big \rfloor }&=\lceil x\rceil ,\\{\big \lceil }\lfloor x\rfloor {\big \rceil }&=\lfloor x\rfloor \end{aligned}}}

due to the identity property for integers.

Quotients If m and n are integers and n ≠ 0,

0 ≤ { m n } ≤ 1 − 1 | n | . {\displaystyle 0\leq \left\{{\frac {m}{n}}\right\}\leq 1-{\frac {1}{|n|}}.}

If n is positive

⌊ x + m n ⌋ = ⌊ ⌊ x ⌋ + m n ⌋ , {\displaystyle \left\lfloor {\frac {x+m}{n}}\right\rfloor =\left\lfloor {\frac {\lfloor x\rfloor +m}{n}}\right\rfloor ,}

⌈ x + m n ⌉ = ⌈ ⌈ x ⌉ + m n ⌉ . {\displaystyle \left\lceil {\frac {x+m}{n}}\right\rceil =\left\lceil {\frac {\lceil x\rceil +m}{n}}\right\rceil .}

If m is positive

n = ⌈ n 1 m ⌉ + ⌈ n − 1 m ⌉ + ⋯ + ⌈ n − m + 1 m ⌉ , {\displaystyle n=\left\lceil {\frac {n{\vphantom {1}}}{m}}\right\rceil +\left\lceil {\frac {n-1}{m}}\right\rceil +\dots +\left\lceil {\frac {n-m+1}{m}}\right\rceil ,}

n = ⌊ n 1 m ⌋ + ⌊ n + 1 m ⌋ + ⋯ + ⌊ n + m − 1 m ⌋ . {\displaystyle n=\left\lfloor {\frac {n{\vphantom {1}}}{m}}\right\rfloor +\left\lfloor {\frac {n+1}{m}}\right\rfloor +\dots +\left\lfloor {\frac {n+m-1}{m}}\right\rfloor .}

For m = 2 these imply

n = ⌊ n 1 2 ⌋ + ⌈ n 1 2 ⌉ . {\displaystyle n=\left\lfloor {\frac {n{\vphantom {1}}}{2}}\right\rfloor +\left\lceil {\frac {n{\vphantom {1}}}{2}}\right\rceil .}

More generally, for positive m (See Hermite's identity)

⌈ m x ⌉ = ⌈ x ⌉ + ⌈ x − 1 m ⌉ + ⋯ + ⌈ x − m − 1 m ⌉ , {\displaystyle \lceil mx\rceil =\left\lceil x\right\rceil +\left\lceil x-{\frac {1}{m}}\right\rceil +\dots +\left\lceil x-{\frac {m-1}{m}}\right\rceil ,}

⌊ m x ⌋ = ⌊ x ⌋ + ⌊ x + 1 m ⌋ + ⋯ + ⌊ x + m − 1 m ⌋ . {\displaystyle \lfloor mx\rfloor =\left\lfloor x\right\rfloor +\left\lfloor x+{\frac {1}{m}}\right\rfloor +\dots +\left\lfloor x+{\frac {m-1}{m}}\right\rfloor .}

The following can be used to convert floors to ceilings and vice versa (with m being positive)

⌈ n 1 m ⌉ = ⌊ n + m − 1 m ⌋ = ⌊ n − 1 m ⌋ + 1 , {\displaystyle \left\lceil {\frac {n{\vphantom {1}}}{m}}\right\rceil =\left\lfloor {\frac {n+m-1}{m}}\right\rfloor =\left\lfloor {\frac {n-1}{m}}\right\rfloor +1,}

⌊ n 1 m ⌋ = ⌈ n − m + 1 m ⌉ = ⌈ n + 1 m ⌉ − 1 , {\displaystyle \left\lfloor {\frac {n{\vphantom {1}}}{m}}\right\rfloor =\left\lceil {\frac {n-m+1}{m}}\right\rceil =\left\lceil {\frac {n+1}{m}}\right\rceil -1,}

For all m and n strictly positive integers:

∑ k = 1 n − 1 ⌊ k m n ⌋ = ( m − 1 ) ( n − 1 ) + gcd ( m , n ) − 1 2 , {\displaystyle \sum _{k=1}^{n-1}\left\lfloor {\frac {km}{n}}\right\rfloor ={\frac {(m-1)(n-1)+\gcd(m,n)-1}{2}},}

which, for positive and coprime m and n, reduces to

∑ k = 1 n − 1 ⌊ k m n ⌋ = 1 2 ( m − 1 ) ( n − 1 ) , {\displaystyle \sum _{k=1}^{n-1}\left\lfloor {\frac {km}{n}}\right\rfloor ={\tfrac {1}{2}}(m-1)(n-1),}

and similarly for the ceiling and fractional part functions (still for positive and coprime m and n),

∑ k = 1 n − 1 ⌈ k m n ⌉ = 1 2 ( m + 1 ) ( n − 1 ) , {\displaystyle \sum _{k=1}^{n-1}\left\lceil {\frac {km}{n}}\right\rceil ={\tfrac {1}{2}}(m+1)(n-1),}

∑ k = 1 n − 1 { k m n } = 1 2 ( n − 1 ) . {\displaystyle \sum _{k=1}^{n-1}\left\{{\frac {km}{n}}\right\}={\tfrac {1}{2}}(n-1).}

Since the right-hand side of the general case is symmetrical in m and n, this implies that

⌊ m 1 n ⌋ + ⌊ 2 m n ⌋ + ⋯ + ⌊ ( n − 1 ) m n ⌋ = ⌊ n 1 m ⌋ + ⌊ 2 n m ⌋ + ⋯ + ⌊ ( m − 1 ) n m ⌋ . {\displaystyle \left\lfloor {\frac {m{\vphantom {1}}}{n}}\right\rfloor +\left\lfloor {\frac {2m}{n}}\right\rfloor +\dots +\left\lfloor {\frac {(n-1)m}{n}}\right\rfloor =\left\lfloor {\frac {n{\vphantom {1}}}{m}}\right\rfloor +\left\lfloor {\frac {2n}{m}}\right\rfloor +\dots +\left\lfloor {\frac {(m-1)n}{m}}\right\rfloor .}

More generally, if m and n are positive,

⌊ x 1 n ⌋ + ⌊ m + x n ⌋ + ⌊ 2 m + x n ⌋ + ⋯ + ⌊ ( n − 1 ) m + x n ⌋ = ⌊ x 1 m ⌋ + ⌊ n + x m ⌋ + ⌊ 2 n + x m ⌋ + ⋯ + ⌊ ( m − 1 ) n + x m ⌋ . {\displaystyle {\begin{aligned}&\left\lfloor {\frac {x{\vphantom {1}}}{n}}\right\rfloor +\left\lfloor {\frac {m+x}{n}}\right\rfloor +\left\lfloor {\frac {2m+x}{n}}\right\rfloor +\dots +\left\lfloor {\frac {(n-1)m+x}{n}}\right\rfloor \\[5mu]=&\left\lfloor {\frac {x{\vphantom {1}}}{m}}\right\rfloor +\left\lfloor {\frac {n+x}{m}}\right\rfloor +\left\lfloor {\frac {2n+x}{m}}\right\rfloor +\cdots +\left\lfloor {\frac {(m-1)n+x}{m}}\right\rfloor .\end{aligned}}}

This is sometimes called a reciprocity law. Division by positive integers gives rise to an interesting and sometimes useful property. Assuming

Tags

  • Mathematical notation
  • Special functions
  • Unary operations