*2018 April 26*

In this blog post, as I did in the precursor to this post, I will explore some more methods of evaluating a few recreational definite integrals without finding the antiderivatives of their integrands. The methods that I employ to solve these problems are, more or less, elementary, relying heavily on functional equations and basic properties of the integral rather than advanced techniques. shall begin with a list of problems that I will solve over the course of the post, so that the reader can try them first:

Evaluate the following integral expressions:

\[\int_{-\pi/2}^{\pi/2} \frac{\cos(x)}{e^{\sin(\sin(x))}+1}dx\]

\[\int_{-\infty}^{\infty} \frac{e^{-x^2}}{e^{x^3}+1}dx\]

\[\int_0^1 \big(2^{x^2}+\sqrt{\log_2(x+1)}\big)dx\]

\[\int_e^{e^2}e^{1/\ln(x)}dx-\int_{\sqrt e}^{e}e^{1/\ln(x)}dx\]

\[\int_0^{\pi/2}\int_0^{\pi/2} \cos(x)\cos(\cos(x)\cos(y))dxdy\]

\[\int_0^{2\pi} e^{\cos(x)}\cos(\sin(x))dx\]

In reality, I will reveal very few distinct tricks in this post, but I will use each trick many times and generalize each as much as possible.

I will evaluate the integrals mostly in the order than I proposed them, beginning with the first one:

\[\int_{-\pi/2}^{\pi/2} \frac{\cos(x)}{e^{\sin(\sin(x))}+1}dx\]

Using a simple substitution \(x\to -x\), we can see that this integral is equal to

\[\begin{align}
\int_{-\pi/2}^{\pi/2} \frac{\cos(x)}{e^{\sin(\sin(x))}+1}dx
&= \int_{\pi/2}^{-\pi/2} \frac{\cos(-x)}{e^{\sin(\sin(-x))}+1}\cdot -dx\\
&= \int_{-\pi/2}^{\pi/2} \frac{\cos(x)}{e^{-\sin(\sin(x))}+1}dx\\
&= \int_{-\pi/2}^{\pi/2} \frac{\cos(x)e^{\sin(\sin(x))}}{e^{\sin(\sin(x))}+1}dx\\
\end{align}\]

If we let \(I\) be equal to the value of this integral, we can see that

\[\begin{align}
2I
&= I+I\\
&= \int_{-\pi/2}^{\pi/2} \frac{\cos(x)}{e^{\sin(\sin(x))}+1}dx+\int_{-\pi/2}^{\pi/2} \frac{\cos(x)e^{\sin(\sin(x))}}{e^{\sin(\sin(x))}+1}dx\\
&= \int_{-\pi/2}^{\pi/2} \bigg(\frac{\cos(x)}{e^{\sin(\sin(x))}+1}+\frac{\cos(x)e^{\sin(\sin(x))}}{e^{\sin(\sin(x))}+1}\bigg)dx\\
&= \int_{-\pi/2}^{\pi/2} \bigg(\frac{\cos(x)(e^{\sin(\sin(x))}+1)}{e^{\sin(\sin(x))}+1}\bigg)\\
&= \int_{-\pi/2}^{\pi/2} \cos(x)\\
&= 2\\
\end{align}\]

Thus, we have \(I=1\), and we have evaluated our first integral:

\[\bbox[lightgray,5px]{\int_{-\pi/2}^{\pi/2} \frac{\cos(x)}{e^{\sin(\sin(x))}+1}dx=1}\]

What a strange creature! Only in one’s wildest dreams might the integrand have an elementary antiderivative, and yet we somehow managed to evaluate this definite integral. What allowed us to do this?

First of all, notice that when we made the seemingly innocent substitution \(x\to -x\) at the beginning, the endpoints of the integral, \(-\pi/2\) and \(\pi/2\), were unchanged, since they are opposites of each other. They switched places upon making the substitution, but we were able to switch them back since the change from \(dx\) to \(-dx\) lent us a sign change that allowed us the change the direction of the integral, switching the endpoints back to how they originally were. The evenness of the cosine function left \(\cos(x)\) unchanged as \(x\) changed to \(-x\), creating a similarity between the integrals before and after the substitution.

Now for the interesting part. When we changed \(x\) to \(-x\), the function

\[\frac{1}{e^{\sin(\sin(x))}+1}\]

changed to

\[\frac{e^{\sin(\sin(x))}}{e^{\sin(\sin(x))}+1}\]

Thus, this function (let’s call it \(f\)) has the cool property

\[f(x)+f(-x)=1\]

Notice that any function in the form

\[f(x)=\frac{1}{e^{O(x)}+1}\]

has this property, as long as \(O(x)\) is an odd function. In this case, the odd function used was \(\sin(\sin(x))\). While this weird (or “odd”) function served to make the integral seem much more complicated than it actually was, it really changed nothing about the method of evaluating the integral.

Having properly analyzed the integral, we are now ready to generalize. Consider now the integral

\[\int_{-a}^a \frac{E(x)}{e^{O(x)}+1}dx\]

where \(a\) is a constant, \(E\) is an even function, and \(O\) is an odd function. By making the same substitution as last time, this integral is equal to

\[\int_{-a}^a \frac{E(x)e^{O(x)}}{e^{O(x)}+1}dx\]

and if we let \(I\) be the value of the integral, we have

\[\begin{align}
2I
&= I+I\\
&= \int_{-a}^a \frac{E(x)}{e^{O(x)}+1}dx+\int_{-a}^a \frac{E(x)e^{O(x)}}{e^{O(x)}+1}dx\\
&= \int_{-a}^a \frac{E(x)(e^{O(x)}+1)}{e^{O(x)}+1}dx\\
&= \int_{-a}^a E(x)dx\\
&= 2\int_{0}^a E(x)dx\\
\end{align}\]

and so we have the wonderful result

\[\bbox[lightgray,5px]{\int_{-a}^a \frac{E(x)}{e^{O(x)}+1}dx=\int_{0}^a E(x)}\]

Now we can consider the next integral:

\[\int_{-\infty}^{\infty} \frac{e^{-x^2}}{e^{x^3}+1}dx\]

Immediately, the reader should recognize this as a special case of the result that we have just derived, with \(a=\infty\), \(E(x)=e^{-x^2}\), and \(O(x)=x^3\). Using the formula previously obtained, we have

\[\int_{-\infty}^{\infty} \frac{e^{-x^2}}{e^{x^3}+1}dx=\int_0^\infty e^{-x^2}dx=\frac{\sqrt{\pi}}{2}\]

Finally, we have

\[\bbox[lightgray,5px]{\int_{-\infty}^{\infty} \frac{e^{-x^2}}{e^{x^3}+1}dx=\frac{\sqrt{\pi}}{2}}\]

Did you see the Gaussian Integral show up in that derivation? If you don’t know what I’m talking about, you should go back to the precursor to this post whose link I offered at the beginning of this post. In that post, I derive the “Gaussian Integral.”

For the next two integrals, I will use the concept of an *inverse function* to evaluate them. First, consider

\[\int_0^1 \big(2^{x^2}+\sqrt{\log_2(x+1)}\big)dx\]

As surprising as it may seem, there is actually a way to evaluate this integral using the geometric interpretation of an integral as area. Let us begin by splitting this integral up as follows:

\[\int_0^1 (2^{x^2}-1)dx+\int_0^1 \sqrt{\log_2(x+1)}dx+1\]

This may seem strange, but it will make sense momentarily. Consider the graph of \(y=2^{x^2}-1\):

The first integral into which I split the original problem can be interpreted as the area underneath this curve:

Get ready, here comes the trick. Recall that the graph of the inverse function of a function can be found by reflecting the original graph about the line \(y=x\). Thus, the area found by integrating the inverse of a function is the area between the *y-axis* and the function, where the limits of the integral refer to \(y\) values rather than \(x\) values. Since the values of \(2^{x^2}-1\) are \(0\) and \(1\) at \(x=0\) and \(x=1\) (that is, the function has fixed points at \(x=0\) and \(x=1\)), and since \(\sqrt{\log_2(x+1)}\) is its inverse, the second integral can be interpreted as the following area:

The sum of these two integrals gives the sum of the orange area and purple area, or the area formed by combining them:

…but this is just a square with side length \(1\), and its area is clearly \(1\)! Thus, the sum of the first two integrals is \(1\), and the whole expression into which we divided our original integral is equal to \(2\). Thus, we have

\[\bbox[lightgray,5px]{\int_0^1 \big(2^{x^2}+\sqrt{\log_2(x+1)}\big)dx=2}\]

Let’s generalize this little trick. Suppose that \(f\) is a bijective function with fixed points \(a,b\) such that \(f(a)=a\) and \(f(b)=b\), with \(a\lt b\). Then consider the integral

\[\int_a^b (f(x)+f^{-1}(x))dx\]

Since the graph of \(y=f^{-1}(x)\) is the reflection of the graph of \(y=f(x)\) about the line \(y=x\), we will always be able to put together the areas under \(y=f(x)\) and \(y=f^{-1}(x)\) like two puzzle pieces to obtain some rectangles whose areas we can easily find. In general, this area will always be given by

\[2a(b-a)+(b-a)^2\]

which can be simplified to \(b^2-a^2\). Thus, we have

\[\bbox[lightgray,5px]{\int_a^b (f(x)+f^{-1}(x))dx=b^2-a^2}\]

Now we can move on to the next problem, which is a multi-integral expression:

\[\int_e^{e^2}e^{1/\ln(x)}dx-\int_{\sqrt e}^{e}e^{1/\ln(x)}dx\]

Again, notice that \(f(x)=e^{1/\ln(x)}\) is a function that one could never hope to antidifferentiate. Let’s graph the integrand just like we did last time, since that seemed to help. Using the special values \(f(e)=e\), \(f(e^2)=\sqrt e\), and \(f(\sqrt e)=e^2\), I can make a graph:

Using the interpretation of a definite integral as the area under a curve, I can display the areas represented by each of these two integrals:

The integral expression that we wish to evaluate is equal to the difference of these two areas - more specifically, the blue area minus the yellow area. Now get ready, here comes the trick. Notice that the function \(f(x)=e^{1/\ln(x)}\) is *its own inverse* (in math language, one would say that it is an **involutory** function). Because of the reflection property of inverse functions that I mentioned earlier, the graph of \(y=f(x)\) must be *symmetrical* about the line \(y=x\). If I reflect the yellow area about the line \(y=x\), its area will remain unchanged, but look what happens when I do that:

Since I’m taking a difference of the two areas, and the green area is contained in both the blue and yellow areas, it will cancel out. Thus, we only need to find the area of the blue region on this graph minus the area of the yellow region. Need I point out that they’re both rectangles, whose areas we can easily calculate? The side lengths of the blue rectangle are \(e^2-e\) and \(\sqrt e\), giving an area of \(e^{5/2}-e^{3/2}\), and the side lengths of the yellow rectangle are \(e-\sqrt e\) and \(e\), giving an area of \(e^{2}-e^{3/2}\). The difference of these two areas gives us our answer:

\[\bbox[lightgray,5px]{\int_e^{e^2}e^{1/\ln(x)}dx-\int_{\sqrt e}^{e}e^{1/\ln(x)}dx=e^2(\sqrt e -1)}\]

In general, one can prove that if \(f\) is an involutory function, then

\[\bbox[lightgray,5px]{\int_a^b f(x)dx+\int_{f(a)}^{f(b)}f(x)dx=bf(b)-af(a)}\]

I’ll omit this proof as an exercise for the reader… it’s not too difficult.

Now I’ll move on to the second-to-last integral problem (appropriately, it’s a double integral). Unfortunately, my methods for evaluating this integral is a little bit less elementary. In my derivation of the solution, I will make use of the following two identities:

\[\int_0^{\pi/2} \cos^{2n}\theta d\theta=\frac{\pi}{2}\frac{(2n-1)!!}{(2n)!!}\]

\[\int_0^{\pi/2} \cos^{2n+1}\theta d\theta=\frac{(2n)!}{(2n+1)!!}\]

…which hold for any natural number \(n\). Notice that, as I will use later, these two formulas imply that for any natural number \(n\),

\[\bigg(\int_0^{\pi/2} \cos^{n}\theta d\theta\bigg)\bigg(\int_0^{\pi/2} \cos^{n+1}\theta d\theta\bigg)=\frac{\pi}{2}\frac{1}{n+1}\]

Let us return now to the problem that I posed at the beginning:

\[\int_0^{\pi/2}\int_0^{\pi/2} \cos(x)\cos(\cos(x)\cos(y))dxdy\]

Recall that \(\cos(x)\) has a Maclaurin series centered at \(x=0\). Of course, we all know that the coefficients of this series are given by

\[\cos(x)=\sum_{n=0}^\infty \frac{(-1)^n x^{2n}}{(2n)!}\]

…but, as I will demonstrate in a moment, we don’t *need* to know the coefficients. So, for the sake of simplicity, I will instead write

\[\cos(x)=\sum_{n=0}^\infty a_n x^n\]

This series representation for \(\cos(x)\), together with the identities that I mentioned earlier, causes the whole integral to unfold before our eyes:

\[\begin{align}
\int_0^{\pi/2}\int_0^{\pi/2} \cos(x)\cos(\cos(x)\cos(y))dxdy
&= \int_0^{\pi/2}\int_0^{\pi/2} \cos(x)\sum_{n=0}^\infty a_n \cos^n(x)\cos^n(y)dxdy\\
&= \sum_{n=0}^\infty \int_0^{\pi/2}\int_0^{\pi/2} a_n \cos^{n+1}(x)\cos^n(y)dxdy\\
&= \sum_{n=0}^\infty a_n\bigg(\int_0^{\pi/2}\cos^{n+1}(x)dx\bigg)\bigg(\int_0^{\pi/2} \cos^n(y)dy\bigg)\\
&= \sum_{n=0}^\infty a_n\cdot \frac{\pi}{2}\frac{1}{n+1}\\
&= \frac{\pi}{2}\sum_{n=0}^\infty \frac{a_n}{n+1}\\
&= \frac{\pi}{2}\sum_{n=0}^\infty \int_0^1 a_n x^n dx\\
&= \frac{\pi}{2} \int_0^1 \sum_{n=0}^\infty a_n x^n dx\\
&= \frac{\pi}{2} \int_0^1 \cos(x) dx\\
&= \frac{\pi\sin(1)}{2}
\end{align}\]

Which gives us the miraculous result

\[\bbox[lightgray,5px]{\int_0^{\pi/2}\int_0^{\pi/2} \cos(x)\cos(\cos(x)\cos(y))dxdy=\frac{\pi\sin(1)}{2}}\]

Wasn’t that awesome? Its generalization is even awesomer. Suppose now that \(f(x)\) is a function with a Maclaurin series:

\[f(x)=\sum_{n=0}^\infty a_n x^n\]

If \(k\) is some arbitrary constant, then we have the following:

\[\begin{align}
\int_0^{\pi/2}\int_0^{\pi/2} \cos(x)f(k\cos(x)\cos(y))dxdy
&= \int_0^{\pi/2}\int_0^{\pi/2} \cos(x)\sum_{n=0}^\infty a_n k^n \cos^n(x)\cos^n(y)dxdy\\
&= \sum_{n=0}^\infty \int_0^{\pi/2}\int_0^{\pi/2} a_n k^n \cos^{n+1}(x)\cos^n(y)dxdy\\
&= \sum_{n=0}^\infty a_n k^n\bigg(\int_0^{\pi/2}\cos^{n+1}(x)dx\bigg)\bigg(\int_0^{\pi/2} \cos^n(y)dy\bigg)\\
&= \sum_{n=0}^\infty a_n k^n\cdot \frac{\pi}{2}\frac{1}{n+1}\\
&= \frac{\pi}{2}\sum_{n=0}^\infty \frac{a_n k^n}{n+1}\\
&= \frac{\pi}{2k}\sum_{n=0}^\infty \int_0^k a_n x^n dx\\
&= \frac{\pi}{2k} \int_0^k \sum_{n=0}^\infty a_n x^n dx\\
&= \frac{\pi}{2k} \int_0^k f(x) dx\\
\end{align}\]

Which gives us the following fantastic result:

\[\bbox[lightgray,5px]{\int_0^{\pi/2}\int_0^{\pi/2} \cos(x)f(k\cos(x)\cos(y))dxdy=\frac{\pi}{2k} \int_0^k f(x) dx}\]

Just remember that this only works if \(f\) has a Maclaurin series. As an exercise, I propose the following problem for the reader: try to find a similar formula for

\[\int_0^{\pi/2}\int_0^{\pi/2} \cos^3(x)f(k\cos(x)\cos(y))dxdy\]

or, more generally,

\[\int_0^{\pi/2}\int_0^{\pi/2} \cos^{2n+1}(x)f(k\cos(x)\cos(y))dxdy\]

for some arbitrary natural number \(n\).

Now we can move on to the final integral, whose derivation is significantly similar than the previous one. The integral is

\[\int_0^{2\pi} e^{\cos(x)}\cos(\sin(x))dx\]

To evaluate this integral, we need only recal the Maclaurin series for \(e^x\) (whose coefficients we will actually have to use this time) and a few properties of complex numbers:

\[e^x=\sum_{n=0}^\infty \frac{x^n}{n!}\]

Letting \(x=e^{i\theta}\), we have

\[e^{e^{i\theta}}=\sum_{n=0}^\infty \frac{e^{in\theta}}{n!}\]

or

\[e^{\cos\theta}(\cos(\sin(\theta))+i\sin(\sin(\theta)))=\sum_{n=0}^\infty \frac{\cos(n\theta)+i\sin(n\theta)}{n!}\]

Taking the real part of both sides, we have

\[e^{\cos\theta}\cos(\sin(\theta))=\sum_{n=0}^\infty \frac{\cos(n\theta)}{n!}\]

and by integrating both sides from \(0\) to \(2\pi\), we have

\[\int_0^{2\pi} e^{\cos\theta}\cos(\sin(\theta))d\theta=\sum_{n=0}^\infty \int_0^{2\pi} \frac{\cos(n\theta)}{n!}d\theta\]

Notice now that for any natural number \(n\gt 0\),

\[\int_0^{2\pi} \cos(nx)dx=0\]

Thus, we have

\[\int_0^{2\pi} e^{\cos\theta}\cos(\sin(\theta))d\theta=\int_0^{2\pi} \frac{\cos(0\cdot \theta)}{0!}d\theta=\int_0^{2\pi}d\theta\]

and, finally,

\[\bbox[lightgray,5px]{\int_0^{2\pi} e^{\cos\theta}\cos(\sin(\theta))d\theta=2\pi}\]

That beautiful identity concludes this blog post!

**CONTINUATION:** Soon after finishing this post, I discovered another mind-blowing trick that absolutely deserves to be part of it, so I’m going to add it to the end.

Evaluate the following integral expressions:

\[\int_0^1 \cos(x-\sqrt{1-x^2})dx\]

\[\int_0^{\pi/2} \sin(x)\cos(\cos(x)-\sin(x))dx\]

Once again, you should definitely try your hand at these problems before you read my explained solutions.

Let’s start with the first integral:

\[\int_0^1 \cos(x-\sqrt{1-x^2})dx\]

Let us set the variable \(I\) equal to the value of this integral. By using the substitution \(x\to \sqrt{1-x^2}\), we have

\[\begin{align}
I
&=\int_0^1 \cos(x-\sqrt{1-x^2})dx\\
&=\int_1^0 \cos(\sqrt{1-x^2}-\sqrt{1-(1-x^2)})\cdot -\frac{xdx}{\sqrt{1-x^2}}\\
&=\int_0^1 \cos(x-\sqrt{1-x^2})\frac{xdx}{\sqrt{1-x^2}}\\
\end{align}\]

This tells us that

\[\begin{align}
I
&=\frac{I+I}{2}\\
&=\frac{1}{2}\int_0^1 \cos(x-\sqrt{1-x^2})dx+\frac{1}{2}\int_0^1 \cos(x-\sqrt{1-x^2})\frac{xdx}{\sqrt{1-x^2}}\\
&=\frac{1}{2}\int_0^1 \cos(x-\sqrt{1-x^2})\bigg(1+\frac{x}{\sqrt{1-x^2}}\bigg)dx\\
\end{align}\]

Notice now that if we let \(u=x-\sqrt{1-x^2}\), we have

\[du=\bigg(1+\frac{x}{\sqrt{1-x^2}}\bigg)dx\]

If we make this substitution \(x-\sqrt{1-x^2}\to u\) into our integral, the endpoints at \(0\) and \(1\) will change to \(-1\) and \(1\), leaving us with

\[\frac{1}{2}\int_{-1}^1 \cos(u)du\]

…and this is trivially evaluated, giving us the mysterious result

\[\bbox[lightgray,5px]{\int_0^1 \cos(x-\sqrt{1-x^2})dx=\sin(1)}\]

Did you catch the trick? I’ll do the second integral so you have another chance to see it. Starting with

\[\int_0^{\pi/2} \sin(x)\cos(\cos(x)-\sin(x))dx\]

I’ll make the substitution \(x\to \pi/2-x\), giving me the integral

\[\int_0^{\pi/2} \cos(x)\cos(\cos(x)-\sin(x))dx\]

The original integral must be equal to the average of these two integrals, since it is equal to both. Thus, we have

\[\frac{1}{2}\int_0^{\pi/2} (\sin(x)+\cos(x))\cos(\sin(x)-\cos(x))dx\]

Making the substitution \(x\to\sin(x)-\cos(x)\), we have

\[\frac{1}{2}\int_{-1}^{1} \cos(x)dx=\cos(1)\]

and we have another interesting solution:

\[\bbox[lightgray,5px]{\int_0^1 \sin(x)\cos(\cos(x)-\sin(x))dx=\cos(1)}\]

I’ve managed to generalize the trick used for these integrals, and I’ll just give you the formula immediately and follow it with a proof. I assert that if \(E\) is an even function, \(\theta\) is an involutory function (like \(\pi/2-x\) or \(\sqrt{1-x^2}\)), \(f\) is some function, and \(a\) is an arbitrary constant, then

\[\bbox[lightgray,5px]{\int_a^{\theta(a)} E(f(x)-f(\theta(x)))f'(x)dx=\int_0^{f(\theta(a))-f(a)}E(x)dx}\]

and here is a proof, using the same method as before with the substitutions \(x\to\theta(x)\) and \(f(x)-f(\theta(x))\to x\):

\[\begin{align} I &=\int_a^{\theta(a)} E(f(x)-f(\theta(x)))f'(x)dx\\ &=-\int_a^{\theta(a)} E(f(x)-f(\theta(x)))f'(\theta(x))\theta'(x)dx\\ &=\frac{1}{2}\int_a^{\theta(a)} E(f(x)-f(\theta(x)))(f'(x)-f'(\theta(x))\theta'(x))dx\\ &=\frac{1}{2}\int_{f(a)-f(\theta(a))}^{f(\theta(a))-f(a)} E(x)dx\\ &=\int_{0}^{f(\theta(a))-f(a)} E(x)dx\\ \end{align}\]

…and this proof really *does* end my blog post (no continuations this time, I promise).