Integrating $\int_0^\pi x^4\cos(nx)\,dx$ using the Feynman trick

If we consider the following integral, with $z\in R$: $$\int_0^\pi \cos(zx)dx=\frac{\sin(\pi z)}{z}$$ Then all we need to do is to take $4$ derivatives with respect to $z$ (on both sides) then set $z=n$ to get the integral in the question, since: $$\frac{d}{dz}\left(\frac{\sin(\pi z)}{z}\right)=-\int_0^\pi x\sin(zx)dx$$ $$\frac{d^2}{dz^2}\left(\frac{\sin(\pi z)}{z}\right)=-\int_0^\pi x^2\cos(zx)dx$$ $$\frac{d^3}{dz^3}\left(\frac{\sin(\pi z)}{z}\right)=\int_0^\pi x^3\sin(zx)dx$$ $$\frac{d^4}{dz^4}\left(\frac{\sin(\pi z)}{z}\right)=\int_0^\pi x^4\cos(zx)dx$$

Of course in case you're looking for $\int_0^\pi x^3 \cos(nx)dx$ then you might want to consider initially $\int_0^\pi \sin(zx)dx$ and proceed as above.


I would also like to mention that this method also works for other integrals, for example let's take: $$\int_0^1 x^9 \ln^5 xdx$$ All there is needed to do is to consider: $$\int_0^1 x^z dx=\frac{1}{z+1}\Rightarrow \int_0^1 x^z \ln xdx=\frac{d}{dz}\left(\frac{1}{z+1}\right) $$ $$\Rightarrow \int_0^1 x^9 \ln^5 x dx= \lim_{z\to 9}\frac{d^5}{dz^5}\left(\frac{1}{z+1}\right)$$


Define $$f(a) = \int_0^\pi e^{ax} dx$$ Use Leibniz rule to differentiate with respect to $a$, $4$ times, set $a=ni$ then take the real part.