Integers – Number of Integers Between Two Real Numbers

integers

At first thought, the question might appear to be stupid but at least for me it isn't. Note that the question asks the number of integers between two "real" numbers.

For example:

Number of integers between $1.0$ and $3.1$ is two! Difference = $2.1$

Number of integers between $1.9$ and $3.1$ is two! Difference = $1.2$

Number of integers between $1.99 and 2.9$ is one! Difference = $0.91$

Number of integers between $1.0$ and $1.91$ is zero! Difference = $0.91$

Note that there is no pattern.

How can the number of integers between two real numbers be found?

*Accepting solutions which take different cases to solve the problem.

Optional – not related directly to the question (source of the problem):

Find the values of $a$, for which the quadratic expression $ax^2 + (a – 2)x -2$ is negative for exactly two integral values of $x$.

Of course, one who can spot that $-1$ is a root of the equation for any given value of the parameter $a$ can solve it without issues.

But what about in a general case where the root depends on the parameter itself?

My approach to solve the problem was as follows. Firstly, a has to be a positive integer if not, there would be infinitely many integers where the expression would turn out to be negative.

Since $a > 0$, the parabola would be open upwards (convex from bottom and concave from the top). The points were the graph intersects the $x$-axis are the roots of the equation. Any real value which lies between the roots when substituted in the expression would evaluate to a negative real number (obvious from the graph).

enter image description here

Hence, the above problem reduces to finding number of integers between the roots (which can be real) of the equation.

This would mean, the answer to the question of finding the number of integers between two real numbers should be such that conditions can be imposed.

If $p(x, y)$ was the function which gives number of integers between two real numbers $x$ and $y$ then I should be able to write it in the form,
$p(x) = 2$ and solve for the range of values of $a$ where it holds good. ($x$ and $y$ are given in terms of the parameter $a$)

Best Answer

Without loss of generality, let the numbers be $x$ and $y$ with $x\leq y$. Let $f(x,y)$ denote the function of counting how many integers are strictly between $x$ and $y$.

$$f(x,y)=\begin{cases}0&\text{if}~\lfloor y\rfloor - \lfloor x\rfloor = 0\\ \lfloor y\rfloor - \lfloor x\rfloor-1&\text{if otherwise and}~y\in\Bbb Z\\ \lfloor y\rfloor - \lfloor x\rfloor&\text{otherwise} \end{cases}$$

Let us look at each of these cases in detail and see why that is so.

If $\lfloor y\rfloor - \lfloor x\rfloor = 0$ that implies that $\lfloor x\rfloor \leq x \leq y = \lfloor x\rfloor + \{y\} < \lfloor x\rfloor + 1$. As there are no integers between $\lfloor x\rfloor$ and $\lfloor x\rfloor + 1$, we get the answer of zero.

Let us look at the third case next, where $\lfloor y\rfloor-\lfloor x\rfloor \neq 0$ and $y\notin\Bbb Z$. We have the following numbers are all integers between $x$ and $y$: $\{\lfloor x\rfloor+1, \lfloor x\rfloor+2,\dots, \lfloor y\rfloor\}$ (note here that $\lfloor x\rfloor\leq x<\lfloor x\rfloor+1\leq\lfloor y\rfloor < y$, so $\lfloor y\rfloor$ is indeed going to be in this list, unlike as is possible in the first and second cases)

The last term in that set can be written instead as $\lfloor y\rfloor = \lfloor x\rfloor +(\lfloor y\rfloor -\lfloor x\rfloor)$. The number of terms in the set is then the same as the number of terms in the set $\{1,2,\dots,\lfloor y\rfloor-\lfloor x\rfloor\}$ which we know to be $\lfloor y\rfloor-\lfloor x\rfloor$.

Finally, looking at the second case, we see it is the same as the third case with the exception that $\lfloor y\rfloor$ will not be included in the list as $x<\lfloor y\rfloor\not < y$, so the list we formed earlier will be correct all but the final term which will be removed, reducing the count by one.

Related Question