Feynman's Trick

a.k.a. Differentiation under the Integral Sign & Leibniz Integral Rule


Among a few other integral tricks and techniques, Feynman's trick was a strong reason that made me love evaluating integrals, and although the technique itself goes back to Leibniz being commonly known as the Leibniz integral rule, it was Richard Feynman who popularized it, which is why it is also referred to as Feynman's trick. Here's an excerpt from his book, Surely You're Joking, Mr. Feynman:

"One thing I never did learn was contour integration. I had learned to do integrals by various methods shown in a book that my high school physics teacher Mr. Bader had given me.

One day he told me to stay after class. "Feynman," he said, "you talk too much and you make too much noise. I know why. You're bored. So I'm going to give you a book. You go up there in the back, in the corner, and study this book, and when you know everything that's in this book, you can talk again."

So every physics class, I paid no attention to what was going on with Pascal's Law, or whatever they were doing. I was up in the back with this book: Advanced Calculus, by Woods. Bader knew I had studied Calculus for the Practical Man a little bit, so he gave me the real works -- it was for a junior or senior course in college. It had Fourier series, Bessel functions, determinants, elliptic functions -- all kinds of wonderful stuff that I didn't know anything about.

That book also showed how to differentiate parameters under the integral sign -- it's a certain operation. It turns out that's not taught very much in the universities; they don't emphasize it. But I caught on how to use that method, and I used that one damn tool again and again. So because I was self-taught using that book, I had peculiar methods of doing integrals.

The result was, when guys at MIT or Princeton had trouble doing a certain integral, it was because they couldn't do it with the standard methods they had learned in school. If it was contour integration, they would have found it; if it was a simple series expansion, they would have found it. Then I come along and try differentiating under the integral sign, and often it worked. So I got a great reputation for doing integrals, only because my box of tools was different from everybody else's, and they had tried all their tools on it before giving the problem to me."

For me, employing this trick felt like I was using cheat codes to deal with integrals. At the same time, it enabled a lot of creativity and wishful thinking, which transformed integrals into puzzles. Unfortunately, this also means that there is no clear path on how and when to use this technique. In addition, what Feynman wrote still applies today since the method isn't taught much, if at all, in universities. Therefore, the trick can seem obscure and difficult to grasp for newcomers.

In the following section, we will embark on a journey to develop some rules of thumb to have at our disposal when using Feynman's trick. These are merely some heuristics that I tend to use, so deviating from them can be perfectly acceptable. However, I hope that they can provide a path to follow when nothing obvious or intuitive occurs when someone tries to use this trick, or even better, so that they can serve as motivation for someone to start using the method.


Hello, World!


Feynman already provided a significant hint about the trick when he mentioned differentiating under the integral sign, which is also an alternative name for the technique. More explicitly, if \(f(x,t)\) and \(\frac{\partial f(x,t)}{\partial t}\) is continuous with respect to both variables over the \([a,b]\) interval, then the following holds:

\[\frac{d}{dt} \int_a^b f(x, t)dx = \int_a^b \frac{\partial f(x, t)}{\partial t}dx\]

This is nice, but not so useful by itself since it doesn't say anything about how and when to apply it. Moreover, learning is not a spectator sport and one has to get their hands dirty as there are no shortcuts to it. Take for example chess, most people could read and understand the rules in a few minutes, however, if they would go on to play a game then most likely they would get stomped by a more experienced player. This is because the other player, through practice, learned some strategies to use when playing.

Thus, with the goal to develop some strategies here as well, we will dive straight into action and approach Feynman's trick using practical examples. As a "Hello, World!" introduction, let's take a look at the following integral:

\[I=\int_0^1 \frac{x-1}{\ln x}dx\]

You are encouraged to try and evaluate the integral using basic methods, but the logarithm being in the denominator makes this integral quite stubborn to deal with. Feynman's trick aims to get rid of this issue by differentiating under the intgeral sign, with respect to a parameter, in order to obtain an integral that is easier to evaluate.

Unfortunately in the integral from above we lack a parameter, therefore the first step is to parameterise the integral, which can even mean introducing a whole function, but for this example we will simply consider:

\[I(t)=\int_0^1 \frac{x^t-1}{\ln x}dx\]

Keep in mind that our original integral is just \(I(1)\). Also, surely we could've placed a parameter in many different places, such as:

\[I(a)=\int_0^1 \frac{x-a}{\ln x}dx, \quad I(b)=\int_0^1 \frac{x-1}{b-\ln x}dx, \quad I(c)=\int_0^1 \frac{x-1}{\ln (cx)}dx\ ...\]

However, the main idea behind the trick is to obtain an integral that we can evaluate easier, after differentiating with respect to the new parameter. Let's put this in action and see what happens to \(I(t)\).

\[I'(t)=\int_0^1 \frac{\partial}{\partial t}\left(\frac{x^t-1}{\ln x}\right)dx = \int_0^1x^tdx = \frac{x^{t+1}}{t+1}\bigg|_0^1 = \frac{1}{t+1}\]

Notice how easy it was to evaluate the integral \(I'(t)=\int_0^1x^tdx\) from above, had we kept \(I(a)\), \(I(b)\) or \(I(c)\) the things wouldn't had simplified at all after differentiating, and most significantly is that we would still have the \(\ln x\) in the denominator, a thing which made the integral hard to deal with in the first place.

We can already sense that the following might be an important question in the future: How to parameterise the integral when using Feynman's Trick?

We will worry about that a bit later, for now let's finish the integral as we only found \(I'(t)\). Since we are looking to find \(I(1)\) we need to integrate \(I'(t)\) back and set \(t=1\) in order to arrive there. Here it's useful to recall that:

\[\int_a^b f'(x) dx = f(b)-f(a)\]

For us, \(f(x)\) is just \(I(t)\) in the above expression. Luckily \(I(0)=0\), and as we are looking for \(I=I(1)\) we have:

\[I= I(1)-I(0)=\int_0^1 I'(t)dt = \int_0^1 \frac{1}{1+t}dt=\ln(1+t)\bigg|_0^1 = \ln 2\]

So that is the big picture of Feynman's trick - we have an integral that is hard to evaluate in it's original form, therefore by differentiating under the integral sign we attempt to transform the integral so that it can be easier integrated, and in the end we go back to undo the differentiation step.


The parameter


As emphasized above, the main goal of the technique is to obtain an integral that is easier to evaluate after differentiating with respect to a parameter, and one issue is that it is not always obvious how to parameterise the integral. In order to make things more intuitively we will play around with the integral from below.

\[I=\int_0^1 \frac{\ln(1+x)}{1+x^2}dx\]

The most annoying thing is the logarithm, so if we get rid of it everything should be straightforward. There are a few parameter possibilities which makes sense to consider, namely:

\[I(a)=\int_0^1\frac{\ln(a+x)}{1+x^2}dx, \quad I(b) = \int_0^1 \frac{\ln(1+bx)}{1+x^2}dx\]

With the first one we are out of luck, as differentiating with respect to \(a\) gives:

\[I'(a)=\int_0^1 \frac{1}{(a+x)(1+x^2)}dx = \frac{1}{1+a^2}\int_0^1\left(\frac{1}{a+x}+\frac{a}{1+x^2}-\frac{x}{1+x^2}\right)dx\] \[=\frac{\ln(1+a)}{1+a^2}-\frac{\ln a}{1+a^2} +\frac{\pi}{4}\frac{a}{1+a^2}-\frac{\ln 2}{2}\frac{1}{1+a^2}\]

Therefore, if we would try to go back to what we're looking, which is \(I=I(1)-I(0)\), we would end up with \(I=I+\text{other stuff}\). This cancels out \(I\) and we wouldn't be able to recover it. Unfortunately, there's no magic formula that tells a priori whether placing a parameter in a specific place would succeed or fail in evaluating an integral - and sometimes we are simply unlucky.

In contrast, things work out nicely with the second choice from above.

\[I'(b)=\int_0^1\frac{x}{(1+bx)(1+x^2)}dx=\frac{1}{1+b^2}\int_0^1\left(\frac{b}{1+x^2}+\frac{x}{1+x^2}-\frac{b}{1+bx}\right)dx\] \[=\frac{\pi}{4}\frac{b}{1+b^2}+\frac{\ln 2}{2}\frac{1}{1+b^2}-\frac{\ln(1+b)}{1+b^2}\]

Again, we are looking to find \(I(1)\), and as \(I(0) = 0\), we have:

\[I=\int_0^1 I'(b)db \Rightarrow 2I=\int_0^1 \left(\frac{\pi}{4}\frac{b}{1+b^2}+\frac{\ln 2}{2}\frac{1}{1+b^2}\right)db \Rightarrow I=\frac{\pi}{8}\ln 2\]

This works, but we can do even better. Looking at the Hello, World! integral we can see that there we simplified the logarithm in the denominator while performing \(\frac{\partial}{\partial t}x^t\). This is also the first thing that I always attempt to look for when using this technique - namely, to simplify something from the integrand which is independent to the parameter when differentiating. Surely for the current integral we got rid of the logarithm, but the denominator remained intact.

In short this will be our first rule of thumb: if possible, place the parameter so that something from the integral, which is not related to the parameter, gets simplified.

In order to achieve this with our integral we would need to get rid of \(1+x^2\), and by using \(\ln x=\frac12\ln(x^2)\) we can rewrite the integral as:

\[I=\int_0^1\frac{\ln(1+x)}{1+x^2}dx=\frac12\int_0^1\frac{\ln(1+2x+x^2)}{1+x^2}dx\]

Finally, in this form it's more natural to place the parameter so that it simplifies \(1+x^2\) when differentiating with respect to \(t\), namely we can consider:

\[I(t)=\frac12\int_0^1 \frac{\ln(2x+t(1+x^2))}{1+x^2}dx\Rightarrow I'(t)=\frac12\int_0^1 \frac{1}{2x+t(1+x^2)}dx=\frac14\frac{\ln\left(\frac{1+\sqrt{1-t^2}}{t}\right)}{\sqrt{1-t^2}}\]

Like for \(I(b)\) we are looking to find \(I(1)\), however here \(I(0)\) is equal to \(\frac12\int_0^1\frac{\ln(2x)}{1+x^2}dx\) not \(0\).

\[\Rightarrow I=I(1)-I(0)+I(0)=\frac14\int_0^1\frac{\ln\left(\frac{1+\sqrt{1-t^2}}{t}\right)}{\sqrt{1-t^2}}dt+\frac12\int_0^1\frac{\ln(2x)}{1+x^2}dx\] \[\int_0^1\frac{\ln\left(\frac{1+\sqrt{1-t^2}}{t}\right)}{\sqrt{1-t^2}}dt\overset{\frac{1+\sqrt{1-t^2}}{t}=x}=-2\int_0^1 \frac{\ln x}{1+x^2}dx\Rightarrow I = \frac12\int_0^1 \frac{\ln 2}{1+x^2}dx=\frac{\pi}{8}\ln 2\]

For this specific integral we only avoided performing partial fractions so there wasn't really a big improvement by simplifying the denominator. However I want to emphasize the importance of this because it will make things come way more natural when deciding where place the parameter. Of course, in case there's not an appropiate or immediate way to achieve this, it's perfectly fine to place the parameter elsewhere too.

As mentioned previously, practicing is the best approach to get along with new techniques, therefore below are more integrals to evaluate alongside some hidden steps in case those will be needed. However, I strongly recommend to try and deal with the integrals before looking at any hints, and only check them afterwards for correctness.

\[\int_0^\frac{\pi}{2} \frac{\ln(1-\sin x)}{\sin x}dx = ?\]

Consider introducing the following parameter: \[I(t)=\int_0^\frac{\pi}{2} \frac{\ln(1-t\sin x)}{\sin x}dx \Rightarrow I'(t)= -\frac{2\arctan\left(\sqrt{\frac{1+t}{1-t}}\right)}{\sqrt{1-t^2}}\] This should lead to: \[\int_0^\frac{\pi}{2} \frac{\ln(1-\sin x)}{\sin x}dx = I(1) - I(0)=\int_0^1 I'(t) dt \overset{\sqrt{\frac{1-t}{1+t}}=x} = -\frac{3\pi^2}{8}\] But it would be even better if the integral would be parameterised as: \[I(t)=\int_0^\frac{\pi}{2} \frac{\ln(1-\sin t\sin x)}{\sin x}dx\] That is because usually when having trigonometric functions, parameterising the integral with another trigonometric function, leads to a more smoother result.

\[\int_0^1 \frac{\ln(1-x+x^2)}{x-x^2}dx = ?\]

Consider introducing the following parameter: \[I(t)=\int_0^1 \frac{\ln(1-t(x-x^2))}{x-x^2}dx\Rightarrow I'(t) = \frac{4\arctan\left(\sqrt{\frac{t}{4-t}}\right)}{\sqrt{t(4-t)}}\] This should lead to: \[I(1)=\int_0^1 \frac{\ln(1-x+x^2)}{x-x^2}dx = I(1) - I(0) = \int_0^1 I'(t)dt \overset{\sqrt{\frac{4-t}{t}}= x}= -\frac{\pi^2}{9}\]

\[\int_0^\frac{\pi}{2} \frac{\arctan(\sin x)}{\sin x}dx = ?\]

Consider introducing the following parameter: \[I(t)=\int_0^\frac{\pi}{2} \frac{\arctan(t\sin x)}{\sin x}dx\Rightarrow I'(t)=\frac{\pi}{2\sqrt{1+t^2}}\] This should lead to: \[I(1)=\int_0^\frac{\pi}{2} \frac{\arctan(t\sin x)}{\sin x}dx = I(1)-I(0) = \int_0^1 I'(t)dt = \frac{\pi}{2}\ln(1+\sqrt 2)\] It will also work if the integral is parameterised as: \[I(t)=\int_0^\frac{\pi}{2} \frac{\arctan(\tan t\sin x)}{\sin x}dx\] However, in this case the first variant is simple enough to integrate back.

\[\int_0^\infty x^2e^{-\left(4x^2+\frac{9}{x^2}\right)}dx = ?\]

Consider introducing the following parameter: \[I(t)=\int_0^\infty x^2e^{-\left(4x^2+\frac{t}{x^2}\right)}dx\Rightarrow I'(t)=-\frac{\sqrt \pi}{4} e^{-4\sqrt t}\] Where the above result follows by using Glasser's master theorem alongside the Gaussian integral. This should lead to: \[\int_0^\infty x^2e^{-\left(4x^2+\frac{9}{x^2}\right)}dx = I(9)- I(0) + I(0) = \int_0^9 I'(t) dt +\frac{\sqrt \pi}{32}=\frac{13}{32}\frac{\sqrt \pi}{e^{12}}\]

\[\int_0^1 \frac{\ln x}{1-x^2}dx = ?\]

Consider parameterising the integral as: \[I(t)=\frac12\int_0^1\frac{\ln(1-t(1-x^2))}{1-x^2}dx\Rightarrow I'(t)=\frac{\arctan\left(\sqrt{\frac{t}{1-t}}\right)}{2\sqrt{t(1-t)}}\] This should lead to: \[\int_0^1 \frac{\ln x}{1-x^2}dx = I(1)- I(0) = \int_0^1 I'(t)dt \overset{\sqrt{\frac{1-t}{t}} = x}= -\frac{\pi^2}{8}\]

\[\int_0^\infty \frac{e^{-x^2}}{1+x^2}dx = ?\]

Consider parameterising the integral as: \[I(t)=\int_0^\infty \frac{e^{-t(1+x^2)}}{1+x^2}dx\Rightarrow I'(t) = -\frac{\sqrt \pi}{2\sqrt t}e^{-t}\] This should lead to: \[\int_0^\infty \frac{e^{-x^2}}{1+x^2}dx = e\left(I(1)-I(\infty)\right) = -e\int_1^\infty I'(t)dt= \frac{\pi e}{2}\operatorname{erfc}(1)\] Where \(\operatorname{erfc}(x)\) is the complementary error function.

\[\int_0^\infty \frac{\ln\left(\frac{1-x^2+x^4}{(1-x^2)^2}\right)}{(1+x^2)^2}dx = ?\]

Since \(1-x^2+x^4=(1+x^2)^2-3x^2\), consider parameterising the integral as: \[I(t)=\int_0^\infty \frac{\ln\left(\frac{t(1+x^2)^2-3x^2}{(1-x^2)^2}\right)}{(1+x^2)^2}dx\Rightarrow I'(t)=\frac{\pi}{2\sqrt{t(4t-3)}}\] And in order to go back it should be observed that \(\frac34(1+x^2)^2-3x^2=\frac34(1-x^2)^2\). \[\int_0^\infty \frac{\ln\left(\frac{1-x^2+x^4}{(1-x^2)^2}\right)}{(1+x^2)^2}dx=I(1)- I\left(\frac34\right)+ I\left(\frac34\right)\] \[=\int_\frac34^1 I'(t)dt + \frac{\pi}{4}\ln\left(\frac{3}{4}\right) = \frac{\pi}{2}\ln\left(\frac32\right)\]


Accelerated Feynman's trick


The previous chapter emphasized to parameterise integrals so that something from the integral, which is not related to the parameter, gets simplified when differentiating (if possible). However there are times when even though we can introduce a parameter to accomplish that, it wouldn't be enough to finish the integral.

In this chapter we will look at a different way to obtain this simplification. Let's start by looking at a modified version of an integral that was previously given as an exercise.

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

With \(\int_{-\infty}^\infty \frac{e^{-x^2}}{1+x^2}dx\) it was quite direct to parameterise the integral as \(\int_{-\infty}^\infty \frac{e^{-t(1+x^2)}}{1+x^2}dx\) since it simplifies the denominator, however the similar way to do that for our integral, \(\int_{-\infty}^\infty \frac{e^{-x^2-t(1+x^4)}}{1+x^4}dx\), doesn't seem to work as it complicates things a bit too much.

There is however a way to simplify the denominator and in the same time to obtain a decent integral afterwards. Without getting into too much details I will parameterise the integral as:

\[I(t)=\int_{-\infty}^\infty \frac{e^{-x^2}}{1+x^4} e^{-tx^2}(x^2\sin t+\cos t) dx\]

This will seem obscure, but fear not as we will never use this approach again. The whole point is to simplify \(1+x^4\), and the above function was created explicitly to achieve that, as \(\frac{\partial}{\partial t}e^{-tx^2}(x^2\sin t+\cos t)\) is \(-(1+x^4)e^{-tx^2}\sin t\). Note that even though we introduced a couple other terms, those aren't disturbing.

\[I'(t)=-\sin t\int_{-\infty}^\infty e^{-x^2}e^{-tx^2}dx \overset{(1+t)x^2\to x^2}= -\frac{\sin t}{\sqrt{1+t}} \int_{-\infty}^\infty e^{-x^2}dx=-\sqrt \pi \frac{\sin t}{\sqrt{1+t}}\]

Here we are looking to find \(I=I(0)\), and we also have \(I(\infty)=0\), therefore:

\[I=-\int_0^\infty I'(t)dt=\sqrt \pi \int_0^\infty \frac{\sin t}{\sqrt{1+t}}dt\overset{\sqrt{1+t}=x}=2\sqrt \pi \int_1^\infty \sin(x^2-1)dx\] \[=2\sqrt{\pi} \cos 1 \int_1^\infty\sin(x^2)dx-2\sqrt{\pi} \sin 1 \int_1^\infty\cos(x^2)dx\] \[=\pi\cos 1\frac{1-2S\left(\sqrt{\frac{2}{\pi}}\right)}{\sqrt 2}-\pi\sin 1\frac{1-2C\left(\sqrt{\frac{2}{\pi}}\right)}{\sqrt 2}\]

Where \(S(x)\) and \(C(x)\) are the Fresnel integrals. However, the approach is important here, not the result itself.

We can avoid the parametrisation from above by directly using \(\frac{1}{1+x^4}=\int_0^\infty e^{-tx^2}\sin t \, dt\), and then switch to double integrals, or put in other words: employ the accelerated Feynman's trick (in which we skip the usual parameterisation step).

\[I=\int_{-\infty}^\infty \frac{e^{-x^2}}{1+x^4}dx = \int_{-\infty}^\infty e^{-x^2}\int_0^\infty e^{-tx^2}\sin t \, dtdx\] \[=\int_{0}^\infty \sin t\int_{-\infty}^\infty e^{-x^2}e^{-tx^2}dxdt\overset{(1+t)x^2\to x^2}=\sqrt{\pi}\int_0^\infty \frac{\sin t}{\sqrt{1+t}}dt\]

The rest goes exactly as with the previous method, as all we did here was to skip differentiation step and instead we switched to double integrals.

A natural question that arises here is how did \(\frac{1}{1+x^4}=\int_0^\infty e^{-tx^2}\sin t\, dt\) appear? Or even better, how can someone come up with similar results for other integrals? In the case from above, simply the Laplace transform of the sine function was used, however in general it's useful to have a list of such identities. There are tables of integral results that can be used - for example: Table of Integrals, Series, and Products by Gradshteyn and Ryzhik - but alternatively one can build up their own list of results which tend to appear often while evaluating other integrals.


Let's conclude this chapter by evaluating one of the most popular integrals that appears when Feynman's trick gets into the conversation.

\[I=\int_0^\infty \frac{\sin x}{x}dx\]

Since \(\int_0^\infty e^{-xt} dt = \frac{1}{x}\), we can make use of this to rewrite the integral as:

\[I=\int_0^\infty \int_0^\infty \sin x e^{-xt}dtdx = \int_0^\infty \int_0^\infty \sin x e^{-xt}dxdt=\int_0^\infty \frac{1}{1+t^2}dt =\frac{\pi}{2}\]

Alternatively, we can also consider the parameter version of this integral, \(\int_0^\infty \frac{\sin x}{x}e^{-xt}dx\), however I feel like switching to double integrals is way more intuitively.

It might be worth to highlight again that this method should be used preferable when parameterising the integral leads to nowhere. For the above integral, the natural introduction of \(\int_0^\infty \frac{\sin(tx)}{x}dx\) unfortunatelly does fail, as we obtain a divergent integral after differentiating under the integral sign.

Like in the previous chapter below are more integrals alongside some hints in order to practice with the accelerated variation of Feynman's trick. However in this case I do recommend to peek at hints faster in case nothing obvious comes to mind, and afterwards to attempt and understand why the mentioned identity can be used.

\[\int_0^\infty \sin(x^2)dx=?\]

Start by substituting \(x^2\to x\) and then switch to double integrals using: \[\int_0^\infty e^{-xt^2}dt = \frac{\sqrt \pi}{2\sqrt x}\] Where the latter result is due to the Gaussian integral. Also, this integral is one particular case of the Fresnel integral.

\[\int_0^\infty \frac{\operatorname{Li}_2(x)}{x\sqrt{1-x^2}}dx=?\]

Switch directly to double integrals by using: \[\int_0^1 \frac{\ln t}{t-\frac{1}{x}}dt = \operatorname{Li}_2(x)\]

\[\int_0^1 \frac{\arctan x\ln(1+x^2)}{x(1+x)}dx = ?\]

Switch to double integrals by using the following result: \[\int_0^x \frac{\arctan t}{1+xt}dt = \frac{\arctan x \ln(1+x^2)}{2x}\]

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

Consider switching to double integrals with: \[\frac{x}{\pi^2+x^2}=\Im\left(-\frac{1}{\pi+ix}\right)=-\Im\int_0^\infty e^{-(\pi+ix)t}dt\] It's also really useful to try and see what happens when the Laplace transform of the cosine function is used instead, or the equivalent: \[\frac{x}{\pi^2+x^2}=\Re\left(\frac{1}{i\pi+x}\right)=\Re\int_0^\infty e^{-(i\pi+x)t}dt\]

\[\int_0^\infty x\left(\operatorname{Ci}^2(x)+\operatorname{si}^2(x)\right)\operatorname{Ci}(x)dx\]

Consider switching to double integrals using: \[\operatorname{Ci}^2(x)+\operatorname{si}^2(x)=\int_0^\infty \frac{e^{-xy}\ln(1+y^2)}{y}dy\]

Above \(\operatorname{Li}_2(x)\) denotes the dilogarithm function and \(\operatorname{Ci}(x)\), \(\operatorname{si}(x)\) are the cosine and the sine integral functions, defined as:

\[\operatorname{Li}_2(x)=\sum_{n=1}^\infty \frac{x^n}{n^2},\ \operatorname{Ci}(x) = - \int_x^\infty \frac{\cos t}{t}dt,\ \operatorname{si}(x) = - \int_x^\infty \frac{\sin t}{t}dt\]

More Feynman's trick variants


We already got familiar with a popular version of Feynman's trick in the previous chapter. Similarly, now we will take a look at other interesting variants of Feynman's trick, which although might appear less often, they can still help to expand the applicability of the technique.


Differentiating under the integral sign

We will start by taking a look at a much simpler case of Feynman's trick, namely, in the situation when it would be enough to simply differentiate under the integral sign without performing that "undo" step to integrate back.

As a small note, it's true that "differentiating under the integral sign" tends to be used as an alternative name for Feynman's trick, however I prefer to keep this for the variant where only the differentiating process takes part, or as mentioned above, when there's no need to integrate back the result, and the name describes quite literally what we are doing.

Let's make this more clear by looking at the following integral:

\[I=\int_0^1 x^3 \ln^2 x \, dx \]

We are already aware from the Hello, World! integral how \(\ln x\) can be simplified, since \(\frac{\partial}{\partial t}x^a = x^a \ln x\). However, by introducing the parameter in that original form as \(x^a \ln^2 x\), we would just produce a third logarithm, so that's going in the opposite direction.

Fortunatelly, if we take a step back, we can observe that after we find the result of \(\int_0^1 x^a dx\), then differentiating it w.r.t.\(a\) would give us as many logarithms as we want. So, let's put that integral to use.

\[\mathcal J(a)=\int_0^1 x^a dx = \frac{1}{a+1}\] \[\Rightarrow \mathcal J'(a) = \int_0^1 x^a \ln x \, dx = \left(\frac{1}{a+1}\right)' = - \frac{1}{(a+1)^2}\] \[\Rightarrow \mathcal J''(a) = \int_0^1 x^a \ln^2 x \, dx = \left(- \frac{1}{(a+1)^2}\right)' = \frac{2}{(a+1)^3}\] \[\Rightarrow I= \mathcal J''(3) = \int_0^1 x^3 \ln^2 x \, dx = \frac{1}{32}\]

Of course the integral itself was quite simple this time, however the important part that should be highlighted is that not always we need to perform that "undo" step after differentiating under the integral sign - and sometimes knowing a general integral result can provide us more useful integrals by differentiating it.


Feynman's trick & indefinite integrals

Further, we will take a look at how Feynman's trick can be applied to indefinite integrals. Let's consider:

\[\int \frac{1}{\sqrt{x^3}} \exp\left({-\frac{(a-bx)^2}{2x}}\right) dx\]

In this form it makes no sense to differentiate the integral with respect to any parameter, but we can extend the integral with temporary bounds by writing:

\[\int f(x)dx = F(x) + C = F(x) - F(0) = \int_0^x f(t)dt\] \[\Rightarrow I(a,b,t)=\int_0^t\frac{1}{\sqrt{x^3}} \exp\left({-\frac{(a-bx)^2}{2x}}\right) dx\]

After this we can go on apply Feynman's trick, however, first we are going get rid of the square root via the substitution \(\frac{1}{\sqrt x}\to x\).

\[I(a,b,t)=2\int_\frac{1}{\sqrt t}^\infty \exp\left(-\frac12 \left(ax-b/x\right)^2\right)dx\]

Here, we can notice that the derivative of \(ax-\frac{b}{x}\) is \(a+\frac{b}{x^2}\) so it would be quite helpful if we had that additional term. In the same time if we differentiate the integrand with respect to \(b\) we'll produce \(a-\frac{b}{x^2}\), which is really useful as \((ax-b/x)^2\) is equal to \((ax+b/x)^2+4ab\) and the derivative of \(ax+\frac{b}{x}\) is \(a-\frac{b}{x^2}\). So let's differentiate as mentioned above:

\[\frac{\partial}{\partial b}I(a,b,t)=2\int_\frac{1}{\sqrt t}^\infty \exp\left(-\frac12 \left(ax-b/x\right)^2\right)\left(a-\frac{b}{x^2}\right)dx\] \[=2e^{2ab}\int_\frac{1}{\sqrt t}^\infty \exp\left(-\frac12 (ax+b/x)^2\right)\left(a-\frac{b}{x^2}\right)dx\] \[\overset{ax+b/x\to x}=2e^{2ab}\int_{\frac{a}{\sqrt t}+b\sqrt t}^\infty \exp{\left(-\frac{x^2}{2}\right)}dx=\sqrt{2\pi}e^{2ab}\operatorname{erfc}\left(\frac{\frac{a}{\sqrt t}+b\sqrt t}{\sqrt 2}\right)\]

Where \(\operatorname{erfc}(x)\) is the complementary error function. Now we'll go back to \(I(a,b,t)\), but we should be careful to replace the dummy variable \(b\), with something else as the \(b\) parameter does also appear in the bounds.

\[\lim_{b\to -\infty}I(a,b,t)=0\Rightarrow I(a,b,t)=\sqrt{2\pi}\int_{-\infty}^be^{2ax}\operatorname{erfc}\left(\frac{\frac{a}{\sqrt t}+x\sqrt t}{\sqrt 2}\right)dx\] \[\overset{IBP}=\frac{\sqrt{\pi}}{\sqrt 2a}e^{2ax}\operatorname{erfc}\left(\frac{\frac{a}{\sqrt t}+x\sqrt t}{\sqrt 2}\right)\bigg|_{-\infty}^b+\frac{\sqrt t}{a}\int_{-\infty}^b e^{2ax}\exp\left(-\frac{(a+xt)^2}{2t}\right)dx\] \[=\sqrt{\frac{\pi}{2}}\frac{1}{a}e^{2ab}\operatorname{erfc}\left(\frac{\frac{a}{\sqrt t}+b\sqrt t}{\sqrt 2}\right)+\frac{\sqrt t}{a}\int_{-\infty}^b \exp\left(-\frac12\left(x\sqrt{t}-\frac{a}{\sqrt{t}}\right)^2\right)dx\] \[\overset{x\sqrt t-\frac{a}{\sqrt t}\to -x}=\sqrt{\frac{\pi}{2}}\frac{1}{a}e^{2ab}\operatorname{erfc}\left(\frac{\frac{a}{\sqrt t}+b\sqrt t}{\sqrt 2}\right)+\frac{1}{a}\int^{\infty}_{\frac{a}{\sqrt t}-b\sqrt t}\exp\left(-\frac{x^2}{2}\right)dx\] \[=\sqrt{\frac{\pi}{2}}\frac{1}{a}\left(e^{2ab}\operatorname{erfc}\left(\frac{\frac{a}{\sqrt t}+b\sqrt t}{\sqrt 2}\right)+\operatorname{erfc}\left(\frac{\frac{a}{\sqrt t}-b\sqrt t}{\sqrt 2}\right)\right)\]

Or for the indefinite integral, this would lead to:

\[\small \int \frac{1}{\sqrt{x^3}} \exp\left({-\frac{(a-bx)^2}{2x}}\right) dx=\sqrt{\frac{\pi}{2}}\frac{1}{a}\left(e^{2ab}\operatorname{erfc}\left(\frac{\frac{a}{\sqrt x}+b\sqrt x}{\sqrt 2}\right)+\operatorname{erfc}\left(\frac{\frac{a}{\sqrt x}-b\sqrt x}{\sqrt 2}\right)\right)+C\]

Feynman's trick & power series

Next, we will take a look at how to combine Feynman's trick with power series. For this we are going to look at:

\[I=\int_{0}^{1}\int_{0}^{1}\frac{x\ln x\ln y}{1-xy}\frac{dxdy}{\ln(xy)}\]

We are already got familiar with what to do when there is a logarithm in the denominator as we saw that we can get rid of them by using \(\frac{d}{dt} x^t = x^t\ln x\), however here also the \(1-xy\) term appears. In order to solve this issue we'll make use of the geoemtric series, namely \(\frac{1}{1-x}=\sum_{n=0}^\infty x^n\), but we will expand into series a bit later and for now continue with the following integral:

\[I(n)=\int_{0}^{1}\int_{0}^{1}\frac{(xy)^{n-1}x\ln x\ln y}{\ln(xy)}dxdy\Rightarrow I'(n)=\int_0^1\int_0^1 (xy)^{n-1} x \ln x \ln y dxdy\] \[=\int_0^1 x^{n} \ln x \, dx \int_0^1 y^{n-1} \ln y\, dy=\frac{1}{(n+1)^2}\frac{1}{n^2}\]

Now we have to to get back to \(I(n)\):

\[I(n)=-(I(\infty)-I(n))=-\int_n^\infty \frac{1}{(x+1)^2 x^2 } dx=-\frac{1}{n}-\frac{1}{n+1}+2\ln\left(1+\frac{1}{n}\right)\]

And finally, we'll put the geometric series to use.

\[\int_0^1\int_0^1 \frac{ x\ln x\ln y}{(1-xy)\ln(xy)}dx\ dy=\sum_{n=1}^\infty \int_0^1\int_0^1 \frac{(xy)^{n-1} x\ln x\ln y}{\ln(xy)}dxdy\] \[\small =\sum_{n=1}^\infty \left(-\frac{1}{n}-\frac{1}{n+1}+2\ln\left(1+\frac{1}{n}\right)\right)=\sum_{n=1}^\infty \left(\underbrace{\frac{1}{n}-\frac{1}{n+1}}_{1}-2\left(\underbrace{\frac{1}{n}-\ln\left(1+\frac{1}{n}\right)}_{\gamma}\right)\right)\]

So the result is simply \(1-2\gamma\), where \(\gamma\) is the Euler-Mascheroni constant.


Feynman's trick & differential equations

In what's to come we are going to take a look at a combination between Feynman's trick and differential equations. Let's consider the following integral:

\[I=\int_0^\infty \frac{\cos x}{1+x^2}dx\]

We can start by parameterising the cosine function and then employ the accelerated Feynman's trick:

\[I(t)=\int_0^\infty \frac{\cos(tx)}{1+x^2}dx=\int_0^\infty \int_0^\infty \cos(tx)\sin y e^{-xy}dydx\] \[\small =\int_0^\infty \sin y \int_0^\infty \cos(tx)e^{-xy}dxdy=\int_0^\infty \frac{y\sin y}{t^2+y^2}dy\overset{y\to tx}=\int_0^\infty \frac{x\sin(tx)}{1+x^2}dx\]

We haven't made much progress above, since we simply arrived at another integral with \(x\sin(tx)\) instead of \(\cos(tx)\), thus complexity is the same. However, as \(\frac{\partial}{\partial t}\cos(tx)\) is \(x\sin(tx)\), differentiating \(I(t)\) gives us a differential equation to work with, namely:

\[I'(t)=- \int_0^\infty \frac{x\sin(tx)}{1+x^2}dx = - I(t) \Rightarrow \frac{I'(t)}{I(t)}=-1\Rightarrow I(t) = C e^{-t}\] \[I(0)=\int_0^\infty \frac{1}{1+x^2}dx=\frac{\pi}{2} \Rightarrow I(t)=\frac{\pi}{2}e^{-t}\] \[ I = I(1) \Rightarrow I = \frac{\pi}{2e}\]

As a small note for the starting step, although employing the accelerated Feynman's trick was rather obvious as to get rid of the denominator, the additional introduction of the \(t\) parameter might be weird first. However performing the same steps without this parameter gives us:

\[\int_0^\infty \frac{\cos x}{1+x^2}dx=\int_0^\infty \frac{x\sin x}{1+x^2}dx\]

Which indicates that one might put to use the fact that \(I(1)=-I'(1)\), by adding the additional \(t\) parameter.


Generalizing Feynman's trick

So far we've seen the Feynman's trick applied only when the parameter was inside the integrand, however it can also be used when the bounds are parameterised as well. More generally, the following holds:

\[\frac{d}{dt} \int_{a(t)}^{b(t)} f(x, t)dx = \frac{d}{dt}b(t)f(x,b(t))-\frac{d}{dt}a(t)f(x,a(t))+\int_{a(t)}^{b(t)} \frac{\partial f(x, t)}{\partial t}dx\]

We'll put this to use with the integral from below.

\[I=\int_\frac{1}{\sqrt 2}^1 \frac{\operatorname{arccosh}\left(\sqrt 2 x\right)}{\sqrt{1-x^2}}dx\]

Above we can see that the same \(\sqrt 2\) appears in both the lower bound and the \(\operatorname{arccosh}\) function, so we'll parameterise the integral as:

\[I(t)=\int_\frac{1}{t}^1 \frac{\operatorname{arccosh}\left(t x\right)}{\sqrt{1-x^2}}dx \Rightarrow I'(t) = \frac{1}{t^2}\frac{\cancelto{0}{\operatorname{arccosh}\left(t\frac{1}{t}\right)}}{\sqrt{1-\frac{1}{t^2}}}+\int_\frac{1}{t}^1\frac{x}{\sqrt{1-t^2x^2}\sqrt{1-x^2}}dx\] \[\overset{1-x^2\to x^2}=\frac1t\int_0^{\sqrt{1-\frac{1}{t^2}}}\frac{1}{\sqrt{1-\frac{1}{t^2}-x^2}}dx=\frac1t\arcsin\left(\frac{x}{\sqrt{1-\frac{1}{t^2}}}\right)\bigg|_0^\sqrt{1-\frac1{t^2}}=\frac{\pi}{2t}\]

We're looking to find \(I=I\left(\sqrt 2\right)\), and since \(I\left(1\right)=0\), we have:

\[I=\int_1^\sqrt 2I'(t)dt = \frac{\pi}{2} \int_1^\sqrt 2 \frac{1}{t}dt=\frac{\pi}{4}\ln 2\]

Generating integrals using Feynman's trick

Now we'll take a look at a fancier way to use Feynman's trick, especially in order to generate new integrals, for this we're considering:

\[I(t)=\int_0^\frac{\pi}{2} \arctan\left(\frac{\sin x-\tan\frac{t}{2}}{\cos x}\right)dx\]

Note that we are not trying to evaluate the above integral, instead we are simply using it in order to build up new integrals with the result that follows after differentiating w.r.t. \(t\).

\[I'(t)=-\frac12\int_0^\frac{\pi}{2}\frac{\cos x}{1-\sin t\sin x}dx=\frac12 \frac{\ln(1-\sin t)}{\sin t}\]

We also have that \(I(\pi)=-\frac{\pi^2}{4}\) and \(I(0)=\frac{\pi^2}{8}\), therefore:

\[I(\pi)-I(0)=-\frac{\pi^2}{4}-\frac{\pi^2}{8}=\frac12\int_0^\pi \frac{\ln(1-\sin x)}{\sin x}dx\] \[\Rightarrow \int_0^\pi \frac{\ln(1-\sin x)}{\sin x}dx=-\frac{3\pi^2}{4}\]

In retrospect, this integral also appeared as an exercise in the second chapter, and with the same suggestion from there, we can evaluate the integral by applying Feynman's trick to:

\[I(t)=\int_0^\pi \frac{\ln(1-\sin t\sin x)}{\sin x}dx\]

Admittedly, following this parameterisation is much more intuitevely than what we've shown with the new variation, however it's also useful to have this trick in the bag.


To keep the practice going, underneath are listed some integrals that can be evaluated with one version of Feynman's trick described in this chapter.

\[\int_1^\infty \int_1^\infty (x+y)^2 e^{-(x+y)}dxdy = ?\]

Start by showing that: \[I(t)=\int_1^\infty \int_1^\infty e^{-t(x+y)}dxdy = \left(\frac{e^{-t}}{t}\right)^2\] Then differentiate both sides two times with respect to \(t\) and set \(t=1\).

\[\int x^4\cos(nx)dx = ?\]

Differentiate four times with respect to \(n\) the following extended indefinite integral: \[ I(n,t) = \int_0^t \cos(nx) dx \]

\[\int_0^1 \int_0^1 \frac{dxdy}{(1+xy)\ln(xy)} = ?\]

Combine the geometric series \(\sum\limits_{n=0}^\infty (-1)^n x^n = \frac{1}{1+x}\) with: \[I(t)=\int_0^1 \int_0^1 \frac{(xy)^t}{\ln(xy)}dxdy\]

\[\int_0^\infty \frac{\sin^2 x}{x^2(1+x^2)}dx = ?\]

Solve the resulting differential equation after differentiating twice the following integral: \[ I(t) = \int_0^\infty \frac{\sin^2 (tx)}{x^2(1+x^2)}dx \]

\[\int_0^1 \ln x \left(\frac{1}{t+x}+\frac{1}{\frac{1}{t}+x}\right)dx = ?\]

Split the integral in two parts, then substitute \(x\to tx\) and respectively \(x\to \frac{x}{t}\) in the resulting integrals to obtain: \[I(t)= \int_0^1 \ln x \left(\frac{1}{t+x}+\frac{1}{\frac{1}{t}+x}\right)dx = \int_0^\frac{1}{t} \frac{\ln(tx)}{1+x}dx + \int_0^t \frac{\ln\left(\frac{x}{t}\right)}{1+x}dx\] Now employ the Feynman's trick (in the generalized variant).


In disguise this exercise is a reformulation of the following identity: \[ \operatorname{Li}_2(-t)+\operatorname{Li}_2\left(-\frac{1}{t}\right) = -\frac{\pi^2}{6} - \frac{1}{2}\ln^2 t \] Where \(\operatorname{Li}_2(x)\) is the dilogarithm function.

\[\int_0^\infty e^{-x^2}dx = ?\]

This integral can be generated starting from: \[I(t)=\int_0^\infty \frac{e^{-t(1+x^2)}}{1+x^2}dx\Rightarrow I'(t)=-e^{-t}\int_0^\infty e^{-tx^2} dx\overset{\sqrt t x \to x}= -\frac{e^{-t}}{\sqrt t}\int_0^\infty e^{-x^2} dx\] Afterwards it should be observed that \(I(0)=\frac{\pi}{2}\) and \(I(\infty)=0\), therefore: \[\frac{\pi}{2} = \int_0^\infty \frac{e^{-t}}{\sqrt t} dt \int_0^\infty e^{-x^2} dx \overset{t\to t^2} = 2\left(\int_0^\infty e^{-x^2}dx\right)^2 \]


Feynman's trick in practice


In this last chapter we'll dive into some "real-world" integrals and observe how Feynman's trick can be adapted for them. Additionally, we will also attempt to build up some heuristics that'll help us manipulate the integrals up to a point where we can introduce an useful parameter. This is due to the fact that with most of the previous examples we had the luxury to parameterise the integrals as they appeared, however often this might not be the case.


Breaking the rules

In the second chapter we've observed how parameterising the integral so that it also simplifies some parts of the integral can make things more intuitively. However, we can always look for better, especially when our approach doesn't seem elegant enough.

Let's see how can we break this rule with the following integral:

\[I=\int_0^1 \frac{\ln(1-x^2+x^4)}{1-x^2} dx\]

As with our first rule of thumb it's straightforward to introduce the new parameter as:

\[I(a)=\int_0^1 \frac{\ln(a(1-x^2)+x^4)}{1-x^2} dx \Rightarrow I'(a)= \int_0^1 \frac{1}{a(1-x^2)+x^4}dx\]

You are encouraged to proceed forward with the above integral, however computing \(I'(a)\) might not give the most pleasant result. So to overcome this, we'll manipulate the integral a bit before parametersing it.

One extremely useful substitution (which deserves its own special chapter) is \(x\to \frac{1-x}{1+x}\). This one is great here especially since it has the following property (among many others):

\[\int_0^1 \frac{f(x)}{1-x^2}dx \overset{x\to\frac{1-x}{1+x}}= \frac12\int_0^1 \frac{f\left(\frac{1-x}{1+x}\right)}{x}dx\] \[\Rightarrow I \overset{x\to\frac{1-x}{1+x}}= \frac12\underbrace{\int_0^1 \frac{\ln(1+14x^2+x^4)}{x}dx}_{x^2\to x} - \frac12 \int_0^1 \frac{\ln((1+x)^4)}{x}dx\] \[= \frac14\int_0^1 \frac{\ln(1+14x+x^2)}{x}dx - 2 \int_0^1 \frac{\ln(1+x)}{x}dx = \frac14 I(\operatorname{arccosh} 7) - I(0)\]

Above, although we could have introduced a simple parameter, for a smoother result we parameterised the integral as:

\[I(t)=\int_0^1 \frac{\ln(1+2\cosh t+x^2)}{x} dx \Rightarrow I'(t)= \int_0^1 \frac{2\sinh t}{1+2\cosh t+x^2}dx\] \[= \int_0^1 \frac{2\sinh t}{(x+\cosh t)^2-\sinh^2 t}dx = -2\operatorname{arctanh}\left(\frac{x+\cosh t}{\sinh t}\right)\bigg|_0^1 = t\]

Finally, to find to find \(I\) we can combine \(I(\operatorname{arccosh} 7)\) with \(I(0)\).

\[I = \frac14 \int_0^{\operatorname{arccosh 7}} t \, dt - \frac34 I(0) = \frac{\ln^2(2+\sqrt 3)}{2} - \frac{\pi^2}{8}\]

The result from above follows since includes \(I(0) = \frac{\pi^2}{6}\), which is also the Basel problem in disguise, but you're further encouraged to approach it by employing Feynman's trick.

\[\int_0^1 \frac{\ln(1+x)}{x}dx=\frac{\pi^2}{12}\]

One idea is to rewrite the integral as: \[ I=\int_0^1 \frac{\ln(1+x)}{x}dx\overset{x\to x^3}=3\int_0^1 \frac{\ln(1+x^3)}{x}dx\] \[\Rightarrow \frac13I-I=\int_0^1 \frac{\ln\left(\frac{1+x^3}{1+x}\right)}{x}dx\Rightarrow I = -\frac32 \int_0^1 \frac{\ln(1-x+x^2)}{x}dx \] Now put Feynman's trick to use for: \[I(t)=\int_0^1 \frac{\ln(1-tx+x^2)}{x}dx\] But also take into account that: \[I(0)=\int_0^1 \frac{\ln(1+x^2)}{x}dx\overset{x^2\to x}=\frac12 \int_0^1 \frac{\ln(1+x)}{x}dx=\frac12I\]


Switching to rational functions

Maybe it's just a personal preference, but for me working with rational functions tends to give a higher visibility on how to parameterise the integrals. We'll see what is meant by this when dealing with the following integral:

\[I=\int_0^\frac{\pi}{2}\ln(2+\tan^2 x)dx\]

In this form, two immediate ways to parameterise the integral are as follows:

\[I(a)=\int_0^\frac{\pi}{2}\ln(a+\tan^2 x)dx,\quad I(b)=\int_0^\frac{\pi}{2}\ln(2+b\tan^2 x)dx\]

It turns out that both variants work, but we can do better. Another rule of thumb that I follow is to use almost exclusive rational functions as they often provide the most visibility to work with. Let's do that for our integral too.

\[I=\int_0^\frac{\pi}{2}\ln(2+\tan^2 x)dx\overset{\tan x\to x}=\int_0^\infty \frac{\ln(2+x^2)}{1+x^2}dx\]

And at this point it should be obvious where to place the parameter so that we can simplify the denominator.

\[I(t)=\int_0^\infty \frac{\ln(1+t(1+x^2))}{1+x^2}dx\Rightarrow I'(t)=\int_0^\infty \frac{1}{1+t+tx^2}dx=\frac{\pi}{2}\frac{1}{\sqrt t\sqrt{1+t}}\] \[\Rightarrow I=\int_0^1 I'(t)dt=\frac{\pi}{2}\int_0^1 \frac{1}{\sqrt t\sqrt{1+t}}dx\overset{t=x^2}=\pi\int_0^1\frac{1}{\sqrt{1+x^2}}dx=\pi\ln(1+\sqrt 2)\]

Obviously, if you're already more used to trigonometric functions, hyperbolic functions or anything else, then this can be ignored. I however recommend switching to rational functions. A few exceptions being when there's a clear way to parameterise the integral directly or when at least one of the bounds is \(\infty\).


For more practice you can also attempt to tackle the following integral:

\[\int_0^\frac{\pi}{2} \ln(\sec^2 x +\tan^4 x)dx=?\]

Start by substituting \(\tan x \to x\) then employ Feynman's trick.


Cleaning up the functions

Before parameterising the integrals it's quite useful to clean the disturbing functions as much as possible before any parameterisation. Let's demonstrate this by considering:

\[I=\int_0^\frac{\pi}{2}\arctan\left(\frac{2\sin x}{2\cos x -1}\right)\frac{\sin\left(\frac{x}{2}\right)}{\sqrt{\cos x}}dx\]

As we have trigonometric functions all over the place, we will perform the Weierstrass substitution \(\tan\left(\frac{x}{2}\right)\to x\) in order to obtain only rational functions, as per the previous heuristic.

\[\Rightarrow I = 2\int_0^1 \frac{x\arctan\left(\frac{4x}{1-3x^2}\right)}{\sqrt{1-x^2}(1+x^2)}dx\]

It would be great to parameterise the integral so that we get rid of the arctangent function, but unfortunately here it is a bit overloaded, therefore we'll clean it by splitting it into two. In case it's not obvious how to do that directly, we can differentiate it, perform partial fractions and then integrate back.

\[\frac{d}{dx}\arctan\left(\frac{4x}{1-3x^2}\right)=\frac{12x^2+4}{9x^4+10x^2+1}=\frac{1}{1+x^2}+\frac{3}{1+9x^2}\] \[\Rightarrow \int \left(\frac{1}{1+x^2}+\frac{3}{1+9x^2}\right) dx = \arctan x + \arctan(3x) + C\]

However since we're integrating over the \((0,1)\) interval we have that \(x \cdot 3 x>1\) for \(x > \frac{1}{\sqrt 3}\), so we need to rewrite the integral as:

\[I=2\int_0^1 \frac{x(\arctan x + \arctan(3x))}{\sqrt{1-x^2}(1+x^2)}dx - 2 \int_\frac{1}{\sqrt 3}^1 \frac{x}{\sqrt{1-x^2}(1+x^2)}dx\] \[= 2 \mathcal J - \frac{\pi}{\sqrt 2}\ln(2+\sqrt 3)\]

At this point there's only left to evaluate the first integral, \(\mathcal J\), for which we'll employ Feynman's trick. There isn't any way to place the parameter so that we get rid of anything from the denominator so we'll simply introduce the following parameterisation:

\[\mathcal J(t)=\int_0^1 \frac{x(\arctan x + \arctan(tx))}{\sqrt{1-x^2}(1+x^2)}dx\Rightarrow \mathcal J'(t) = \int_0^1 \frac{x^2}{\sqrt{1-x^2}(1+x^2)(1+t^2 x^2)}dx\]

In general when we have rational functions it is prefered to integrate over \((0,\infty)\), if possible, as it drastically reduces the result, and when there's the derivative of \(\arcsin x\) in the denominator one way to map \((0,1)\) to \((0,\infty)\) is to directly substitute \(x \to \frac{1}{\sqrt{1+x^2}}\).

\[\Rightarrow \mathcal J=\int_0^\infty \frac{1}{(2+x^2)(1+t^2+x^2)}dx = \frac{\pi}{2(1-t^2)}\left(\frac{1}{\sqrt{1+t^2}}-\frac{1}{\sqrt 2}\right)\]

Now in order to go back to \(\mathcal J(3)\), we'll make use of \(\mathcal J(-1)=0\), so:

\[\mathcal J = \frac{\pi}{2}\int_{-1}^3 \frac{1}{(1-t^2)}\left(\frac{1}{\sqrt{1+t^2}}-\frac{1}{\sqrt 2}\right)dt\]

Finally, to finish this integral we'll subsitute \(t = \frac{1-x}{1+x}\).

\[\Rightarrow \mathcal J = \frac{\pi}{4\sqrt 2}\int_{-\frac12}^\infty \frac{1}{x}\left(\frac{1+x}{\sqrt{1+x^2}}-1\right)dx=\frac{\pi}{\sqrt 2}\ln \left(\frac{1+\sqrt 5}{2}\right)\]

As such, we can conclude that:

\[\int_0^\frac{\pi}{2}\arctan\left(\frac{2\sin x}{2\cos x -1}\right)\frac{\sin\left(\frac{x}{2}\right)}{\sqrt{\cos x}}dx=\sqrt 2 \pi \ln \left(\frac{1+\sqrt 5}{2}\right)- \frac{\pi}{\sqrt 2}\ln(2+\sqrt 3)\]

Similarly you can try and tackle the following integral:

\[\int_0^\pi \arctan\left(\frac{1+2\cos x}{\sqrt 3}\right)dx=?\]

Start by substituting \(\tan\left(\frac{x}{2}\right) \to x\), then split the arctangent function into two parts and use Feynman's trick.


Preparing better integral bounds

Another useful thing to consider before using Feynman's trick is to manipulate the bounds prior to parameterising the integral so that they get rid of any complicated functions for the differentiated integral, \(I'(t)\). This will almost always give a smoother and easier integral that we have to undo. We will show this in action with the integral from below.

\[I=\int_0^1 \frac{x^2 \ln(1-x^2)}{1+x^4}dx\]

With the previous heuristic we've already seen that it is useful to integrate over \((0,\infty)\) when there are some rational functions - therefore we will attempt to do the same with this integral. You are encouraged to try and see what kind of mess it would be produced by parameterising the integral as it is, when the bounds are \((0,1)\). However we will jump straightforward to get our bounds to \((0,\infty)\).

In order to obtain that we can notice that the integrand is even, so we can move the bounds to \((-1,1)\) and then substitute \(x\to \frac{1-x}{1+x}\) again, which is another useful way to get our bounds at \((0,\infty)\).

\[I=\frac12\int_{-1}^1 \frac{x^2\ln(1-x^2)}{1+x^4}dx\overset{x\to\frac{1-x}{1+x}}=\frac12\int_0^\infty \frac{(1-x)^2\ln\left(\frac{4x}{(1+x)^2}\right)}{1+6x^2+x^4}dx\]

Now we can split the logarithm into three parts and use that:

\[\int_0^\infty \frac{(1-x)^2}{1+6x^2+x^4}dx = \frac{\pi}{2\sqrt 2}-\frac{\ln(1+\sqrt 2)}{\sqrt 2}\] \[\int_0^\infty \frac{(1-x)^2\ln(x)}{1+6x^2+x^4}dx\overset{x\to\frac{1}{x}} = -\int_0^\infty \frac{(1-x)^2\ln(x)}{1+6x^2+x^4}dx = 0\]

Therefore our integral is:

\[I=\frac{\pi\ln 2}{2\sqrt 2}-\frac{\ln 2\ln(1+\sqrt 2)}{\sqrt 2}-\mathcal J, \quad \mathcal J = \int_0^\infty \frac{(1-x)^2\ln(1+x)}{1+6x^2+x^4}dx\]

To evaluate the emerging integral we will perform Feynman's trick. There's not an obvious way to place the parameter as to simplify the denominator, so we'll parameterise the integral as:

\[\mathcal J(a) = \int_0^\infty \frac{(1-x)^2\ln(1+ax)}{1+6x^2+x^4}dx\Rightarrow \mathcal J'(a)\int_0^\infty \frac{x(1-x)^2}{(1+ax)(1+6x^2+x^4)}dx\] \[=-\frac{(1+a)^2\ln a}{1+6a^2+a^4}-\frac{\ln(1+\sqrt 2)}{\sqrt 2}\frac{a(3-a+a^2)+1}{1+6a^2+a^4}+\frac{\pi}{2\sqrt 2}\frac{a(3+a+a^2)-1}{1+6a^2+a^4}\]

The partial fraction was ommited above, as what's really important here is that we're left only with a simple \(\ln a\) as a "disturbing" function. In contrast, if the bounds were \((0,1)\) things would have been way more complicated.

Let's finish this integral as we still have to undo the differentiating step.

\[\mathcal J(1)=\mathcal J(1)-\mathcal J(0)=\int_0^1 \mathcal J'(a)da\] \[=-\int_0^1\frac{(1+a)^2\ln a}{1+6a^2+a^4}da-\frac{\pi\ln(1+\sqrt 2)}{8\sqrt 2}-\frac{3\ln 2\ln(1+\sqrt 2)}{4\sqrt 2}-\frac{\pi^2}{16\sqrt 2}+\frac{3\pi\ln 2}{8\sqrt 2}\] \[\int_0^1\frac{(1+x)^2\ln x}{1+6x^2+x^4}dx=\int_0^1\left(\frac{1}{2\sqrt 2}\frac{(1+\sqrt 2)-x}{(1+\sqrt 2)^2+x^2}-\frac{1}{2\sqrt 2}\frac{(1-\sqrt 2)-x}{(1-\sqrt 2)^2+x^2}\right)\ln x \, dx\] \[\small =\frac{1}{8\sqrt 2}\left(\operatorname{Li}_2\left(-(1+\sqrt 2)^2\right)-\operatorname{Li}_2\left(-(1-\sqrt 2)^2\right)\right)+\frac{1}{2\sqrt 2}\left(\operatorname{Ti}_2\left(-(1+\sqrt 2)\right)-\operatorname{Ti}_2\left(-(1-\sqrt 2)\right)\right)\]

The result from above follows since:

\[\int_0^1 \frac{x\ln x}{a^2+x^2}dx\overset{x^2\to x}=\frac14\int_0^1 \frac{\ln x}{a^2+x}dx=\frac14\operatorname{Li}_2\left(-\frac{1}{a^2}\right)\] \[\int_0^1 \frac{a\ln x}{a^2+x^2}dx\overset{x\to ax}=\int_0^\frac1a\frac{\ln a +\ln x}{1+x^2}dx\overset{IBP}=-\operatorname{Ti}_2\left(\frac1a\right)\]

Where \(\operatorname{Li}_2(x)\) is the dilogarithm and \(\operatorname{Ti}_2(x)\) is the inverse tangent integral.

Finally, collecting all the results yields:

\[I=\frac{\pi^2}{16\sqrt 2}+\frac{\pi \ln 2}{8\sqrt 2}+\frac{\pi\ln(1+\sqrt 2)}{8\sqrt 2}-\frac{\ln 2\ln(1+\sqrt 2)}{4\sqrt 2}\] \[\small +\frac{1}{8\sqrt 2}\left(\operatorname{Li}_2\left(-(1+\sqrt 2)^2\right)-\operatorname{Li}_2\left(-(1-\sqrt 2)^2\right)\right)+\frac{1}{2\sqrt 2}\left(\operatorname{Ti}_2\left(-(1+\sqrt 2)\right)-\operatorname{Ti}_2\left(-(1-\sqrt 2)\right)\right)\]

With the same idea one can attempt to calculate the following integral:

\[\int_0^1 \frac{\ln^2 x\ln(1+x)}{1+x^2}dx=?\]

Map the bounds from \((0,1)\) to \((0,\infty)\) by substituting \(x\to\frac{1}{x}\) - here it is necessary to add the resulting integral with the original one - afterwards use Feynman's trick.


Multiple parameters

We mostly got familiar to apply Feynman's trick by introducing a parameter somewhere, however sometimes even multiple parameters can be used when encountering new integrals. To exemplify such a situation, let's take a look at the following unit square integral arising in geometric probability:

\[I=\int_0^1\int_0^1 \left(\frac{-\ln(xy)}{1-xy}\right)^mdxdy\]

In order to generate the \(\ln(xy)\) part it's straightforward to consider the following integral:

\[I(a)=\int_0^1\int_0^1 \frac{(xy)^a}{(1-xy)^m}dxdy\]

Differentiating with respect to \(a\), \(m\) times followed by setting \(a=0\) will gives us the desired integral, ignoring the \((-1)^m\) term. However the denominator is still troublesome, and to deal with that we will introduce one more parameter:

\[I(a,z)=\int_0^1\int_0^1 \frac{(xy)^a}{z-xy}dxdy\]

This is perfect now, as we can recover our original integral by differentiating with respect to \(a\), \(m\) times, and with respect to \(z\), \(m-1\) times, followed by setting \(a=0\) and respectively \(z=1\) - ignoring some coefficients.

One way to evaluate \(I(a,z)\) is to expand the denominator into geometric series as:

\[I(a,z)=\int_0^1\int_0^1 \frac{(xy)^a}{z-xy}dxdy=\frac{1}{z}\sum_{n=0}^\infty \int_0^1\int_0^1(xy)^a\left(\frac{xy}{z}\right)^ndxdy\] \[=\sum_{n=0}^\infty \frac{1}{z^{n+1}}\int_0^1x^{n+a}dx\int_0^1y^{n+a}dy=\sum_{n=1}^\infty \frac{1}{z^{n+2}}\frac{1}{(n+a)^2}\]

Now we will take \(m\) derivatives with respect to \(a\) and then set it to \(0\).

\[\frac{\partial^m}{\partial a^m}I(a,z) = \int_0^1\int_0^1 \frac{\ln^m(xy)}{z-xy} dxdy =(-1)^m (m+1)!\sum_{n=1}^\infty \frac{1}{z^{n+2}}\frac{1}{n^{m+2}}\]

This can be also rewriten in terms of the polylogarithm function as:

\[\int_0^1\int_0^1 \frac{(-\ln(xy))^m}{z-xy} dxdy = (m+1)!\operatorname{Li}_{m+2}\left(\frac{1}{z}\right)\]

Finally, we can arrive at our original integral by taking \(m-1\) derivatives with respect to \(z\) and setting it to \(1\).

\[(-1)^m(m-1)!\int_0^1\int_0^1 \frac{(-\ln(xy))^m}{(1-xy)^m}dxdy=(m+1)!\frac{d^{m-1}}{dz^{m-1}}\operatorname{Li}_{m+2}\left(\frac{1}{z}\right)\bigg|_{z=1}\]

Although the derivation from above was the important part since it shows the main idea on how to differentiate in order to produce the desired integral, by using \(\frac{\partial}{\partial z} \operatorname{Li}_n(z) = \frac{\operatorname{Li}_{n-1}(z)}{z}\) the result can be also written, with the help of OEIS, as:

\[\int_0^1\int_0^1 \left(\frac{-\ln(xy)}{1-xy}\right)^m dxdy =m(m+1)\sum_{k=1}^{m-1}|s(m-1,m-k)|\zeta(k+2)\]

Where \(s(n,m)\) is the Stirling number of the first kind and \(\zeta(z)\) is the Riemann zeta function.


A similar idea can be applied for the following integral:

\[\int_0^\infty \frac{\cos(3x)}{(1+x^2)^4}dx=?\]

Make use of a more general integral that was evaluated in the fourth chapter, namely: \[\int_0^\infty \frac{\cos(tx)}{a^2+x^2}dx = \frac{\pi}{2a}e^{-at}\] Then differentiate \(3\) times w.r.t. \(a\).


Cascaded Feynman's trick

Sometimes to enable an application of Feynman's trick we needed to actually apply another Feynman's trick. Let's look at the following integral:

\[I = \int_0^\frac{\pi}{2}\int_0^\frac{\pi}{2}\cot x \csc^2 y\ln(\cos y)\ln(1-2\sin x+\sin^2 x\csc^2y)dxdy\]

The first step should be pretty obvious by now, namely to get rid of the trigonometric functions.

\[I \overset{\large \sin x\to x \atop \large \cot y \to y}=-\frac12\int_0^\infty \int_0^1 \frac{\ln\left(1+\frac{1}{y^2}\right)\ln((1-x)^2+x^2y^2)}{x}dxdy\]

Now we can notice that we have two logarithms and only one of them contains the \(x\) term, however since the bounds are \((0,1)\) dealing with that integral won't produce much success (as the result would be quite complicated).

However we also have the bounds as \((0,\infty)\) for the \(y\) integral, and it would be even better if we could have a single logarithm. To further obtain such a favorable integral form, we can use the following result:

\[\int_0^1 \frac{t}{t^2+y^2}dt=\frac12\ln\left(1+\frac{1}{y^2}\right)\] \[\Rightarrow I=-\int_0^\infty \int_0^1 \int_0^1 \frac{t\ln((1-x)^2+x^2y^2)}{x(t^2+y^2)}dtdxdy \] \[\overset{y\to ty}=-\int_0^1 \frac{1}{x}\int_0^1 \int_0^\infty \frac{\ln((1-x)^2+x^2t^2y^2)}{1+y^2} dydtdx\]

In the third chapter we saw how it's useful to have a list of integral results. One more such useful integral that tend to appear quite often is:

\[\int_0^\infty \frac{\ln(a^2+b^2 x^2)}{1+x^2}dx= \pi \ln(|a|+|b|)\]

You can differentiate either \(I(a)\) or \(I(b)\), and even directly employ the accelerated Feynman's trick by writing the logarithm as an integral.


Now back to our integral, by using the above result, we can easily finish the integral.

\[I=-\pi\int_0^1 \frac{1}{x}\int_0^1 \ln((1-x)+xt)dtdx\] \[=\pi\underbrace{\int_0^1 \left(\frac1x+\frac{\ln(1-x)}{x^2}\right)dx}_{\large -1}-\pi\underbrace{\int_0^1\frac{\ln(1-x)}{x}dx}_{\large -\frac{\pi^2}{6}}=\frac{\pi^3}{6}-\pi\]

Although this marks the conclusion of the essay, this isn't a static website, and I might update it when I encounter new interesting integrals that are worth to be shown. So far, the integrals comes from my posts on Mathematics Stack Exchange, combined with some of the most popular integrals - thus you can also check them directly there.

For further exercises, I can recommend you to explore math forums and magazines such as Art of Problem Solving, Mathematics Stack Exchange, The American Mathematical Monthly, Crux Mathematicorum, or the Romanian Mathematical Magazine, where dozens of fascinating integrals are often posted or published. Additionally, delving into other fields like Statistics, Physics, or Quantum Physics will present you with many remarkable integrals — some of which might be computed using Feynman's trick.


I would appreciate a notice on my email address (rxzacky@gmail.com) in case you find any mistakes or if something feels unclear in this essay - and even better if you have some further ideas or suggestions.

This work is licensed under a Creative Commons Attribution 4.0 International License, and it can be cited as:
Zaharia Burghelea, "Feynman's Trick," https://zackyzz.github.io/feynman.