What happens when the lower limit is greater than the upper limit in a definite integral? For example, what is
$$
\int_2^1 f(x) \, dx
$$
equal to?
Some said it equal to
$$
-\int_1^2 f(x) \, dx
$$
but others said it equal to $0$ because
$(x \geq 2 ) \cap ( x \leq 1 ) = \varnothing$.
Which one is correct? or such cases 'the lower limit bigger than the upper limit' actually are undefined (illegal) that they should be avoided?
 A: Let $F$ be the antiderivative of $f$ defined as $^1$
$$F(x) := \int_0^x f(t)\,dt$$
The usual way to evaluate an indefinite integral is
$$\int_a^b f(x)\,dx := F(b) - F(a)$$
For consistency, we need
$$F(a) - F(b) + (F(b) - F(a)) = 0$$
It is also useful to have the property
$$\int_a^b f(x)\,dx + \int_b^c f(x)\,dx = \int_a^c f(x)\,dx$$
Both of these desirable properties require
$$\int_a^b f(x)\,dx = - \int_b^a f(x)\,dx$$
(for example, think about $c=a$)

$^1$: Wikipedia's Antiderivative article
A: Your first interpretation is consistent with the usual convention. It has to do with orientation of the interval. Think of
$$
\int_a^b f(x) \, dx
$$
as integrating the function $f$ as $x$ moves from $a$ to $b$. So, when the limits are reversed, you are considering the opposite orientation, where $x$ traverses the interval in the opposite direction. Hence,
$$
\int_b^a f(x) \, dx = -\int_a^b f(x) \, dx,
$$
regardless of which of $a$ or $b$ is larger. They can even be equal in which case the integral evaluates to $0$.
A: First things first, I want to clarify a few misconceptions here. The other answers given here imply that $0)$ the definite integral is defined in terms of the antiderivative of a function. This is completely false. $1)$ Another misconception here is that the "interval of integration has an orientation." This is not the case either. An interval is simply defined as a set of real numbers, defined in the following fashion: $[a,b]:=\{x\in\mathbb{R}:a\leq{x}\leq{b}\}.$
What exactly is an integral? An integral is an abstract concept that, at least historically, was first developed when trying to generalize the concept of "area." I strongly suggest you take a look at this link for introductory purposes: https://en.wikipedia.org/wiki/Riemann_integral. The article is a little heavy, but despite its difficulty, I believe you can get quite a decent idea of what an integral is without the misconceptions. To put it briefly: take a function $f:[a,b]\rightarrow\mathbb{R}$ you are interested in. You partition the domain of the function into intervals $[x_k,x_{k+1}],$ and by definition, this obviously means that $x_k\lt{x_{k+1}}$ for every $k.$ Now, choose a point $t_k\in[x_k,x_{k+1}],$ and evaluate $f(t_k).$ Now, define $\lambda$ to be some kind of "length" function: it tells you the "length" of an interval in an intuitive, geometric sense. For our purposes, $\lambda([x_k,x_{k+1}])=x_{k+1}-x_k.$ Now, evaluate $$\sum_kf(t_k)\cdot\lambda([x_k,x_{k+1}]).$$ This is called a Riemann sum. The idea is that you can take Riemann sums where the lengths of each interval $[x_k,x_{k+1}]$ get closer to $0,$ in some specific, rigorous sense. Whatever the sums converge to, is what we call the Riemann integral of $f.$ The product $f(t_k)\cdot\lambda([x_k,x_{k+1}])$ represents the area of a rectangle with the base being $[x_k,x_{k+1}],$ and the height being located at $f(t_k).$ So the sum of these products, in a sense, approximates the area enclosed by the graph of $f.$ As the lengths of $[x_k,x_{k+1}]$ get closer to $0,$ the approximation gets, in a suitable sense, better, so the area enclosed by $f$ is defined to be the Riemann integral of $f.$ This area, which is the Riemann integral of $f,$ at least within higher level mathematics, is denoted as $$\int{f}.$$ However, this notation probably confuses you, and it makes sense why you are confused: this is not the notation used in calculus classrooms. Firstly, where are the "bounds of integration," as teachers call them? Why do we use them? Well, the thing is, most functions you work with at that elementary level of mathematics are functions $f:\mathbb{R}\rightarrow\mathbb{R}.$ So if you want to restrict your function $f$ to the interval $[a,b],$ we specify that by using bounds, hence the notation $$\int_a^bf.$$ Another notation you may find is the notation $$\int_{[a,b]}f.$$ However, this is still not the notation you are familiar with. Where is the differential, and the variable of integration? And why do we use them as part of the notation? Well, there are two reasons. The first reason is historical. When the idea of the integral was first conceived of, the idea was that the symbol $\mathrm{d}x$ was a sort of "limit-replacement" of $x_{k+1}-x_k,$ and thus, this gives us the notation $$\int_a^bf(x)\,\mathrm{d}x$$ or $$\int_{[a,b]}f(x)\,\mathrm{d}x.$$ The second reason is that this notation helps with making the generalization to differential geometry more intuitive. Explaining this is beyond the scope of your question and beyond the scope of my answer, but I just want to let you know there is that reason as well.
Awesome! But this probably only makes it more confusing to understand why you can encounter things such as $$\int_1^{-1}f(x)\,\mathrm{d}x$$ as opposed to $$\int_{-1}^1f(x),\mathrm{d}x.$$ Why would we treat these as different things when they both represent the Riemann integral of $f:[-1,1]\rightarrow\mathbb{R}$? I already explained that intervals have no concept of orientation built into their definition, and neither does the definition of the Riemann integral. So what gives?
It turns out that it is extremely convenient to let $$\int_a^bf(x)\,\mathrm{d}x=-\int_b^af(x)\,\mathrm{d}x$$ for a multitude of reasons. So although the notational convention cannot be derived from the definition of the Riemann integral, it is consistent with the definition of the symbol, so we lose nothing by adopting the convention, and we gain a lot of mathematical shortcuts. For instance, the change of variables theorem, under the formal notation that one would use, would say that if $g$ is differentiable and injective, then $$\int_{[a,b]}f(g(x))|g'(x)|\,\mathrm{d}x=\int_{g([a,b])}f(x)\,\mathrm{d}x,$$ where $g([a,b])$ is the set that $g$ maps $[a,b]$ to. But instead, if we use the notation where the bounds are denoted as a subscript and superscript, and if we allow for the above notational convention, then the theorem can be "restated," so to speak, so that the absolute values are not required, and the injectivity of $g$ is not required either. So instead, you can simply say $$\int_a^bf(g(x))g'(x)\,\mathrm{d}x=\int_{g(a)}^{g(b)}f(x)\,\mathrm{d}x.$$ Notice how much simpler and convenient this version of the theorem is! That is why, in a calculus course, you only ever encounter the second version: since calculus is an applied mathematics course, and not a theory course, there is a heavy emphasis on practical utility and computational techniques and symbolic manipulation, rather than on formality and rigor, so the latter approach, which is less taxing for convenience and symbolic manipulation, is used. But since the second version of the theorem requires that we allow for the notational convention that $$\int_a^bf(x)\,\mathrm{d}x=-\int_b^af(x)\,\mathrm{d}x,$$ we therefore use this convention to allow ourselves to simplify the change of variables theorem.
Another reason we use the notational convention has already been pointed out in the other answers, and that reason is that the fundamental theorem of calculus is made more convenient using this convention. The fundamental theorem of calculus, or at least, the second part of the theorem, states that if $f:[a,b]\rightarrow\mathbb{R}$ has some antiderivative $F:(a,b)\rightarrow\mathbb{R},$ then $$\int_a^bf(x)\,\mathrm{d}x=F(b)-F(a).$$ What this implies is that if your restrict $f$ to $[a,t],$ where $t\in[a,b],$ then $$\int_a^tf(x)\,\mathrm{d}x=F(t)-F(a).$$ BUT... there is another side to this story. What if, instead, you restrict $f$ to $[t,b],$ where $t\in[a,b]$? Then, by the fundamental theorem, $$\int_t^bf(x)\,\mathrm{d}x=F(b)-F(t),$$ which implies $$-\int_t^bf(x)\,\mathrm{d}x=F(t)-F(b).$$ This last equation seems to suggest that $$-\int_t^bf(x)\,\mathrm{d}x=\int_b^tf(x)\,\mathrm{d}x.$$ It does not quite work, since the equation $$\int_b^tf(x)\,\mathrm{d}x=F(t)-F(b)$$ is implied only in the case that $t\geq{b},$ thus it is not the case that $t\in[a,b].$ But since we can change the interval we restrict $f$ to anyway, it does not actually matter! So simply defining, by convention, that $$-\int_t^bf(x)\,\mathrm{d}x=\int_b^tf(x)\,\mathrm{d}x$$ creates no inconsistencies, and it makes it so that we no longer have to worry about whether $t\geq{b}$ or not.
Finally, this convention, once again, makes the generalization of the Riemann integral to differential geometry, where you differentiate differential forms over chains, a lot more straightforward and intuitive. Again, discussing this generalization is beyond the scope of my answer, but because this generalization is so important in mathematics (as it leads to what I consider to be the most beautiful theorem in mathematics, the generalized Stokes' theorem), it should be known that this is another reason for the notational convention. These, and perhaps a few others, are the reason why we adopt this convention. It really has nothing to do with how integrals work, but rather, with making the notation more efficient to use in practice.
