When does linearity of definite Riemann integrals hold? My Calculus text book says if functions $f$ and $g$ are continuous on a closed interval $[a,b]$, then
$$
\int_a^b (f(x)+g(x)) \, dx=\int_a^b f(x) \, dx+\int_a^b g(x) \, dx
$$
where the integrals are in the Riemann sense.
However, there are many important applications for functions with discontinuities.
Does this identity also apply in all cases where all three integrals exist? If not what other constraints are needed to include functions with discontinuities?
*** Update ***
I think I have an example where excluding discontinuities is relevant.
$
\int_0^{\infty } \left(\sin (x) \cos \left(\frac{1}{x}\right)-\sin (x)\right) \, dx
$ is well defined but
$
\int_0^{\infty } \sin (x) \cos \left(\frac{1}{x}\right) \, dx-\int_0^{\infty } \sin (x) \, dx
$ involves two integrals that don't exist. It seems the sufficient conditions used in my text book are not met in this example because sin(x) is not continuous at $\infty$.
 A: The correct theorem in the setting of Riemann integration is the following:

If $f,g:[a,b]\to\Bbb{R}$ are Riemann-integrable over $[a,b]$, then $f+g$ is also Riemann-integrable over $[a,b]$, and in this case we have
\begin{align}
\int_a^b(f+g)&= \int_a^bf+\int_a^bg.
\end{align}

A proof should be available in any good textbook (for example it's in Spivak's Calculus book). Of course, continuous functions are Riemann-integrable so you can apply this result to continuous functions. There are of course also many Riemann-integrable functions which are not continuous; the thereom holds for these functions as well. As you can see from the theorem statement, there is no mention of continuity at all!
A: For the equation
$$
\int_a^b (f(x)+g(x)) \, dx=\int_a^b f(x) \, dx+\int_a^b g(x) \, dx
\tag1$$
we can say: if any two of the integrals exist, then so does the third, and $(1)$ holds.  This works for Riemann integral, and also for improper Riemann integral.
A: The result is almost immediate using the characterization with step functions $\mathcal S$ (you do not have to care about the countability of discontinuities or stuff like that, it is hidden in the fact that you consider input functions $f,g$ as Riemann integrable).
The Riemann integral $I()$ is linear for step functions since a sum of two step functions is a step function and it is possible to take a common subdivision which agrees with the subdivision of each one taken separately.
Therefore if $f,g$ are Riemann integrable you can find $(f_n,g_n,F_n,G_n)\in\mathcal S^4$ such that:
$\begin{cases} f_n\le f\le F_n &\quad I(F_n-f_n)\to 0&\quad I(f)=\lim\limits_{n\to\infty}I(F_n)=\lim\limits_{n\to\infty}I(f_n)\\ g_n\le g\le G_n &\quad  I(G_n-g_n)\to 0 &\quad I(g)=\lim\limits_{n\to\infty}I(G_n)=\lim\limits_{n\to\infty}I(g_n)\end{cases}$
Now we have $\quad\overbrace{(f_n+g_n)}^{\in\mathcal S}\le (f+g)\le \overbrace{(F_n+G_n)}^{\in\mathcal S}\quad$ and
$I((F_n+G_n)-(f_n+g_n))=I((\overbrace{F_n-f_n}^{\in\mathcal S})+(\overbrace{G_n-g_n}^{\in\mathcal S}))=\overbrace{I(F_n-f_n)}^{\to 0}+\overbrace{I(G_n-g_n)}^{\to 0}\to 0$
This means $f+g$ is Riemann integrable and (or similarly with $f_n,g_n$) :
$I(f+g)=\lim\limits_{n\to\infty}I(F_n+G_n)=\lim\limits_{n\to\infty}I(F_n)+\lim\limits_{n\to\infty}I(G_n)=I(f)+I(g)$
The multiplication by a scalar works in a similar fashion.
A: If we integrate via Lebesgue, then the same equality holds for discontinous functions, provided $f$ and $g$ are discontinous only on a dense numerable subsetset of their domain. To be fair, the condition of being integrable doesn't depend on continuity: there exists non continous functions which are integrable. As an example you can take the floor function, which is clearly integrable but it has discontinuities on every number in $\mathbb{Z}$, which is not dense in $\mathbb{R}$.
