4
$\begingroup$

I have the following integral $$\int_0^{\pi/2} |\sin x-\cos x|dx. $$It's a simple integral but when I try to solve the module I get stuck. I took $\sin x-\cos x>0$ and squaring this I found that $\sin 2x<1$. When I apply $\arcsin$ it would mean $$2x<\frac\pi2 \implies x<\frac\pi4$$ but the interval is wrong from the one in my book. When I apply $\arcsin$ does the sign change? Why?

$\endgroup$
  • 5
    $\begingroup$ In your title, you mention "solving an equation". Do you realize that you don't use the appropriate terms. Nothing common for example with solving a quadratic equation $x^2+x-2=0$ for example. You should say "find an explicit value". Being good in mathematics is also using accurate terms. $\endgroup$ – Jean Marie Jun 5 '17 at 12:54
  • $\begingroup$ You haven't shown your work for how you went from $\sin x-\cos x>0$ to $\sin2x<1$. From $\sin2x<1$, you forget to realize that $\sin\theta<1$ hold everywhere except at odd integer multiples of $\pi$, not just on $\theta<\frac\pi2$. This follows from $\sin$ being periodic and the such. $\endgroup$ – Simply Beautiful Art Jun 6 '17 at 0:11
6
$\begingroup$

Hint for how to determine the sign of $\sin x - \cos x$:

$$\sin x -\cos x = \sqrt2\left(\sin x \cos \frac\pi4 - \cos x \sin\frac\pi4\right) = \sqrt2 \sin\left(x-\frac\pi4\right)$$

$\endgroup$
  • $\begingroup$ Thats a nice solution but could you tell me where I'm going wrong with mine? $\endgroup$ – Lola Jun 5 '17 at 10:56
  • 2
    $\begingroup$ @Lola If you square $\sin x - \cos x$, regardless of whether it was positive or negative, the result will be non-negative. And $\sin 2x <1$ does not tell you much, only that $2x \ne 2n\pi + \pi/2$. $\endgroup$ – peterwhy Jun 5 '17 at 11:00
12
$\begingroup$

Note that $\sin x-\cos x=\cos x(\tan x-1)$.

$\sin x\le\cos x$ when $x\in[0,\frac{\pi}{4}]$.

$\sin x\ge\cos x$ when $x\in[\frac{\pi}{4},\frac{\pi}{2}]$.

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

$\endgroup$
  • $\begingroup$ @TonyK What's the problem with the first line? $\endgroup$ – CY Aries Jun 5 '17 at 15:08
  • 2
    $\begingroup$ Personally I'm struggling to see where that note in the first line is relevant... You don't seem to use it afterwards, you just split the range of the integral by way of your second and third lines and I don't think you need the first line to get your second and third lines. I'm probably missing something but if somebody else was confused in a previously deleted comment then I might not be the only one missing something... :) $\endgroup$ – Chris Jun 5 '17 at 15:32
  • 1
    $\begingroup$ OP seems to have difficulties in determining the range for which $\sin x-\cos x\ge0$. Since $\cos x\ge 0$ for $x\in[0,\frac{\pi}{2}]$, the fact that $\tan x\ge1$ for $x\in[\frac{\pi}{4},\frac{\pi}{2})$ implies that $\sin x-\cos x\ge0$ on $[\frac{\pi}{4},\frac{\pi}{2})$. Similarly, for $x\in[0,\frac{\pi}{4}]$, $\tan x\le0$ and hence $\sin x-\cos x\le0$. That's why I have put this line. $\endgroup$ – CY Aries Jun 5 '17 at 15:39
  • $\begingroup$ Ah, thanks for the explanation. $\endgroup$ – Chris Jun 5 '17 at 15:52
5
$\begingroup$

