Floor function

The floor function

In mathematics, the floor function is the function defined as follows: for a real number x, floor(x) is the largest integer less than or equal to x. For example, floor(2.9) = 2, floor(−2) = −2 and floor(−2.3) = −3. The floor function is also denoted by [x] or <math>\lfloor x \rfloor<math>. A more traditional name for it is the integral part of x. The function x−[x], also written as x mod 1, is called the fractional part of x. Every fraction x ≥ 0 can be written as a mixed number, the sum of an integer and a proper fraction. The floor function and fractional part functions extend this decomposition to all real values.

Contents

Some properties of the floor function

We always have

<math> \lfloor x\rfloor \le x < \lfloor x \rfloor + 1<math>

with equality on the left if and only if x is an integer. For any integer k and any real number x, we have

<math> \lfloor k+x \rfloor = k + \lfloor x\rfloor<math>

The ordinary rounding of the number x to the nearest integer can be expressed as floor(x + 0.5).

The floor function is not continuous, but it is upper semi-continuous.

If x is a real number and n is an integer, we have nx if and only if n ≤ floor(x). In fancy language: the floor function is part of a Galois connection; it is the upper adjoint of the function which embeds the integers into the reals.

Using the floor function, one can produce several explicit (yet impractical) formulas for prime numbers. See the article on prime numbers for a number of examples.

The ceiling function

A closely related mathematical function is the ceiling function, which is defined as follows: for any given real number x, ceiling(x) is the smallest integer no less than x. For example, ceiling(2.3) = 3, ceiling(2) = 2 and ceiling(−2.3) = −2. The ceiling function is also denoted by <math>\lceil x \rceil<math>. It is easy to show the following:

<math>\lceil x \rceil = - \lfloor - x \rfloor<math>

and the following:

<math>x \leq \lceil x \rceil < x + 1<math>

For any integer k, we also have the following equality:

<math>\lfloor k / 2 \rfloor + \lceil k / 2 \rceil = k<math>.

If m and n are coprime positive integers, then

<math>\sum_{i=1}^{n-1} \lfloor im / n \rfloor = (m - 1) (n - 1) / 2<math>

Beatty's theorem shows how every positive irrational number gives rise to a partition of the natural numbers into two sequences via the floor function.

The floor and ceiling functions are related by

<math>x=\left\lfloor \frac{x}{2} \right\rfloor + \left\lceil \frac{x}{2} \right\rceil<math>

The operator (int) in C

C and related programming languages have a feature called type casting which allows to turn a floating point value into an integer by prefixing it with (int). This operation is a mixture of the floor and ceiling function: for positive or 0 x it returns floor(x), and for negative x it returns ceiling(x).

Like the floor and ceiling function, this operation is not continuous, which can magnify rounding errors with disastrous consequences. For instance, (int)(0.6/0.2) will return 2 in most implementations of C, even though 0.6/0.2 = 3. The reason is that computers work internally with the binary numeral system, and it is not possible to represent the numbers 0.6 and 0.2 by a finite binary string. So some rounding errors occur, and the result is computed as 2.999999999999999555910790149937 which the (int) operator will happily convert to 2. The POSIX floor() function has similar problems. Because of issues like these, most modern calculators use the decimal numeral system internally.

The fractional part

If x is an irrational number, then the fractional parts nx mod 1, where n runs through the positive integers, are extremely evenly distributed in the open interval (0,1). This can be made precise in various ways, one of which states

<math>\int_0^1 f(t)\; dt = \lim_{N\to\infty} \frac{1}{N}\sum_{n=1}^N f(nx \;\operatorname{mod}\; 1)<math>

for every continuous function f : [0,1] -> R (see limit (mathematics) and integration.)

According to a general principle of diophantine approximation discovered by Hermann Weyl, that property is equivalent to something much easier to check in this case: namely that sums

<math>\sum e^{2 \pi i k n x}<math>

for fixed integers k > 0 and taken over ranges

0 < n < N

have estimates o(N). Because these are geometric progressions, that can be proved rather directly. The condition that x be irrational comes out to be that

<math>\sin \pi k x \ne 0<math>.bg:Функция скобка

de:Gauklammer es:Funcin parte entera fr:Partie entire nl:Entierfunctie ja:端数処理 pl:Część całkowita ru:целая часть sl:celi del

Navigation

  • Art and Cultures
    • Art (https://academickids.com/encyclopedia/index.php/Art)
    • Architecture (https://academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (https://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (https://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools