There are three different questions which are often confused:
1) when does a function have an antiderivative?
2) when does a function have a definite integral?
3) when does a function have an antiderivative which is of the same "type" as the original function?
We will restrict attention to bounded functions on finite intervals.
In general a function with a definite integral also has an indefinite integral, and that indefinite integral is an antiderivative, but there is no guarantee the antiderivative will be as simple or elementary as the original function.
E.g. the answer is yes to both questions 1 and 2, when f is continuous. Question 3 is harder, and there are many familiar continuous functions f such that the antiderivative F given by the indefinite integral of f, is not at all familiar. The point is that even when F(x) exists with F’(x) = f(x), the function F is usually more exotic than f was. The basic example is that the indefinite integral of the rational function 1/(1+x), say on [0,1], is the exotic (non rational) function ln(1+x).
If we choose more complicated continuous functions, like e^(x^2), then the theorems above guarantee that the definite and indefinite integrals exist, and that the indefinite integral F(x) is an antiderivative of e^(x^2). But there is no guarantee that F can be expressed in terms of the familiar exponential, trig, and polynomial functions, and indeed it cannot. F is so exotic, it is an essentially “new” function, in the sense that we have not met with it in precalculus. But since e^(x^2) has a power series, it is not hard to write F down also as a power series. So the antiderivative certainly exists, but it is a function that most precalculus students have not run across. The answers to 1) and 2) also depend on what definition of the integral we use, but essentially whenever the answer to 2) is yes, then so is the answer to 1).
Recall a “step function” on [a,b] is a function g such that for some subdivision a = a0 < a1 < a2 < ...< an-1 < an = b, the function g has a constant value ci on each open subinterval (ai-1,ai). Everyone agrees that the integral of such a step function is c1(a1-a0) + a2(c2-c1) +...+cn(an-an-1). I.e. the graph of a step function is the border of a finite collection of rectangles, and the integral is the sum of the signed areas of those rectangles.
In beginning calculus we usually define f to have a definite (Riemann) integral if for every positive number e>0, we can find two “step functions” g,h (for the same subdivision) such that g ≤ f ≤ h and the integral of the step function (h-g) is less than e. This means we can fit rectangles above and below the graph of f such that the area between the rectangles is as small as you ask.
The usual theorem proved (or left to the appendix) says that if f is continuous on [a,b], then the Riemann integral of f exists on [a,b]. It follows that it also exists on every subinterval [a,x], for a < x < b. If F(x) is the integral of f over [a,x], we call F the indefinite integral of f. If f is continuous, then at every x in [a,b], F has a derivative at x and F’(x) = f(x).
Riemann proved that not only continuous functions f have integrals, but also all bounded functions f which are continuous “almost everywhere” or “continuous a.e.” have (Riemann) integrals. A function is continuous almost everywhere if, for every e>0, the set of discontinuities of f can be covered by a sequence of open intervals of total length < e. So the answer to 2) is also yes for f which are continuous a.e. (f is always assumed bounded).
If f is continuous a.e. then f has a definite integral and thus also an indefinite integral F(x), and we expect the indefinite integral to be an antiderivative of f. This is true almost everywhere, I.e. F is differentiable with F’(x) = f(x) at every x where f is continuous, i.e. almost everywhere. Of course there is still no guarantee that F is at all a familiar function, even though f is a familiar function. One thing we can say is that the indefinite integral F is continuous, and even Lipschitz continuous, i.e. for some constant B we have |F(x)-F(y)| ≤ B|x-y| for all x,y in [a,b].
Now we broaden our definition of an antiderivative of f to be any Lipschitz function F which is differentiable a.e., and with derivative equal to f a.e. Then anytime question 2) has answer yes in the sense of Riemann integration then also question 1) has answer yes in the new broader sense.
As to question 3), basically there is no hope of enhancing our precalculus course by teaching more and more types of more and more exotic functions so that we will know the antiderivatives of all known function. No matter how many classes of specific functions we learn, there will always be antiderivatives of these functions which we have never seen before, and which cannot be expressed in terms of ones we have seen. I.e. I am not an expert here, but it seems that although most elementary collections of specific functions are “closed” under differentiation, they tend not to be closed under antidifferentiation. (Check out some articles on “integration in elementary terms” for more details.)
Now one can define the integral of a much larger (abstract) class of bounded functions so that questions 2) and also 1), have answer yes, by changing slightly the definition of the integral. Instead of considering only functions f which can be approximated from above and below by step functions, as in Riemann’s integral, consider any bounded function f on [a,b] which is a pointwise limit a.e. of a bounded sequence of step functions. We just remove the requirement that the step functions have to come at f from above and below, and we let them approach from any direction. Then one can prove the limit of the integrals of these step functions always converges to the same limit, independent of the choice of the approximating sequence of step functions, and we can define that limit to be the (Lebesgue) integral of f.
Then for a bounded function f on [a,b] which is the pointwise limit a.e. of a bounded sequence of step functions, f has both a definite integral, and indefinite integral F, and again F is a Lipschitz function which has a derivative a.e. and whose derivative equals f a.e. on [a,b].
Conversely, any Lipschitz function F at all on [a,b] is differentiable a.e. on [a,b], and if we define f(x) = F’(x) at such x, and set f(x) = 0 elsewhere, then f has a Lebesgue integral on [a,b] which equals F(b)-F(a).
I hope this is correct, as this subject is one of the hardest for me.
Considering the examples in the previous post, if f is the characteristic function of the rationals, with value 1 at each rational, and value zero at each non rational, then f is the pointwise limit of the constant sequence of identically zero step functions, except at the rationals, i.e. almost everywhere. Hence the Lebesgue integral is zero. Hence the indefinite integral is also zero, with derivative equal to f at every irrational, i.e. almost everywhere. The same facts hold for the second, more interesting Dirichlet function, where either the Riemann or the Lebesgue integral gives the same result.