Basic integration by parts yields (seemingly?) wrong result

87 Views Asked by At

I'm trying to calculate a relatively trivial integral, but wolfram doesn't agree with me.

Here's my calculation: \begin{align*} \int \cos(2n\pi x)\cos(\pi x)dx &= \frac1{2n\pi} \sin(2n\pi x) \cos(\pi x) - \int \frac1{2n\pi} \sin(2n\pi x) [-\pi \sin(\pi x)]dx \\[6px] &= \frac1{2n\pi} \sin(2n\pi x) \cos(\pi x) + \frac1{2n} \int \sin(2n\pi x) \sin(\pi x)dx \\[6px] &= \frac1{2n\pi} \sin(2n\pi x) \cos(\pi x) \\ &\qquad+ \frac1{2n} \left[ \frac1{2n\pi} \cos(2n\pi x) \sin(\pi x)- \int \frac1{2n\pi} \cos(2n\pi x) \pi \cos(\pi x)dx\right] \\[6px] &= \frac1{2n\pi} \sin(2n\pi x) \cos(\pi x) \\ &\qquad + \frac1{2n} \left[ \frac1{2n\pi} \cos(2n\pi x) \sin(\pi x)- \frac1{2n}\int \cos(2n\pi x) \cos(\pi x)dx\right] \\[6px] &= \frac1{2n\pi} \sin(2n\pi x) \cos(\pi x) \\ &\qquad + \frac1{4n^2\pi} \cos(2n\pi x) \sin(\pi x)- \frac1{4n^2}\int \cos(2n\pi x) \cos(\pi x)dx \end{align*}

Then \begin{align*} \left(1+\frac1{4n^2}\right)\int \cos(2n\pi x)\cos(\pi x)dx&= \frac1{2n\pi} \sin(2n\pi x) \cos(\pi x) + \frac1{4n^2\pi} \cos(2n\pi x) \sin(\pi x)\\[6px] \int \cos(2n\pi x)\cos(\pi x)dx&= \frac{\frac1{2n\pi} \sin(2n\pi x) \cos(\pi x) + \frac1{4n^2\pi} \cos(2n\pi x) \sin(\pi x)}{\left(1+\frac1{4n^2}\right)} \\[6px] \int \cos(2n\pi x)\cos(\pi x)dx&= \frac{2n \sin(2n\pi x) \cos(\pi x) + \cos(2n\pi x) \sin(\pi x)}{\pi\left(4n^2+1\right)} \end{align*} and here's what Wolfram thinks it should be:

enter image description here

Am I supposed to apply some goniometric identity here, or what's wrong in this calculation? Should I apply partial fractions perhaps?

1

There are 1 best solutions below

0
On BEST ANSWER

There is no integration by parts substitution to get:

$$\int \sin(2\pi nx)\sin(\pi x) \,dx =\frac{1}{2\pi n}\cos(2\pi n x)\sin(\pi x)-\int\dots$$

(Step from line 2 to line 3.)

If you set $u=\sin(\pi x)$ and $dv=\sin(2\pi n x)$, then $v=-\frac{1}{2\pi n}\cos(2\pi n x)$. You don't have the minus sign in line $3$.

Indeed, both the signs are wrong in this step, so it should be: $$\int \sin(2\pi nx)\sin(\pi x) \,dx =-\frac{1}{2\pi n}\cos(2\pi n x)\sin(\pi x)+\int\dots$$

This then leaves you with a $1-\frac{1}{n^2}$ factor on the left, which gives you an $n^2-1$ denominator when you divide, which is close to what you want. You get:

$$\frac{2n \sin(2n\pi x) \cos(\pi x) - \cos(2n\pi x) \sin(\pi x)}{\pi\left(4n^2-1\right)}$$

This turns out to be equal to Wolfram Alpha's answer, I think. It takes some juggling with the $\sin(A+B)$ formula to see that: $$(2n+1)\sin(2n-1)x +(2n-1)\sin(2n+1)x = 2(2n\sin(2n\pi x)\cos(\pi x)-\cos(2\pi n x)\sin(\pi x))$$

If you are allowed to not use integration by parts, it is easier to do this integral using: $$\cos(A)\cos(B)=\frac{1}{2}\left(\cos(A+B)-\cos(A-B)\right)$$