Integration question.

The question is as follows

For any real number $x$, let $\lfloor{x}\rfloor$ denote the greatest integer less than or equal to $x$. Let $f$ be a real valued function defined on the interval $[-10,10]$ by

$f(x)= \begin{cases} x-\lfloor{x}\rfloor & \ \ \text{if} \ \lfloor{x}\rfloor \ \text{is odd} \\ 1+\lfloor{x}\rfloor-x & \ \ \text{if} \ \lfloor{x}\rfloor \ \text{is even} \end{cases}$

Then the value of $\dfrac{\pi^2}{10}\displaystyle\int_{-10}^{10} f(x) \ \cos{\pi x} \ dx$ is

My try--

$f(x)$ can be rewritten as

$f(x)= \begin{cases} \{x\} & \ \ \text{if} \ \lfloor{x}\rfloor \ \text{is odd} \\ 1-\{x\} & \ \ \text{if} \ \lfloor{x}\rfloor \ \text{is even} \end{cases}$

Where $\{ \cdot\}$ denotes the fractional part function.

The graph of $f(x)$ will be somewhat like this, from $-10$ to $10$.

So, $\displaystyle\int_{-10}^{10} f(x) \ dx=10 \times \dfrac{1}{2} \times 2 \times 1=10.$

Then, using integration by parts, $$\displaystyle\int_{-10}^{10} \underbrace{f(x)}_{\text{2nd function}} \underbrace{\cos{\pi x}}_{\text{1st function}} \ dx=\left[\cos {\pi x} \cdot 10\right]_{-10}^{10}+\displaystyle\int_{-10}^{10}\pi\sin{\pi x} \cdot 10 \ dx \ \ \ \ \ \ \left(\text{because} \ \displaystyle\int_{-10}^{10} f(x) \ dx=10\right)$$

But my answer does not match that given in the book.

• It seems that you have somehow mixed definite and indefinite integrals when integrating by parts. How would you state the integration by parts formula? Aug 14, 2014 at 15:53
• @JoonasIlmavirta $$\int u(x) \cdot v(x) dx=u(x)\int v(x) dx-\int \left(u'(x) \int v(x) dx\right) dx$$ Aug 14, 2014 at 15:59
• That formula is so confusingly written that I would say that it is wrong. Using the same variable $x$ in two nested integrals and not marking any limits (especially in the inner integrals) is the source of your confusion. Something like $\int_a^x f(y)g'(y)dy=f(x)g(x)-f(a)g(a)-\int_a^x f'(y)g(y)dy$ would be much safer to use. Aug 14, 2014 at 16:06

It is easier to note that the answer is (do you see why?)
$10*\displaystyle\int_{0}^{2} f(x)\cos(\pi x)dx=10*\displaystyle\int_{0}^{1} x\cos(\pi x)dx+10*\displaystyle\int_{1}^{2} (2-x)\cos(\pi x)dx$, and then use IBP (integration by parts) on that.

EDIT: Your mistake is actually something else in your IBP. Let the integral of $f(x)$ be denoted $F(x)$:

$\displaystyle\int_{-10}^{10} \underbrace{f(x)}_{\text{2nd function}} \underbrace{\cos{\pi x}}_{\text{1st function}} \ dx=\left[\cos {\pi x} \cdot F(x)\right]_{-10}^{10}+\displaystyle\int_{-10}^{10}\pi\sin{\pi x} \cdot F(x) \ dx$
When you integrate by parts, the function that isn't differentiated (that's integrated) isn't integrated definitely across the whole range but indefinitely inside the square brackets and the integral.

$\displaystyle\int_{0}^{1} u'vdx=\left[uv\right]_{0}^{1}-\displaystyle\int_{0}^{1}uv'dx$

Not $\displaystyle\int_{0}^{1} u'vdx=\left[v(\displaystyle\int_{0}^{1}udx)\right]_{0}^{1}-\displaystyle\int_{0}^{1}v'(\displaystyle\int_{0}^{1}udt)dx$

• I have integrated $f(x)$ in doing IBP, which we know to be $10$.. Aug 14, 2014 at 15:54
• @Pkwssis Yes, but integration by parts uses the derivative of $f$ in the second integral, which (the derivative) can be $-1$ or $1$ Aug 14, 2014 at 15:55
• Where does it use the derivative of $f$? I have differentiated $\cos {\pi x}$.. Aug 14, 2014 at 15:57
• @Pkwssis Oh, I see your mistake. Just a sec, I'll make an edit Aug 14, 2014 at 15:58