Opentopia Directory Encyclopedia Tools

Floor function

Encyclopedia : F : FL : FLO : Floor function



 

In mathematics, the floor function for a real number x, floor(x) also denoted by [\lfloor x \rfloor] is the function defined as [ \lfloor x \rfloor=\sup\/n\le x\}]. This is, the largest integer less than or equal to x. For example, floor(2.9) = 2, floor(−2) = −2 and floor(−2.3) = −3. For nonnegative x, a more traditional name for floor(x) is the integral part or integral value of x. The function [x -\lfloor x\rfloor], also written as x mod 1, or , is called the fractional part of x. Every fraction x 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.

Some properties of the floor function

:[ \lfloor x\rfloor \le x < \lfloor x \rfloor + 1]
with equality on the left if and only if x is an integer.
  • The floor function is idempotent: [\lfloor\lfloor x\rfloor\rfloor=\lfloor x\rfloor].
  • For any integer k and any real number x,
  • [ \lfloor k+x \rfloor = k + \lfloor x\rfloor.]
  • 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. Being a piecewise constant function, its derivative is zero where it exists, that is, at all points which are not integers.
  • If x is a real number and n is an integer, one has 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 that embeds the integers into the reals.
  • Using the floor function, one can produce several explicit (yet impractical) formulas for prime numbers.
  • The ceiling function

    A closely related mathematical function is the ceiling function, given x, ceiling(x) also denoted by [\lceil x \rceil] is the function defined as [ \lceil x \rceil=\inf\/x\le n\}]. This is, the smallest integer not less than x. For example, ceiling(2.3) = 3, ceiling(2) = 2 and ceiling(−2.3) = −2.

    Some properties of the ceiling function

    [\lceil x \rceil = - \lfloor - x \rfloor]
  • Also:
  • [x \leq \lceil x \rceil < x + 1]
  • For any integer k, we also have the following equality:
  • [\lfloor k / 2 \rfloor + \lceil k / 2 \rceil = k].
    [\sum_^ \lfloor im / n \rfloor = (m - 1) (n - 1) / 2]

    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).

    This operation loses significant data, and can therefore 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.

    Many other languages, such as Java (tested with Sun JDK version 1.5.0_05) and Perl (as of version 5.8.0) behave similarly, as does the POSIX floor() function.

    Because of issues like these, most modern calculators use the decimal numeral system internally.

    Uniform Distribution mod 1

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

    [\int_0^1 f(t)\; dt = \lim_ \frac\sum_^N f(nx \;\operatorname\; 1)]
    for every real-valued continuous function [f:[0,1]\to\mathbb] (see limit (mathematics), integration and equidistribution theorem).

    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

    [\sum\limits_^N e^]
    for [k\in\mathbb] 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

    [\sin \pi k x \ne 0.]

    Truncation

    While the floor function only outputs natural numbers, truncation allows "cutting off the numbers" at a specified position.

     


    From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
    All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.


    Search Titles
    0123456789
    ABCDEFGHIJ
    KLMNOPQRST
    UVWXYZ?

    E-mail this article to:

    Personal Message: