Why am I allowed to cancel terms inside an integral? Given the definite integral
$$
\int_0^{\pi} \frac{\cos \theta}{\cos \theta} \ \text{d}\theta
$$
When $\theta = \frac{\pi}{2}$, the integrand becomes
$$
\frac{0}{0}
$$
Since the integral can be thought of as the limit of a Riemann sum and each $\theta$ in the interval $[0,\pi]$ will eventually be substituted into the integrand, then would it still be correct to write
$$
\int_0^{\pi} \frac{\cos \theta}{\cos \theta} \ \text{d}\theta = \int_0^{\pi} 1 \ \text{d}\theta
$$
If so, why?
 A: The quotient $\frac{\cos\theta}{\cos\theta}$ is equal to $1$ if $\theta\in\left[0,\frac\pi2\right)\cup\left(\frac\pi2,\pi\right]$, and it is undefined if $\theta\in\frac\pi2$. So, your integral is actually an improper integral and it is equal to\begin{align}\lim_{\alpha\to\frac\pi2^-}\int_0^\alpha\frac{\cos\theta}{\cos\theta}\,\mathrm d\theta+\lim_{\beta\to\frac\pi2^+}\int_\beta^\pi\frac{\cos\theta}{\cos\theta}\,\mathrm d\theta&=\lim_{\alpha\to\frac\pi2^-}\int_0^\alpha1\,\mathrm d\theta+\lim_{\beta\to\frac\pi2^+}\int_\beta^\pi1\,\mathrm d\theta\\&=\int_0^{\pi/2}1\,\mathrm d\theta+\int_{\pi/2}^\pi1\,\mathrm d\theta\\&=\int_0^\pi1\,\mathrm d\theta.\end{align}
A: For any bounded function $f$, if $f$ has a discontinuity, then it is still Riemann integrable. The "intuitive" reason is that the "rectangle" there would account for $0$% of the total area, thus it can be neglected.
There is a stronger result: a bounded function $f$ is Riemann integrable if and only if the set of discontinuities has measure $0$.
A: On the interval $[0,\pi],$ the function $\displaystyle\frac{\cos \theta}{\cos \theta}$ is identically equal to $1$ except at $x=\displaystyle\frac\pi2,$ where it is undefined. Therefore, strictly speaking, $$\int_0^{\pi} \frac{\cos \theta}{\cos \theta} \ \text{d}\theta$$ does not exist.
If we change the integrand by introducing the point $\displaystyle\left(\frac\pi2,v\right),$ where $v$ is any real number, into its definition, then it becomes bounded with countably many discontinuities (in fact, with just at most one discontinuity), and thus Riemann-integrable, on $[0,\pi].$ In fact, the integral becomes equal to $\int_0^{\pi} 1\, \ \text{d}\theta,$ whose value is straightforward to compute.
