Entier
   HOME

TheInfoList



OR:

In
mathematics Mathematics is a field of study that discovers and organizes methods, Mathematical theory, theories and theorems that are developed and Mathematical proof, proved for the needs of empirical sciences and mathematics itself. There are many ar ...
, the floor function is the function that takes as input a real number , and gives as output the greatest integer less than or equal to , denoted or . Similarly, the ceiling function maps to the least integer greater than or equal to , denoted or . For example, for floor: , , and for ceiling: , and . The floor of is also called the integral part, integer part, greatest integer, or entier of , and was historically denoted (among other notations). However, the same term, ''integer part'', is also used for truncation towards zero, which differs from the floor function for negative numbers. For an integer , . Although and produce graphs that appear exactly alike, they are not the same when the value of is an exact integer. For example, when , . However, if , then , while .


Notation

The ''integral part'' or ''integer part'' of a number ( 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 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 and . (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 are used for floor, and reversed brackets or for ceiling. The fractional part is the sawtooth function, denoted by for real and defined by the formula : For all ''x'', :. These characters are provided in Unicode: * * * * In the
LaTeX Latex is an emulsion (stable dispersion) of polymer microparticles in water. Latices are found in nature, but synthetic latices are common as well. In nature, latex is found as a wikt:milky, milky fluid, which is present in 10% of all floweri ...
typesetting system, these symbols can be specified with the and commands in math mode. LaTeX has supported UTF-8 since 2018, so the Unicode characters can now be used directly. Larger versions are and .


Definition and properties

Given real numbers ''x'' and ''y'', integers ''m'' and ''n'' and the set of integers \mathbb, floor and ceiling may be defined by the equations : \lfloor x \rfloor=\max \, : \lceil x \rceil=\min \. 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 where \lfloor x \rfloor = m and \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. : \begin \lfloor x \rfloor &= m \ \ &&\mbox &m &\le x < m+1,\\ \lceil x \rceil &= n &&\mbox &\ \ n -1 &< x \le n,\\ \lfloor x \rfloor &= m &&\mbox &x-1 &< m \le x,\\ \lceil x \rceil &= n &&\mbox &x &\le n < x+1. \end 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. : \begin x These formulas show how adding an integer to the arguments affects the functions: : \begin \lfloor x+n \rfloor &= \lfloor x \rfloor+n,\\ \lceil x+n \rceil &= \lceil x \rceil+n,\\ \ &= \. \end The above are never true if is not an integer; however, for every and , the following inequalities hold: :\begin \lfloor x \rfloor + \lfloor y \rfloor &\leq \lfloor x + y \rfloor \leq \lfloor x \rfloor + \lfloor y \rfloor + 1,\\ mu\lceil x \rceil + \lceil y \rceil -1 &\leq \lceil x + y \rceil \leq \lceil x \rceil + \lceil y \rceil. \end


Monotonicity

Both floor and ceiling functions are monotonically non-decreasing functions: : \begin x_ \le x_ &\Rightarrow \lfloor x_ \rfloor \le \lfloor x_ \rfloor, \\ x_ \le x_ &\Rightarrow \lceil x_ \rceil \le \lceil x_ \rceil. \end


Relations among the functions

It is clear from the definitions that :\lfloor x \rfloor \le \lceil x \rceil, with equality if and only if ''x'' is an integer, i.e. :\lceil x \rceil - \lfloor x \rfloor = \begin 0&\mbox x\in \mathbb\\ 1&\mbox x\not\in \mathbb \end In fact, for integers ''n'', both floor and ceiling functions are the identity: :\lfloor n \rfloor = \lceil n \rceil = n. Negating the argument switches floor and ceiling and changes the sign: : \begin \lfloor x \rfloor +\lceil -x \rceil &= 0 \\ -\lfloor x \rfloor &= \lceil -x \rceil \\ -\lceil x \rceil &= \lfloor -x \rfloor \end and: :\lfloor x \rfloor + \lfloor -x \rfloor = \begin 0&\text x\in \mathbb\\ -1&\text x\not\in \mathbb, \end :\lceil x \rceil + \lceil -x \rceil = \begin 0&\text x\in \mathbb\\ 1&\text x\not\in \mathbb. \end Negating the argument complements the fractional part: :\ + \ = \begin 0&\text x\in \mathbb\\ 1&\text x\not\in \mathbb. \end The floor, ceiling, and fractional part functions are idempotent: : \begin \big\lfloor \lfloor x \rfloor \big\rfloor &= \lfloor x \rfloor, \\ \big\lceil \lceil x \rceil \big\rceil &= \lceil x \rceil, \\ \big\ &= \. \end The result of nested floor or ceiling functions is the innermost function: : \begin \big\lfloor \lceil x \rceil \big\rfloor &= \lceil x \rceil, \\ \big\lceil \lfloor x \rfloor \big\rceil &= \lfloor x \rfloor \end due to the identity property for integers.


Quotients

If ''m'' and ''n'' are integers and ''n'' ≠ 0, :0 \le \left\ \le 1-\frac. If ''n'' is positive :\left\lfloor\frac\right\rfloor = \left\lfloor\frac\right\rfloor, :\left\lceil\frac\right\rceil = \left\lceil\frac\right\rceil. If ''m'' is positive :n=\left\lceil\frac\right\rceil + \left\lceil\frac\right\rceil +\dots+\left\lceil\frac\right\rceil, :n=\left\lfloor\frac\right\rfloor + \left\lfloor\frac\right\rfloor +\dots+\left\lfloor\frac\right\rfloor. For ''m'' = 2 these imply :n= \left\lfloor \frac\right \rfloor + \left\lceil\frac\right \rceil. More generally, for positive ''m'' (See Hermite's identity) :\lceil mx \rceil =\left\lceil x\right\rceil + \left\lceil x-\frac\right\rceil +\dots+\left\lceil x-\frac\right\rceil, :\lfloor mx \rfloor=\left\lfloor x\right\rfloor + \left\lfloor x+\frac\right\rfloor +\dots+\left\lfloor x+\frac\right\rfloor. The following can be used to convert floors to ceilings and vice versa (with ''m'' being positive) :\left\lceil \frac \right\rceil = \left\lfloor \frac \right\rfloor = \left\lfloor \frac \right\rfloor + 1, :\left\lfloor \frac \right\rfloor = \left\lceil \frac \right\rceil = \left\lceil \frac \right\rceil - 1, For all ''m'' and ''n'' strictly positive integers: :\sum_^ \left\lfloor \frac \right\rfloor = \frac2, which, for positive and coprime ''m'' and ''n'', reduces to :\sum_^ \left\lfloor \frac \right\rfloor = \tfrac(m - 1)(n - 1) , and similarly for the ceiling and fractional part functions (still for positive and coprime ''m'' and ''n''), :\sum_^ \left\lceil \frac \right\rceil = \tfrac(m + 1)(n - 1), :\sum_^ \left\ = \tfrac(n - 1). Since the right-hand side of the general case is symmetrical in ''m'' and ''n'', this implies that :\left\lfloor \frac \right \rfloor + \left\lfloor \frac \right \rfloor + \dots + \left\lfloor \frac \right \rfloor = \left\lfloor \frac \right \rfloor + \left\lfloor \frac \right \rfloor + \dots + \left\lfloor \frac \right \rfloor. More generally, if ''m'' and ''n'' are positive, :\begin &\left\lfloor \frac \right \rfloor + \left\lfloor \frac \right \rfloor + \left\lfloor \frac \right \rfloor + \dots + \left\lfloor \frac \right \rfloor\\ mu= &\left\lfloor \frac \right \rfloor + \left\lfloor \frac \right \rfloor + \left\lfloor \frac \right \rfloor + \cdots + \left\lfloor \frac \right \rfloor. \end This is sometimes called a reciprocity law. Division by positive integers gives rise to an interesting and sometimes useful property. Assuming m,n >0, : m \leq \left\lfloor \frac \right \rfloor \iff n \leq \left\lfloor \frac \right \rfloor \iff n \leq \frac. Similarly, : m \geq \left\lceil \frac \right \rceil \iff n \geq \left\lceil \frac \right \rceil \iff n \geq \frac. Indeed, : m \leq \left\lfloor \frac \right \rfloor \implies m \leq \frac \implies n \leq \frac \implies n \leq \left \lfloor \frac\right \rfloor \implies \ldots \implies m \leq \left\lfloor \frac \right \rfloor, keeping in mind that \left\lfloor \frac \right\rfloor = \left\lfloor \frac \right\rfloor. The second equivalence involving the ceiling function can be proved similarly.


Nested divisions

For a positive integer ''n'', and arbitrary real numbers ''m'' and ''x'': : \begin \left\lfloor \frac \right\rfloor &= \left\lfloor \frac \right\rfloor \\ px\left\lceil \frac \right\rceil &= \left\lceil \frac \right\rceil. \end


Continuity and series expansions

None of the functions discussed in this article are continuous, but all are piecewise linear: the functions \lfloor x \rfloor, \lceil x \rceil, and \ have discontinuities at the integers. \lfloor x \rfloor is upper semi-continuous and \lceil x \rceil and \ are lower semi-continuous. Since none of the functions discussed in this article are continuous, none of them have a power series expansion. Since floor and ceiling are not periodic, they do not have uniformly convergent Fourier series expansions. The fractional part function has Fourier series expansion \= \frac - \frac \sum_^\infty \frac for not an integer. At points of discontinuity, a Fourier series converges to a value that is the average of its limits on the left and the right, unlike the floor, ceiling and fractional part functions: for ''y'' fixed and ''x'' a multiple of ''y'' the Fourier series given converges to ''y''/2, rather than to ''x'' mod ''y'' = 0. At points of continuity the series converges to the true value. Using the formula \lfloor x\rfloor = x - \ gives \lfloor x\rfloor = x - \frac + \frac \sum_^\infty \frac for not an integer.


Applications


Mod operator

For an integer ''x'' and a positive integer ''y'', the
modulo operation In computing and mathematics, the modulo operation returns the remainder or signed remainder of a Division (mathematics), division, after one number is divided by another, the latter being called the ''modular arithmetic, modulus'' of the operatio ...
, denoted by ''x'' mod ''y'', gives the value of the remainder when ''x'' is divided by ''y''. This definition can be extended to real ''x'' and ''y'', ''y'' ≠ 0, by the formula :x \bmod y = x-y\left\lfloor \frac\right\rfloor. Then it follows from the definition of floor function that this extended operation satisfies many natural properties. Notably, ''x'' mod ''y'' is always between 0 and ''y'', i.e., if ''y'' is positive, :0 \le x \bmod y and if ''y'' is negative, :0 \ge x \bmod y >y.


Quadratic reciprocity

Gauss's third proof of quadratic reciprocity, as modified by Eisenstein, has two basic steps. Let ''p'' and ''q'' be distinct positive odd prime numbers, and let m = \tfrac12(p - 1), n = \tfrac12(q - 1). First, Gauss's lemma is used to show that the Legendre symbols are given by :\begin \left(\frac\right) &= (-1)^, \\ mu\left(\frac\right) &= (-1)^. \end The second step is to use a geometric argument to show that :\left\lfloor\frac\right\rfloor +\left\lfloor\frac\right\rfloor +\dots +\left\lfloor\frac\right\rfloor +\left\lfloor\frac\right\rfloor +\left\lfloor\frac\right\rfloor +\dots +\left\lfloor\frac\right\rfloor = mn. Combining these formulas gives quadratic reciprocity in the form :\left(\frac\right) \left(\frac\right) = (-1)^=(-1)^. There are formulas that use floor to express the quadratic character of small numbers mod odd primes ''p'': :\begin \left(\frac\right) &= (-1)^, \\ mu\left(\frac\right) &= (-1)^. \end


Rounding

For an arbitrary real number x, rounding x to the nearest integer with tie breaking towards positive infinity is given by :\text(x)=\left\lfloor x+\tfrac\right\rfloor = \left\lceil \tfrac12\lfloor 2x \rfloor \right\rceil; rounding towards negative infinity is given as :\text(x)=\left\lceil x-\tfrac\right\rceil = \left\lfloor \tfrac12 \lceil 2x \rceil \right\rfloor. If tie-breaking is away from 0, then the rounding function is :\text(x) = \sgn(x)\left\lfloor, x, +\tfrac\right\rfloor (where \sgn is the sign function), and rounding towards even can be expressed with the more cumbersome :\lfloor x\rceil=\left\lfloor x+\tfrac\right\rfloor+\left\lceil\tfrac14(2x-1)\right\rceil-\left\lfloor\tfrac14(2x-1)\right\rfloor-1, which is the above expression for rounding towards positive infinity \text(x) minus an integrality indicator for \tfrac14(2x-1). Rounding a real number x to the nearest integer value forms a very basic type of quantizer – a ''uniform'' one. A typical (''mid-tread'') uniform quantizer with a quantization ''step size'' equal to some value \Delta can be expressed as :Q(x) = \Delta \cdot \left\lfloor \frac + \frac \right\rfloor,


Number of digits

The number of digits in base ''b'' of a positive integer ''k'' is :\lfloor \log_ \rfloor + 1 = \lceil \log_ \rceil .


Number of strings without repeated characters

The number of possible strings of arbitrary length that doesn't use any character twice is given by :(n)_0 + \cdots + (n)_n = \lfloor e n! \rfloor where: * > 0 is the number of letters in the alphabet (e.g., 26 in English) * the falling factorial (n)_k = n(n-1)\cdots(n-k+1) denotes the number of strings of length that don't use any character twice. * ! denotes the
factorial In mathematics, the factorial of a non-negative denoted is the Product (mathematics), product of all positive integers less than or equal The factorial also equals the product of n with the next smaller factorial: \begin n! &= n \times ...
of * = 2.718... is Euler's number For = 26, this comes out to 1096259850353149530222034277.


Factors of factorials

Let ''n'' be a positive integer and ''p'' a positive prime number. The exponent of the highest power of ''p'' that divides ''n''! is given by a version of Legendre's formula :\left\lfloor\frac\right\rfloor + \left\lfloor\frac\right\rfloor + \left\lfloor\frac\right\rfloor + \dots = \frac where n = \sum_a_kp^k is the way of writing ''n'' in base ''p''. This is a finite sum, since the floors are zero when ''p''''k'' > ''n''.


Beatty sequence

The Beatty sequence shows how every positive irrational number gives rise to a partition of the
natural number In mathematics, the natural numbers are the numbers 0, 1, 2, 3, and so on, possibly excluding 0. Some start counting with 0, defining the natural numbers as the non-negative integers , while others start with 1, defining them as the positive in ...
s into two sequences via the floor function.


Euler's constant (γ)

There are formulas for Euler's constant γ = 0.57721 56649 ... that involve the floor and ceiling, e.g. :\gamma =\int_1^\infty\left(-\right)\,dx, :\gamma = \lim_ \frac \sum_^n \left( \left \lceil \frac \right \rceil - \frac \right), and : \gamma = \sum_^\infty (-1)^k \frac = \tfrac12-\tfrac13 + 2\left(\tfrac14 - \tfrac15 + \tfrac16 - \tfrac17\right) + 3\left(\tfrac18 - \cdots - \tfrac1\right) + \cdots


Riemann zeta function (ζ)

The fractional part function also shows up in integral representations of the Riemann zeta function. It is straightforward to prove (using integration by parts) that if \varphi(x) is any function with a continuous derivative in the closed interval 'a'', ''b'' :\sum_\varphi(n) = \int_a^b\varphi(x) \, dx + \int_a^b\left(\-\tfrac12\right)\varphi'(x) \, dx + \left(\-\tfrac12\right)\varphi(a) - \left(\-\tfrac12\right)\varphi(b). Letting \varphi(n) = n^ for real part of ''s'' greater than 1 and letting ''a'' and ''b'' be integers, and letting ''b'' approach infinity gives :\zeta(s) = s\int_1^\infty\frac\,dx + \frac + \frac 1 2. This formula is valid for all ''s'' with real part greater than −1, (except ''s'' = 1, where there is a pole) and combined with the Fourier expansion for can be used to extend the zeta function to the entire complex plane and to prove its functional equation. For ''s'' = ''σ'' + ''it'' in the critical strip 0 < ''σ'' < 1, :\zeta(s)=s\int_^\infty e^(\lfloor e^\omega\rfloor - e^\omega)e^\,d\omega. In 1947 van der Pol used this representation to construct an analogue computer for finding roots of the zeta function.


Formulas for prime numbers

The floor function appears in several formulas characterizing prime numbers. For example, since \left\lfloor\frac \right\rfloor -\left\lfloor\frac\right\rfloor = \begin 1 &\text m \text n \\ 0 &\text, \end it follows that a positive integer ''n'' is a prime if and only if :\sum_^\infty \left(\left\lfloor\frac\right\rfloor-\left\lfloor\frac\right\rfloor\right) = 2. One may also give formulas for producing the prime numbers. For example, let ''p''''n'' be the ''n''-th prime, and for any integer ''r'' > 1, define the real number ''α'' by the sum :\alpha = \sum_^\infty p_m r^. Then :p_n = \left\lfloor r^\alpha \right\rfloor - r^\left\lfloor r^\alpha\right\rfloor. A similar result is that there is a number ''θ'' = 1.3064... ( Mills' constant) with the property that :\left\lfloor \theta^3 \right\rfloor, \left\lfloor \theta^9 \right\rfloor, \left\lfloor \theta^ \right\rfloor, \dots are all prime.Ribenboim, p. 186 There is also a number ''ω'' = 1.9287800... with the property that :\left\lfloor 2^\omega\right\rfloor, \left\lfloor 2^ \right\rfloor, \left\lfloor 2^ \right\rfloor, \dots are all prime. Let (''x'') be the number of primes less than or equal to ''x''. It is a straightforward deduction from Wilson's theorem that :\pi(n) = \sum_^n\Biggl\lfloor\frac - \left\lfloor\frac\right\rfloor\Biggr\rfloor. Also, if ''n'' ≥ 2, :\pi(n) = \sum_^n \left\lfloor \frac \right\rfloor. None of the formulas in this section are of any practical use.


Solved problems

Ramanujan submitted these problems to the ''Journal of the Indian Mathematical Society''. If ''n'' is a positive integer, prove that
  1. \left\lfloor\tfrac\right\rfloor + \left\lfloor\tfrac\right\rfloor + \left\lfloor\tfrac\right\rfloor = \left\lfloor\tfrac\right\rfloor + \left\lfloor\tfrac\right\rfloor,
  2. \left\lfloor\tfrac12 + \sqrt\right\rfloor = \left\lfloor\tfrac12 + \sqrt\right\rfloor,
  3. \left\lfloor\sqrt+ \sqrt\right\rfloor = \left\lfloor \sqrt\right\rfloor.
Some generalizations to the above floor function identities have been proven.


Unsolved problem

The study of Waring's problem has led to an unsolved problem: Are there any positive integers ''k'' ≥ 6 such that :3^k-2^k\Bigl\lfloor \bigl(\tfrac 3 2\bigr)^k \Bigr\rfloor > 2^k-\Bigl\lfloor \bigl(\tfrac 3 2\bigr)^k \Bigr\rfloor -2 \ ? Mahler has proved there can only be a finite number of such ''k''; none are known.


Computer implementations

In most programming languages, the simplest method to convert a floating point number to an integer does not do floor or ceiling, but truncation. The reason for this is historical, as the first machines used ones' complement and truncation was simpler to implement (floor is simpler in two's complement). FORTRAN was defined to require this behavior and thus almost all processors implement conversion this way. Some consider this to be an unfortunate historical design decision that has led to bugs handling negative offsets and graphics on the negative side of the origin. An arithmetic right-shift of a signed integer x by n is the same as \left\lfloor \tfrac \right\rfloor. Division by a power of 2 is often written as a right-shift, not for optimization as might be assumed, but because the floor of negative results is required. Assuming such shifts are "premature optimization" and replacing them with division can break software. Many programming languages (including C, C++, C#,
Java Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
, Julia, PHP, R, and Python) provide standard functions for floor and ceiling, usually called floor and ceil, or less commonly ceiling. The language APL uses ⌊x for floor. The J Programming Language, a follow-on to APL that is designed to use standard keyboard symbols, uses <. for floor and >. for ceiling. ALGOL usesentier for floor. In Microsoft Excel the function INT rounds down rather than toward zero, while FLOOR rounds toward zero, the opposite of what "int" and "floor" do in other languages. Since 2010 FLOOR has been changed to error if the number is negative. The OpenDocument file format, as used by OpenOffice.org, Libreoffice and others, INT and FLOOR both do floor, and FLOOR has a third argument to reproduce Excel's earlier behavior.


See also

* Bracket (mathematics) * Integer-valued function * Step function *
Modulo operation In computing and mathematics, the modulo operation returns the remainder or signed remainder of a Division (mathematics), division, after one number is divided by another, the latter being called the ''modular arithmetic, modulus'' of the operatio ...


Citations


References

* * * * *Nicholas J. Higham, ''Handbook of writing for the mathematical sciences'', SIAM. , p. 25 * ISO/ IEC. ''ISO/IEC 9899::1999(E): Programming languages — C'' (2nd ed), 1999; Section 6.3.1.4, p. 43. * * * * *Michael Sullivan. ''Precalculus'', 8th edition, p. 86 *


External links

* * Štefan Porubský
"Integer rounding functions"
''Interactive Information Portal for Algorithmic Mathematics'', Institute of Computer Science of the Czech Academy of Sciences, Prague, Czech Republic, retrieved 24 October 2008 * * {{DEFAULTSORT:Floor And Ceiling Functions Special functions Mathematical notation Unary operations