Floor and ceiling functions

Floor and ceiling functions

In mathematics and computer science, the floor and ceiling functions map real numbers to nearby integers. [Ronald Graham, Donald Knuth and Oren Patashnik. "Concrete Mathematics". Addison-Wesley, 1999. Chapter 3, "Integer Functions".]

The floor function, sometimes called the greatest integer function, of a real number "x", denoted variously by [x] [,cite book | author=J.W.S. Cassels | title=An introduction to Diophantine approximation | series=Cambridge Tracts in Mathematics and Mathematical Physics | volume=45 | publisher=Cambridge University Press | year=1957 | pages=1] lfloor x floor, floor("x"), or int("x") [Michael Sullivan. "Precalculus", 8th edition, p. 86] [ [http://mathworld.wolfram.com/FloorFunction.html Floor Function — from Wolfram MathWorld] ] , is a function whose value is the largest integer less than or equal to "x". Formally, for all real numbers "x",

: lfloor x floor=max, {ninmathbb{Z}mid nle x}.

For example, floor(2.9) = 2, floor(−2) = −2 and floor(−12/5) = −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 floor, also written as "x" mod 1, or {"x"}, 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.

The closely-related ceiling function, denoted lceil x ceil or ceil("x") or ceiling("x"), is the function whose value is the smallest integer not less than "x", or, formally,

: lceil x ceil=min,{ninmathbb{Z}mid nge x}.

For example, ceiling(2.3) = 3, ceiling(2) = 2 and ceiling(−12/5) = −2.

The names "floor" and "ceiling" and the corresponding notations were introduced by Kenneth E. Iverson in 1962. [Nicholas J. Higham, "Handbook of writing for the mathematical sciences", SIAM. ISBN 0898714206, p. 25] [Kenneth E. Iverson. "A Programming Language". Wiley, 1962.]

Some properties of the floor function

* For all "x",:: lfloor x floor le x < lfloor x floor + 1:with equality on the left if and only if "x" is an integer.

* The floor function is idempotent: lfloorlfloor x floor floor=lfloor x floor.
* For any integer "k" and any real number "x",: lfloor {k+x} floor = k + lfloor x floor.
*The ordinary rounding of the positive 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 "n" ≤ "x" if and only if "n" ≤ floor("x"). 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.
* If "x" is a real number and "n" is an integer, lfloorlfloor x floor / n floor = lfloor x/n floor holds.
* Using the floor function, one can produce several explicit (yet impractical) formulas for prime numbers.
* For real, non-integer "x", the floor function has the Fourier series representation:lfloor x floor = x - frac{1}{2} + frac{1}{pi} sum_{k=1}^infty frac{sin(2 pi k x)}{k}.
* If "m" and "n" are coprime positive integers, then :sum_{i=1}^{n-1} lfloor im / n floor = (m - 1) (n - 1) / 2
* 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 number of digits in base "b" of a positive integer "k" is:lfloor log_{b}{k} floor + 1

Some properties of the ceiling function

* It is easy to show that::lceil x ceil = - lfloor - x floor
* Also::x leq lceil x ceil < x + 1
* For any integer "k", we have the following equality:: lfloor k / 2 floor + lceil k / 2 ceil = k.

Some properties of the fractional part function

* For all "x":: 0 le {x} < 1:with equality on the left if and only if "x" is an integer.

* For positive integers "m", "n"::0 le {frac{m}{n}} le frac{n-1}{n}.

Computer implementations

The operator (int) in C

C and related programming languages convert floating point values into integers using the type casting syntax: (int) value. The fractional part is discarded (i.e., the value is truncated toward zero) [ISO/IEC. "ISO/IEC 9899::1999(E): Programming languages — C" (2nd ed), 1999; Section 6.3.1.4, p. 43.] .

Spreadsheet software

Most spreadsheet programs support some form of a ceiling function. Although the details differ between programs, most implementations support a second parameter—a multiple of which the given number is to be rounded to. As a typical example, ceiling(2, 3) would round 2 up to the nearest multiple of 3, so this would return 3. The definition of what "round up" means, however, differs from program to program.

Microsoft Excel's ceiling function does not follow the mathematical definition, but rather as with (int) operator in C, it is a mixture of the floor and ceiling function: for "x" ≥ 0 it returns ceiling("x"), and for "x" < 0 it returns floor("x"). This has followed through to the Office Open XML file format. For example, CEILING(-4.5) returns -5. A mathematical ceiling function can be emulated in Excel by using the formula "-INT(-"value")" (please note that this is not a general rule, as it depends on Excel's INT function, which behaves differently that most programming languages).

The OpenDocument file format, as used by OpenOffice.org and others, follows the mathematical definition of ceiling for its ceiling function, with an optional parameter for Excel compatibility. For example, CEILING(-4.5) returns -4.

Typesetting

The floor and ceiling function are usually typeset with left and right square brackets where the upper (for floor function) or lower (for ceiling function) horizontal bars are missing, and, e.g., in the LaTeX typesetting system these symbols can be specified with the lfloor, floor, lceil and ceil commands in math mode. Unicode contains codepoints for these symbols, at U+2308U+230B: ⌈"x"⌉, ⌊"x"⌋.

See also

*Nearest integer function
*Truncation, a similar function

Notes


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • Floor (disambiguation) — Floor may refer to one of the following: In buildings: Floor, the lower surface of a room; and the supportive subfloor, the layer which structurally provides the strength and support for the flooring above commonly miscalled the floor . Storey, a …   Wikipedia

  • Land of the Lost (1974 TV series) geography and technology — Land of the Lost was a 1974 1976 TV series presenting the adventures of the Marshall family (including Will and Holly and their father Rick, later replaced by their uncle Jack). The Marshalls become trapped in a pocket universe populated by… …   Wikipedia

  • Ceiling fan — A ceiling fan is a fan, usually electrically powered, suspended from the ceiling of a room, that uses hub mounted rotating paddles to circulate air. Casablanca Fan Co. ceiling fan from the early 1980s. A ceiling fan rotates much mo …   Wikipedia

  • Ceiling-Funktion — Die Gaußklammer oder Abrundungsfunktion (auch Ganzzahl Funktion, Ganzteilfunktion oder Entier Klammer; engl. floor function) und die Aufrundungsfunktion (engl. ceiling function) sind Funktionen, die einer reellen Zahlen die nächstgrößere bzw.… …   Deutsch Wikipedia

  • Floor-Funktion — Die Gaußklammer oder Abrundungsfunktion (auch Ganzzahl Funktion, Ganzteilfunktion oder Entier Klammer; engl. floor function) und die Aufrundungsfunktion (engl. ceiling function) sind Funktionen, die einer reellen Zahlen die nächstgrößere bzw.… …   Deutsch Wikipedia

  • Floor — A floor is the walking surface of a room or vehicle. Floors vary from simple dirt in a cave to many layered surfaces using modern technology. Floors may be stone, wood, bamboo, metal, or other material that can hold a person s weight.Floors… …   Wikipedia

  • Architecture and Civil Engineering — ▪ 2009 Introduction Architecture       For Notable Civil Engineering Projects in work or completed in 2008, see Table (Notable Civil Engineering Projects (in work or completed, 2008)).        Beijing was the centre of the world of architecture… …   Universalium

  • Business and Industry Review — ▪ 1999 Introduction Overview        Annual Average Rates of Growth of Manufacturing Output, 1980 97, Table Pattern of Output, 1994 97, Table Index Numbers of Production, Employment, and Productivity in Manufacturing Industries, Table (For Annual… …   Universalium

  • garden and landscape design — Introduction       the development and decorative planting of gardens, yards, grounds, parks, and other types of areas. Gardening and landscape design is used to enhance the settings for buildings and public areas and in recreational areas and… …   Universalium

  • Stirling Smith Museum and Art Gallery — [http://www.smithartgallery.demon.co.uk Stirling Smith Art Gallery and Museum] is an institution based in Stirling, Central Scotland, dedicated to the promotion of cultural and historical heritage and the arts, from a local scale to nationally… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”