In many problems we can check our solution by "solving the problem backwards". E.g. we can plug the solutions of an equation into the equation to get identities, or differentiate the antiderivative of a function we (indefinitely) integrated to get the original function.
But if we've calculated a definite integral, we generally only get a number, which we can't plug anywhere to check that it's the correct result.
Is there any generally applicable way of checking whether the result we got from definite integration is correct?
Some simple sanity checks off the top of my head:
- If the function you integrated was positive, did you get a positive answer?
- More generally, can you write down a bound (an easy one is that $\int_a^b f(x) \, dx$ is between $(b - a) \text{max}_{x \in [a, b]} |f(x)|$ and $(b - a) \text{min}_{x \in [a, b]} -|f(x)|$) and check that your answer satisfies it?
- Can you do the integral a completely different way and get the same answer? (This is a general-purpose way to check your answer to a problem.)
- As in Landuros' comment, can you solve the indefinite integral, then differentiate it?
Another general but less simple strategy that comes to mind is to see if whatever method you used to compute the integral can also compute the integral with an additional parameter in the integrand; then you can check whether the answer makes sense as a function of the parameter, or at least whether your method is handling the parameter sensibly.
Here's a simple example. We have the result
$$\int_{-\infty}^{\infty} \frac{1}{1 + x^2} \, dx = \pi$$
which can be obtained by knowing that the antiderivative of $\frac{1}{1 + x^2}$ is $\arctan x$, but let's pretend for a moment that we don't know that, since it can also be obtained by contour integration. What sanity checks can we do?
For starters, the integrand is positive and so is the answer, so that's good. We can also upper bound the integrand $\frac{1}{1 + x^2}$ crudely by $1$ on $[-1, 1]$ and $\frac{1}{x^2}$ elsewhere, giving the upper bound
$$\int_{-\infty}^{-1} \frac{dx}{x^2} + 2 + \int_1^{\infty} \frac{dx}{x^2} = 4$$
which is bigger than $\pi$, so that's good. Similarly, we can lower bound the integrand by $\frac{1}{2}$ on $[-1, 1]$ and $\frac{1}{2x^2}$ elsewhere, giving exactly half the above lower bound, or $2$, which is less than $\pi$, so that's also good; this is already enough to confirm that we're not off by a factor of $2$, which is reasonably common in integrals whose answer involves $\pi$.
More interestingly, the contour integral argument generalizes to give
$$\int_{-\infty}^{\infty} \frac{1}{1 + tx^2} \, dx = \frac{\pi}{\sqrt{t}}$$
(which we can also get by substituting $x \mapsto \sqrt{t} x$, but again pretend for a minute not to have noticed this), and we can ask ourselves if the two sides behave the same way as a function of $t$. Well, on the LHS bigger values of $t$ make the integrand decay faster, so the integral should be a decreasing function of $t$, which is the case on the RHS. Moreover the integral should go to $0$ as $t \to \infty$ and should go to $\infty$ as $t \to 0$, which is also the case on the RHS. You can try to adapt the crude upper and lower bounds from above to this case as well, and they'll continue to match. This is not a check that the numerical answer is right, but it's a check that the way you're using the contour integration method is giving answers that behave sensibly.
A more complicated example is the Gaussian integral
$$\int_{-\infty}^{\infty} e^{-x^2} \, dx = \sqrt{\pi}.$$
since here the indefinite integral is unavailable so we have to do something else. Again we have a positive integrand and a positive answer, so that's good. We can bound $e^{-x^2}$ by $1$ on $[-1, 1]$ and by $|x| e^{-x^2}$ elsewhere (chosen because $xe^{-x^2}$ has antiderivative $-\frac{1}{2} e^{-x^2}$), giving the upper bound
$$2 + 2 \int_1^{\infty} xe^{-x^2} \, dx = 2 + e^{-1} \approx 2.37$$
which is bigger than $\sqrt{\pi} \approx 1.77$, so that's good. This is enough to verify that we're not off by a factor of $2$, and also it's just barely enough to verify that we're not off by a factor of $\sqrt{2}$, since we have $\sqrt{2 \pi} \approx 2.51$.
Now, one way to compute the Gaussian integral is famously to compute its square, namely
$$\int_{\mathbb{R}^2} e^{-x^2 - y^2} \, dx \, dy = \pi$$
using polar coordinates. We can sanity check this method by checking that it continues to give sensible answers in higher dimensions, namely it should give
$$\int_{\mathbb{R}^n} e^{-x_1^2 - \dots - x_n^2} \,dx_1 \dots \, dx_n = \pi^{n/2}.$$
We'll compute this integral in spherical coordinates by integrating over all spheres of radius $r$ for all $r \ge 0$; this gives that the integral becomes
$$\int_0^{\infty} S_{n-1}(r) e^{-r^2} \, dr$$
where $S_{n-1}(r)$ is the "hypersurface area" of an $(n-1)$-sphere of radius $r$. This integral is easiest to compute when $n = 2$ where $S_1(r) = 2 \pi r$ and we have an elementary antiderivative available, which gives $\pi$ as expected. In general $S_{n-1}(r) = r^{n-1} S_{n-1}(1)$ and so the identity we want to check is that
$$\boxed{ S_{n-1}(1) \int_0^{\infty} r^{n-1} e^{-r^2} \, dr = \pi^{n/2} }.$$
Depending on which quantity is more mysterious to you, you can think of this as either a formula for the surface area $S_{n-1}(1)$ of an $(n-1)$-sphere of radius $1$, or a formula for the integral $\int_0^{\infty} r^{n-1} e^{-r^2} \, dr$. Both of these quantities are slightly mysterious, but in any case formulas for both are known and you can verify that they multiply to $\pi^{n/2}$, so at least all of the slightly mysterious things behave consistently with each other.
For starters, when $n = 3$ we have $S_2(1) = 4 \pi$, so the identity to check is that
$$4 \pi \int_0^{\infty} r^2 e^{-r^2} \, dr = \pi^{3/2}.$$
You can check this by using a change of coordinates as above to compute that
$$\int_0^{\infty} e^{-tr^2} \, dr = \frac{\sqrt{\pi}}{2} t^{-1/2}$$
and then differentiating both sides with respect to $t$ to get
$$\int_0^{\infty} r^2 e^{-tr^2} \, dr = \frac{\sqrt{\pi}}{4} t^{-3/2}$$
then substituting $t = 1$ to get $4 \pi \left( \frac{\sqrt{\pi}}{4} \right) = \pi^{3/2}$. So everything checks out. Of course, at this point you're checking integrals by evaluating other integrals and if you're worried about making mistakes while integrating you might worry that your original answer is correct but that your checks are wrong... so keep it simple if you can. (For example, I had accidentally written $t^{1/2}$ instead of $t^{-1/2}$ in the second to last equation, and got confused because I was missing a minus sign, then did the sanity check to see if $t^{1/2}$ had the right qualitative behavior as a function of $t$; of course it didn't and I found my mistake!)