Is it always safe to assume that a integral is zero if it has equal bounds?

The problem is that you cannot directly make a substitution which is not one-to-one on the domain of interest. Thus you can take $t=\sin(x)$, but to do so you need to split the domain between $[0,\pi/2],[\pi/2,3\pi/2],[3\pi/2,2\pi]$.

This condition of being one-to-one can actually be relaxed. Indeed, in general $\int_a^b f(g(x)) g'(x) dx = \int_{g(a)}^{g(b)} f(t) dt$; this is just the fundamental theorem of calculus and the chain rule. But in substitution you need to be careful about using the right $g'(x)$ throughout the entire new interval, which in general amounts to picking the right "inverse" $x(t)$.

For example, naively, you might compute $\int_{-1}^1 x^4 dx = \frac{1}{2} \int_1^1 u^{3/2} du$ with $u=x^2$. But in fact the correct way to do this substitution you find $\int_{-1}^1 x^4 dx = \frac{1}{2} \int_1^0 -u^{3/2} du + \frac{1}{2} \int_0^1 u^{3/2} du$ which is nonzero. This happens because when you pass through $u=0$ you need to switch from one local inverse of $x^2$, namely $-\sqrt{u}$, to the other, namely $\sqrt{u}$.


Hidden parity trick: $$\begin{eqnarray*}\int_{0}^{2\pi}\frac{x\cos x}{1+\sin^2 x}\,dx = -\int_{-\pi}^{\pi}\frac{(z+\pi)\cos z}{1+\sin^2 z}\,dx &\color{red}{=}& -2\pi\int_{0}^{\pi}\frac{\cos z}{1+\sin^2 z}\,dz\\[0.2cm]&=&-2\pi\,\left.\arctan(\sin z)\right|_{0}^{\pi}\\&=&\color{red}{0}.\end{eqnarray*}$$


If $f$ is any function then the symbol $\int_{a}^{a}f(x)\,dx$ is defined to be $0$. That answers the question in your title. But it appears that your question is in the context of substitution during evaluation of an integral. What follows is a detailed answer in that context.


I think there is some typo in the question. If you substitute $ t = \sin x$ then the integrand $$\frac{x\cos x}{1 + \sin^{2}x}$$ should change to $$\frac{\arcsin t}{1 + t^{2}}$$ Let's assume that this typo is corrected. Then we should ideally have (at least that is what OP is expecting) $$\int_{0}^{2\pi}\frac{x\cos x}{1 + \sin^{2}x}\,dx = \int_{0}^{0}\frac{\arcsin t}{1 + t^{2}}\,dt\tag{1}$$ The change of variables is based on the following theorem:

If $g'$ is continuous on $[a, b]$ and $f$ is continuous on $g([a, b])$ then $$\int_{g(a)}^{g(b)}f(t)\,dt = \int_{a}^{b}f(g(x))g'(x)\,dx$$

Note that in the above theorem we don't need $g$ to be strictly monotone. For the current question, $$f(t) = \frac{\arcsin t}{1 + t^{2}}$$ and $$g(x) = \sin x$$ Clearly $g'(x) = \cos x$ is continuous on $[0, 2\pi]$. However range of $g$ i.e. $g([0, 2\pi])$ is not just consisting of $0$ but is the interval $[-1, 1]$. Moreover $f(t)$ is clearly continuous on this range $[-1, 1]$ and hence the substitution is justified and the integral should be $0$ by equation $(1)$ (as both the bounds of integration are equal).

Then what is the problem?? Let's see if we have $$f(g(x)) = \frac{x}{1 + \sin^{2}x}\tag{2}$$ for all $x \in [0, 2\pi]$? Clearly if we put $x = \pi$ so that $g(x) = 0$ and then $f(g(x)) = f(0) = 0$ but RHS of $(2)$ is clearly equal to $\pi$ when $x = \pi$. And therefore we get a problem. The reason is simply that we can not write the part $$\frac{x}{1 + \sin^{2}x}$$ into the form $f(g(x))$ for all $x \in [0, 2\pi]$ (the part $\cos x\,dx$ can be safely written in the form $g'(x)dx$). The substitution $t = \sin x$ is thus OK but we are not getting a suitable function $f$ so that the integrand can be expressed in the form $f(g(x))g'(x)$ for all $x \in [0, 2\pi]$.

