I should solve the following integral
$$\displaystyle\int_0^\pi x^4\cos(nx)\,dx$$
Usually you would integrate 4 times by parts. I was wondering if there is a more direct way, something like the Leibniz rule (aka Feynman trick).
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It only takes a minute to sign up.
Sign up to join this communityI should solve the following integral
$$\displaystyle\int_0^\pi x^4\cos(nx)\,dx$$
Usually you would integrate 4 times by parts. I was wondering if there is a more direct way, something like the Leibniz rule (aka 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.
EDIT: Sorry, I didn't read the question fully; this doesn't use the Leibniz rule.
If I recall, the cumulative distribution function for the Erlang distribution works for complex parameters. Your integral is $$ \Re\left(\int_0^\pi x^4 e^{inx}dx\right) = \Re\left(\frac{\Gamma(5)}{(-in)^5} \int_0^\pi \frac{(-in)^5 x^4 e^{inx}}{\Gamma(5)}dx\right)$$ where $\Re$ denotes the real part. The integral is the cumulative distribution function evaluated at $\pi$, namely $$ \int_0^\pi \frac{(-in)^5 x^4 e^{inx}}{\Gamma(5)}dx = 1 - \sum_{j=0}^4 \frac{(-in\pi)^j}{j!}e^{in\pi},$$ i.e. $$ \int_0^\pi x^4 \cos(nx)dx = \Re\left(\frac{24i}{n^5}\left(1 - \sum_{j=0}^4 \frac{(-in\pi)^j}{j!}e^{in\pi}\right)\right).$$
Take $\int$ as operator D^(-1) (1/D)e^(ax)x^4=e^(ax)(1/(D+a))x^4=e^(ax)(1/a)(1+D/a)^-1 {x^4} =(1/a)e^(ax){1-D/a+D^2 /a^2 +D^3/a^3-d^4/a^4}x^4
We can take a as $in$ and proceed to obtain the real part of the expression. [\begin{gathered} \int {{e^{ax}}} {x^n}dx = \frac{1}{D}\left\{ {{e^{ax}}.{x^4}} \right\} = {e^{ax}}\frac{1}{{D + a}}\left\{ {{x^4}} \right\} \hfill \\ = \frac{{{e^{ax}}}}{a}\frac{1}{{\left( {1 + \frac{D}{a}} \right)}}\left\{ {x4} \right\} = \frac{{{e^{ax}}}}{a}{\left( {1 + \frac{D}{a}} \right)^{ - 1}}\left\{ {{x^4}} \right\} \hfill \\ = \frac{{{e^{ax}}}}{a}\left( {1 - \left( {\frac{D}{a}} \right) + {{\left( {\frac{D}{a}} \right)}^2} - {{\left( {\frac{D}{a}} \right)}^3} + {{\left( {\frac{D}{a}} \right)}^4} - \cdots } \right)\left\{ {{x^4}} \right\} \hfill \\ = \frac{{{e^{ax}}}}{a}\left\{ {{x^4} - \frac{{4{x^3}}}{a} + \frac{{4.3{x^2}}}{{{a^2}}} - \frac{{4.3.2x}}{{{a^3}}} + \frac{{4.3.2.1}}{{{a^4}}}} \right\} \hfill \\ Let\,a = j.n;and\,obtain\,the\,real\,part\,of\,the\,result. \hfill \\ \end{gathered} ]
Yep,
$$\int_0^\pi\cos(nx)\,dx=\frac{\sin(n\pi)}n$$
and it "suffices" to differentiate four times on $n$.
By the Leibniz rule,
$$\pi^4n^{-1}\sin(\pi n)+4\pi^3n^{-2}\cos(\pi n)-6\pi^2\cdot2n^{-3}\sin(\pi n)-4\pi\cdot3!n^{-4}+4!n^{-5}.$$