logo

Definition of Intervals in Mathematics 📂Lemmas

Definition of Intervals in Mathematics

Definition

$$ [a,b] := \left\{ x \in \mathbb{R} : a \le x \le b \right\} \subset \mathbb{R} $$

  1. For two real numbers $a \le b$, the set as described above is called an Interval.
  2. In particular, if both endpoints $a,b$ are included, it is notated as $\left[ a,b \right]$ using square brackets [] and is said to be Closed.
  3. If both endpoints $a,b$ are not included, it is notated as $\left( a,b \right)$ using parentheses () and is said to be Open.
  4. If only one of the endpoints is not included, it is called Clopen, and when only $a$ is included it is notated as $[a,b)$, and when only $b$ is included it is notated as $(a,b]$.
  5. In case one of the ends is absent, that is, if it is infinite, the following notation is used. $$ \begin{align*} (-\infty, b) &:= \left\{ x \in \mathbb{R} : x \lt b \right\} \subset \mathbb{R} \\ (a, \infty) &:= \left\{ x \in \mathbb{R} : a \lt x \right\} \subset \mathbb{R} \end{align*} $$

Explanation

An interval is one of the most well-known subsets which has connectivity in a one-dimensional Euclidean space $\mathbb{R}^{1}$. It is easy to understand, familiar, and something that one would often come across in various studies.

Numerical Analysis

In fields such as Numerical Analysis, there are scenarios where one deals with a multitude of points that are neither just two nor in any specific order as in $a,b$. Thus, the smallest interval containing a set of multiple points $S := \left\{ x_{1} , \cdots , x_{n} \right\}$ is often denoted as follows. $$ \mathscr{H} \left\{ x_{1} , \cdots , x_{n} \right\} := \left[ \min S , \max S \right] $$ The fields that are interested in operations with intervals even have a specific area called Interval Arithmetic1.

Programming Languages

I came across an interesting article while randomly searching for something out of curiosity when coding. 2 To summarize, it questions why in programming, instead of using $(0,n]$ or $[1,n]$, a clopen interval $[0,n)$ is used. I wanted to rewrite it, simplifying only the parts I agreed with, from a mathematician’s perspective.

n = 10
for i in 0:n
    print(n)

In many programming languages including Python and MATLAB, similar codes are often used, and mostly, the execution result of that code is as follows. (Note that this code is neither Python nor MATLAB but a hypothetical language.)

0123456789

What this means is, if it’s controlled by 0:n, then it is considered as a clopen interval $[0,n)$. This kind of thinking, or convention, has the advantage where if indexes are used starting from $0$ to $i = 0, 1, \cdots , n-1$, then the ’total number of iterations’ fittingly comes out to be $n$. Using such an intuitive notation can significantly reduce errors and becomes a practical habit.

Moreover, in languages like C, the same expression must be written as for(i=0; i<10; i++), but if one starts from 1 and ends exactly at 10, it should be compared with for(i=1; i<=10; i++). The operator itself becomes messier, shifting from < to <=, and in fact, when accessing arrays in C, 0 must be included. Therefore, that kind of loop might be stupidly written as for(i=0; i<=(10-1); i++).

Meaning, confusing beginners at coding and being off by 1 is not always to torment you, but there might be some seemingly good reasons for it.