Thursday, May 31, 2007

Mod,Floor, Nearest integer & Ceiling funtion


Mod Function:

The absolute value of a real number x is denoted |x| and defined as the "unsigned" portion of x,

|x|=xsgn(x)
(1)
=
(2)

where sgn(x) is the sign function. The absolute value is therefore always greater than or equal to 0. The absolute value of x for real x is plotted above.

he absolute value of a complex number z==x+iy, also called the complex modulus, is defined as

|z|=sqrt(x^2+y^2).
(3)


Note that the derivative (read: complex derivative) d|z|/dz does not exist because at every point in the complex plane, the value of the derivative of |z| depends on the direction in which the derivative is taken (so the Cauchy-Riemann equations cannot and do not hold). However, the real derivative (i.e., restricting the derivative to directions along the real axis) can be defined for points other than x==0 as


(4)

Floor Function:

FloorFunction

The floor function |_x_|, also called the greatest integer function or integer value (Spanier and Oldham 1987), gives the largest integer less than or equal to x. The name and symbol for the floor function were coined by K. E. Iverson (Graham et al. 1994).

Unfortunately, in many older and current works (e.g., Honsberger 1976, p. 30; Steinhaus 1999, p. 300; Shanks 1993; Ribenboim 1996; Hilbert and Cohn-Vossen 1999, p. 38; Hardy 1999, p. 18), the symbol [x] is used instead of |_x_| (Graham et al. 1990, p. 67). Because of the elegant symmetry of the floor function and ceiling function symbols |_x_| and [x], and because [x] is such a useful symbol when interpreted as an Iverson bracket, the use of [x] to denote the floor function should be deprecated. In this work, the symbol [x] is used to denote the nearest integer function since it naturally falls between the |_x_| and [x] symbols.


Since usage concerning fractional part/value and integer part/value can be confusing, the following table gives a summary of names and notations used (D. W. Cantrell, pers. comm.). Here, S&O indicates Spanier and Oldham (1987).

notationnameS&OGraham et al. Mathematica
[x]ceiling function--ceiling, least integerCeiling[x]
mod(m,n)congruence----Mod[m, n]
|_x_|floor functionInt(x)floor, greatest integer, integer partFloor[x]
x-|_x_|fractional valuefrac(x)fractional part or {x}no name
sgn(x)(|x|-|_|x|_|)fractional partFp(x)no nameFractionalPart[x]
sgn(x)|_|x|_|integer partIp(x)no nameIntegerPart[x]
nint(x)nearest integer function----Round[x]
m\nquotient----Quotient[m, n]

The floor function satisfies the identity

|_x+n_|==|_x_|+n
(1)

for all integers n.

A number of geometric-like sequences with a floor function in the numerator can be done analytically. For instance, sums of the form

sum_(n==1)^infty(|_nx_|)/(k^n)
(2)

can be done analytically for rational x. For x==1/m a unit fraction,

sum_(n==1)^inftyk^(-n)|_n/m_|==k/((k-1)(k^m-1)).
(3)

Sums of this form lead to Devil's staircase-like behavior.

For irrational 0" border="0" height="15" width="32">, continued fraction convergents p_n/q_n, and epsilon_n=q_nalpha-p_n,

|_nalpha+epsilon_N_|=={|_nalpha_|   for n<q_(N+1); |_nalpha_|+(-1)^N   for n==q_(N+1)
(4)

(Borwein et al. 2004, p. 12). This leads to the rather amazing result relating sums of the floor function of multiples of alpha to the continued fraction of alpha by

sum_(n==1)^infty|_nalpha_|z^n==(p_0z)/((1-z)^2)+sum_(n==0)^infty(-1)^n(z^(q_n)z^(q_(n+1)))/((1-z^(q_n))(1-z^(q_(n+1))))
(5)

(Mahler 1929; Borwein et al. 2004, p. 12).


Nearest Integer Function:

NearestIntegerFunction

The nearest integer function nint(x) of x, illustrated above and also called nint or the round function, is defined such that [x] is the integer closest to x. Since this definition is ambiguous for half-integers, the additional rule that half-integers are always rounded to even numbers is usually added in order to avoid statistical biasing. For example, [1.5]==2, [2.5]==2, [3.5]==4, [4.5]==4, etc. This convention is followed in the C math.h library function rint, as well as in Mathematica, where the nearest integer function is implemented as Round[x].

Although the notation |_x] is sometimes used to denote the nearest integer function (Hastad et al. 1988), this notation is rather cumbersome and is not recommended. Also note that while [x] is used to denote the nearest integer function in this work, [x] is also commonly used to denote the floor function |_x_|.



Since usage concerning fractional part/value and integer part/value can be confusing, the following table gives a summary of names and notations used (D. W. Cantrell, pers. comm.). Here, S&O indicates Spanier and Oldham (1987).

notationnameS&OGraham et al. Mathematica
[x]ceiling function--ceiling, least integerCeiling[x]
mod(m,n)congruence----Mod[m, n]
|_x_|floor functionInt(x)floor, greatest integer, integer partFloor[x]
x-|_x_|fractional valuefrac(x)fractional part or {x}no name
sgn(x)(|x|-|_|x|_|)fractional partFp(x)no nameFractionalPart[x]
sgn(x)|_|x|_|integer partIp(x)no nameIntegerPart[x]
nint(x)nearest integer function----Round[x]
m\nquotient----Quotient[m, n]
NearestIntegerDiff

The plots above illustrate x^(1/n)-[x^(1/n)] for small n.


Ceiling Function:

CeilingFunction

The function [x] which gives the smallest integer =x" border="0" height="15" width="25">, shown as the thick curve in the above plot. Schroeder (1991) calls the ceiling function symbols the "gallows" because of the similarity in appearance to the structure used for hangings. The name and symbol for the ceiling function were coined by K. E. Iverson (Graham et al. 1990).


The ceiling function is implemented in Mathematica as Ceiling[z], where it is generalized to complex values of z as illustrated above.

Although some authors used the symbol ]x[ to denote the ceiling function (by analogy with the older notation [x] for the floor function), this practice is strongly discouraged (Graham et al. 1990, p. 67). Also strongly discouraged is the use of the symbol {x} to denote the ceiling function (e.g., Harary 1994, pp. 91, 93, and 118-119), since this same symbol is more commonly used to denote the fractional part of x.

Since usage concerning fractional part/value and integer part/value can be confusing, the following table gives a summary of names and notations used (D. W. Cantrell, pers. comm.). Here, S&O indicates Spanier and Oldham (1987).

notationnameS&OGraham et al. Mathematica
[x]ceiling function--ceiling, least integerCeiling[x]
mod(m,n)congruence----Mod[m, n]
|_x_|floor functionInt(x)floor, greatest integer, integer partFloor[x]
x-|_x_|fractional valuefrac(x)fractional part or {x}no name
sgn(x)(|x|-|_|x|_|)fractional partFp(x)no nameFractionalPart[x]
sgn(x)|_|x|_|integer partIp(x)no nameIntegerPart[x]
nint(x)nearest integer function---Round[x]
m\nquotient----Quotient[m, n]