$$ \begin{align} \int_0^{\pi/2}|\sin(x)-\cos(x)|\,\mathrm{d}x &=\int_0^{\pi/4}(\cos(x)-\sin(x))\,\mathrm{d}x +\int_{\pi/4}^{\pi/2}(\sin(x)-\cos(x))\,\mathrm{d}x\tag{1}\\ &=2\int_0^{\pi/4}(\cos(x)-\sin(x))\,\mathrm{d}x\tag{2}\\ &=2\left[\vphantom{\int}\sin(x)+\cos(x)\right]_0^{\pi/4}\tag{3}\\[6pt] &=2\sqrt2-2\tag{4} \end{align} $$ Explanation:
$(1)$: $\cos(x)\ge\sin(x)$ on $\left[0,\frac\pi4\right]$ and $\sin(x)\ge\cos(x)$ on $\left[\frac\pi4,\frac\pi2\right]$
$(2)$: $\cos(x)=\sin\left(\frac\pi2-x\right)$ and $\sin(x)=\cos\left(\frac\pi2-x\right)$
$(3)$: integrate
$(4)$: evaluate

$\endgroup$
3
$\begingroup$

The function $\;f(x)=\lvert \sin x-\cos x\rvert\;$ has a symmetry w.r.t. $\frac\pi 4$ since $\;f\bigl(\frac \pi2-x\bigr)=f(x)$, hence $$\int_0^{\tfrac\pi 2} \lvert\sin x-\cos x\rvert \,\mathrm dx=2\int_0^{\tfrac\pi 4} (\cos x-\sin x) \,\mathrm dx=2(\sin x+\cos x)\biggl\rvert_0^{\tfrac\pi4}=2(\sqrt2-1).$$

$\endgroup$
  • $\begingroup$ Integration is false. $\endgroup$ – Takahiro Waki Jun 5 '17 at 13:11
  • $\begingroup$ @Takahiro Waki: It's fixed. I really was out of my mind on posting…Thanks for pointing it! $\endgroup$ – Bernard Jun 5 '17 at 15:25
2
$\begingroup$

Well, we can use the relation:

$$\sin\left(x\right)-\cos\left(x\right)=-\sqrt{2}\cdot\sin\left(\frac{\pi}{4}-x\right)\tag1$$

So, for the integral we get:

$$\mathscr{I}:=\int_0^\frac{\pi}{2}\left|\sin\left(x\right)-\cos\left(x\right)\right|\space\text{d}x=\int_0^\frac{\pi}{2}\left|-\sqrt{2}\cdot\sin\left(\frac{\pi}{4}-x\right)\right|\space\text{d}x=$$ $$\int_0^\frac{\pi}{2}\left|-\sqrt{2}\right|\cdot\left|\sin\left(\frac{\pi}{4}-x\right)\right|\space\text{d}x=\sqrt{2}\int_0^\frac{\pi}{2}\left|\sin\left(\frac{\pi}{4}-x\right)\right|\space\text{d}x\tag2$$

Now, for the integral we can write:

$$\int_0^\frac{\pi}{2}\left|\sin\left(\frac{\pi}{4}-x\right)\right|\space\text{d}x=\int_0^\frac{\pi}{4}\sin\left(\frac{\pi}{4}-x\right)\space\text{d}x-\int_\frac{\pi}{4}^\frac{\pi}{2}\sin\left(\frac{\pi}{4}-x\right)\space\text{d}x\tag3$$

$\endgroup$
  • $\begingroup$ To simplify all previous answers: Just look at the rectification of f(x)= cosx-sinx so the full integral is twice that of f(x) over half the range. $\endgroup$ – Jens Jul 5 '17 at 12:33
2
$\begingroup$

\begin{align} \int_0^{\pi/2} |\sin(x)-\cos(x)|dx &= \int_0^{\pi/4} |\sin(x)-\cos(x)|dx+\int^0_{\pi/4} |\sin(x)-\cos(x)|dx\\ &=-\int_0^{\pi/4} \sin(x)-\cos(x)dx+\int_{\pi/4}^{\pi/2} \sin(x)-\cos(x)dx\\ &=.. \end{align}

$\endgroup$
  • 3
    $\begingroup$ Use \sin x , \cos x to write nicely those functions, and don't forget parentheses...Also use \pi for $\;\pi\;$ . $\endgroup$ – DonAntonio Jun 5 '17 at 10:59
  • 2
    $\begingroup$ Are your limits correct in your second terms? Should the top limit be $\pi/2$ ? $\endgroup$ – Chris Jun 5 '17 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.