# Ceiling and floor functions

What are some real life application of ceiling and floor functions? Googling this shows some trivial applications.

• Just in math or in general in science? Sep 5, 2013 at 11:55

If you need 11 foos, and they are sold in packages of 3, you need to buy $\lceil \frac{11}3 \rceil$ packages.

The floor function is, among other things, of great use for arithmetic functions, like the Moebius $\mu$-function, or Mangoldt $\Lambda$-function. We have $$\sum_{n\le x}\mu(n)\left\lfloor \frac{x}{n}\right\rfloor =1,\quad \sum_{n\le x}\Lambda(n)\left\lfloor \frac{x}{n}\right\rfloor =\log (\lfloor x\rfloor !)$$ for example, and there are numerous similar results using floor and ceiling function. (Here $\mu(p)=-1$ for primes $p$, and $\mu(p_1\ldots p_r)=(-1)^r$ for $r$ different primes, and $\mu(n)=0$ if $n$ is not squarefree).

One example is the formula for the the number of derangements $d_n$, which satisfies $$d_n=\left\lfloor \frac{n!}{e}+\frac{1}{2} \right\rfloor.$$ Here it would be difficult to rewrite the equation without the floor function.

However, in many cases, the role floor and ceiling functions play is merely to make equations look more succinct. There's many formulas involving these functions, but the important part for these formulas will not the ceiling or floor parts.

One such case is for the Legendre symbol, which satisfies some identity involving floors, e.g. $$\left(\frac{3}{p}\right)=(-1)^{\lfloor(p-1)/6\rfloor}$$ for odd primes $p$. Instead of using a floor function, we could split it into cases, one for each residue class of $p-1$ modulo $6$ (actually, since $p$ is an odd prime, we could separate the $p=3$ and $p \equiv \pm 1 \pmod 6$ cases).

Suppose a telephone company charges you 0.25 dollar for every minute. Now, you talk 5 minutes and you are charged 1.40 dollar.

But 5 x 0.25 = 1.25

They use ceiling function to make it 1.40 dollar.

Or, suppose they give you an offer to talk 5 minutes for 1.00 dollar. Then they are using floor function.

The floor function can be used when converting time to different formats.

• This would be an even better answer if it showed how to do some time conversions using mathematical notation rather than JavaScript. May 14, 2015 at 0:52

If you mean real life, they come up in discrete contexts all the time. You have fifty crayons to distribute to six children and want to give them each the same whole number of crayons (which may leave some over). They each get $\lfloor \frac {50}6 \rfloor$. You are building a $47$ foot long fence and the posts cannot be more than $4$ feet apart. You need $1+\lceil \frac {47}4 \rceil$ posts.

Prime-counting or "prime-generating" functions often use these functions. See, for example, http://en.wikipedia.org/wiki/Prime-counting_function#Algorithms_for_evaluating_.CF.80.28x.29 and similar.

Unfortunately, these don't often make the calculations any more efficient or effective — they simply make it algebraically clear what's happening.

Suppose I am given an angle of $1102.451$ degrees and I want to know the equivalent angle $x$ degrees such that $0 \leq x < 360$. The answer is

$$x = 1102.451 - 360 \left\lfloor \frac{1102.451}{360} \right\rfloor.$$

If instead the given angle is $18.335$ radians and I want to find the equivalent angle $\theta$ (in radians) such that $0 \leq \theta < 2\pi,$ it's

$$\theta = 18.335 - 2\pi \left\lfloor \frac{18.335}{2\pi} \right\rfloor.$$