# Integral in greatest integer and absolute functions

$$\tag{1} \int_{1}^{4} \ln [x]\,dx$$ now we are given this problem , what i did was to write function as $$\int_1^4 1\cdot\ln [x]\,dx$$ and integral by parts yielded $[x]\ln [x]-[x]$ now we can enter limits to get the integral , have i done it correctly or am i missing something ? $$\tag{2} \int_0^\pi |\cos(x)-\sin(x)|\,dx$$ what i did was $$\int_0^\pi |\cos(x)| -\int_0^\pi|\sin(x)|\,dx$$ now since $\cos(x) \lt 0$ in $(-\pi/2,\pi)$ i wrote the integral $$\int_0^{\pi/2} \cos(x) \, dx-\int_{\pi/2}^\pi \cos(x) \, dx-\int_0^\pi \sin(x)\,dx$$ did i made any mistake ?

-
A lot of odd notation in there. What do you mean by $1.ln[x]$? $|cos(x)dx-six(x)|dx$ is a bit confused, too. – Thomas Andrews Aug 24 '13 at 20:09
well i needed to integrate by parts so i took 1 to be function and ln[x] to be another function and applied byparts integral like you do in case of evaluating $\int_{}^{}ln(x)dx$ and $|cos(x)dx−six(x)|dx$ it's typing mistake – Tesla Aug 24 '13 at 20:12
For the first problem, break up into $\int_1^2+\int_2^3+\int_3^4$. Each part is easy. Don't worry about endpoints, they don't affect the answer. From $1$ to $2$, we are integrating $0$. From $2$ to $3$, we are integrating $\ln 2$. From $3$ to $4$, we are integrating $\ln 3$. Answer is $\ln 2+\ln 3$. Maybe draw the function, it looks like a staircase. – André Nicolas Aug 24 '13 at 20:13
yes @AndréNicolas you are very correct now about the second part? – Tesla Aug 24 '13 at 20:17
Break up into parts, where $\cos x\ge \sin x$, and where $\cos x\le \sin x$. So from $0$ to $\pi/4$ we are integrating $\cos x-\sin x$. From $\pi/4$ to $\pi$ we are integrating $\sin x-\cos x$. Add. – André Nicolas Aug 24 '13 at 20:22

For the first integral, just note that the function you're integrating is constant on $[1, 2]$, $[2, 3]$ and $[3, 4]$. Just sketch the graph and add the areas.

For the second integral, it's not valid to state that

$$|\cos{x} - \sin{x}| = |\cos{x}| - |\sin{x}|$$

It is necessary to consider when the quantity inside the absolute value bars is positive and negative; we have that

$$\cos{x} - \sin{x} \geq 0$$

for all $x \in [0, \frac{\pi}{4}]$, so the integrand is just $\cos{x} - \sin{x}$ on that interval.

On the other hand, $\cos{x} - \sin{x} \le 0$ on $[\frac{\pi}{4}, \pi]$, so the integrand is $-(\cos{x} - \sin{x})$ on that interval. So the relevant integrals to consider are

$$\int_0^{\pi} |\cos{x} - \sin{x}| dx = \int_0^{\pi/4} \cos{x} - \sin{x} dx + \int_{\pi/4}^{\pi} -(\cos{x} - \sin{x}) dx$$

-

\begin{align} &\int_{0}^{\pi}\left\vert\cos\left(x\right) - \sin\left(x\right)\right\vert\,{\rm d}x \\[3mm]&= \sum_{\sigma = \pm}\sigma\int_{0}^{\pi} \left\lbrack\cos\left(x\right) - \sin\left(x\right)\vphantom{\Large A}\right\rbrack \Theta\left(\sigma\cos\left(x\right) - \sigma\sin\left(x\right)\right)\,{\rm d}x \\[3mm]&= \sum_{\sigma = \pm}\sigma \left.\left\lbrack\sin\left(x\right) + \cos\left(x\right)\right\rbrack \Theta\left(\sigma\cos\left(x\right) - \sigma\sin\left(x\right)\right) \vphantom{\LARGE A}\right\vert_{0}^{\pi} \\[3mm]&- \sum_{\sigma = \pm}\sigma\int_{0}^{\pi} \left\lbrack\sin\left(x\right) + \cos\left(x\right)\vphantom{\Large A}\right\rbrack \delta\left(\sigma\cos\left(x\right) - \sigma\sin\left(x\right)\right) \left\lbrack -\sigma\sin\left(x\right) - \sigma\cos\left(x\right) \right\rbrack\,{\rm d}x \\[3mm]&= \sum_{\sigma = \pm}\sigma\left\lbrack% -\Theta\left(-\sigma\right) -\Theta\left(\sigma\right) \right\rbrack + \sum_{\sigma = \pm}\int_{0}^{\pi} \left\lbrack\sin\left(x\right) + \cos\left(x\right)\vphantom{\Large A}\right\rbrack^{2}\, {\delta\left(x - \pi/4\right) \over \left\vert\vphantom{\Large A} -\sigma\sin\left(\pi/4\right) - \sigma\cos\left(\pi/4\right)\right\vert} \,{\rm d}x \\[3mm]&= 2\int_{0}^{\pi} \left\vert\vphantom{\Large A}\sin\left(\pi/4\right) + \cos\left(\pi/4\right)\right\vert\ \delta\left(x - \pi/4\right) \,{\rm d}x = {\large 2\,\sqrt{2}} \end{align}

-