Let's also see why it is not possible to express the integrand in the form $f(g(x))g'(x)$ in this particular case. As noted above the issue comes in representing $x/(1 + \sin^{2}x)$ in form $f(\sin x)$. The reason is that sometimes we have the integrand not in form of $f(g(x))g'(x)$ but rather in the form of $f(x, g(x))g'(x)$. Thus there is some part of $f$ which is made of $g(x)$ but some part is not made of $g(x)$ but rather made of $x$. Now the only way to get $x$ from $g(x)$ is to go for the inverse $g^{-1}$ and this exists only when $g(x)$ is one-one (for continuous functions this implies strict monotone nature). Therefore in cases when the integrand is not of the form $f(g(x))g'(x)$ but rather of the form $f(x, g(x))g'(x)$ then we need to split the interval of integration into multiple sub-intervals such that on each sub-interval there is an inverse of $g(x)$ (which implies $g(x)$ is strictly monotone).

Note that if the integral was $$\int_{0}^{2\pi}\frac{\sin x\cos x}{1 + \sin^{2}x}\,dx\tag{3}$$ then we don't have the problem mentioned above and $t = \sin x$ reduces the above integral to $$\int_{0}^{0}\frac{t}{1 + t^{2}}\,dt = 0$$ The substitution works fine even if we integrate in $[0, \pi]$ and result is $0$.

How to salvage the situation for our original integral $(1)$?? We split the interval $[0, 2\pi]$ into 4 sub-intervals of equal length. For the interval $[0, \pi/2]$ the function $f$ is given by $$f(t) = \frac{\arcsin t}{1 + t^{2}}$$ For $[\pi/2, \pi]$ we have $$f(t) = \frac{\pi - \arcsin t}{1 + t^{2}}$$ For interval $[\pi, 3\pi/2]$ we have $$f(t) = \frac{\pi - \arcsin t}{1 + t^{2}}$$ and finally for $[3\pi/2, 2\pi]$ we have $$f(t) = \frac{2\pi + \arcsin t}{1 + t^{2}}$$ (the bounds for integrating with respect to $t$ are easily calculated for these four intervals by using $t = \sin x$). Note that the above choices for $f(t)$ guarantee that the equation $$f(g(x)) = \frac{x}{1 + \sin^{2}x}$$ is satisfied for all $x \in [0, 2\pi]$.

We thus have \begin{align} I &= \int_{0}^{2\pi}\frac{x\cos x}{1 + \sin^{2}x}\,dx\notag\\ &= \int_{0}^{\pi/2}\frac{x\cos x}{1 + \sin^{2}x}\,dx + \int_{\pi/2}^{\pi}\frac{x\cos x}{1 + \sin^{2}x}\,dx\notag\\ &\,\,\,\,\,\,\,\, + \int_{\pi}^{3\pi/2}\frac{x\cos x}{1 + \sin^{2}x}\,dx + \int_{3\pi/2}^{2\pi}\frac{x\cos x}{1 + \sin^{2}x}\,dx\notag\\ &= \int_{0}^{1}\frac{\arcsin t}{1 + t^{2}}\,dt + \int_{1}^{0}\frac{\pi - \arcsin t}{1 + t^{2}}\,dt\notag\\ &\,\,\,\,\,\,\,\, + \int_{0}^{-1}\frac{\pi - \arcsin t}{1 + t^{2}}\,dt + \int_{-1}^{0}\frac{2\pi + \arcsin t}{1 + t^{2}}\,dt\notag\\ &= 2\int_{0}^{1}\frac{\arcsin t}{1 + t^{2}}\,dt + 2\int_{-1}^{0}\frac{\arcsin t}{1 + t^{2}}\,dt\notag\\ &\,\,\,\,\,\,\,\,+ 2\pi\int_{-1}^{0}\frac{dt}{1 + t^{2}} - \pi\int_{-1}^{1}\frac{dt}{1 + t^{2}}\notag\\ &= 2\int_{-1}^{1}\frac{\arcsin t}{1 + t^{2}}\notag\\ &= 0\notag \end{align} So the end result is still $0$ as expected by equation $(1)$ but the change of variables in equation $(1)$ is not justified because we don't have suitable functions to meet the criteria for change of variables during integration.