7
$\begingroup$

I am trying to calculate the derivative of $\left| \sin x \right| $

Given the graphs, we notice that the derivative of $\left| \sin x \right|$ does not exist for $x= k\pi$.

Graph for $\left|\sin x\right|$:

|\sin x|

We can rewrite the function as

$\left| \sin(x) \right| = \left\{ \begin{array}{ll} \sin(x),& 2k\pi < x < (2k+1)\pi \\ -\sin(x), & \text{elsewhere} \\ \end{array} \right. $

Therefore calculate its derivative as:

$(\left| \sin(x) \right|)^{'} = \left\{ \begin{array}{ll} \cos(x),& 2k\pi < x < (2k+1)\pi \\ -\cos(x), & \text{elsewhere} \\ \end{array} \right. $

Is there a way to rewrite this derivative, in a more elegant way (as a non-branch function) $(\left| \sin(x) \right|)^{'} = g(x)$?

$\endgroup$
4
  • $\begingroup$ Note that the derivative doesn't exist at $x=k\pi$. Elsewhere you have it as a piecewise function. $\endgroup$
    – Anurag A
    Jul 11, 2020 at 7:25
  • $\begingroup$ True, I am editing the question, thank you. $\endgroup$
    – HelloWorld
    Jul 11, 2020 at 7:26
  • 1
    $\begingroup$ @Dimitris I know that you already accepted VIVID's answer, but since you were looking for an elegant way you may consider to at least upvote my answer. $\endgroup$
    – jjagmath
    Jul 31, 2021 at 1:51
  • $\begingroup$ @jjagmath done :) $\endgroup$
    – HelloWorld
    Aug 1, 2021 at 2:11

3 Answers 3

16
$\begingroup$

The better way, for me, is as follows: $$f(x)=\left|\sin(x)\right|=\sqrt{\sin^2(x)}$$ Now, differentiate both sides to get $$f'(x)=\frac{1}{2\sqrt{\sin^2(x)}}\cdot2\sin(x)\cos(x)=\frac{\sin(2x)}{2\left|\sin(x)\right|}$$ Therefore, $$\left(\left|\sin(x)\right|\right)'=\frac{\sin(2x)}{2\left|\sin(x)\right|}, \ \ \ \ x \neq k\pi, k\in \mathbb{Z}$$


Appendum: This approach can easily be extended to a general case of finding $\left(|f(x)|\right)'$.

First, we rewrite $$|f(x)| = \sqrt{f^2(x)}$$ Then, repeating the work above: $$|f(x)|' = \frac{1}{2\sqrt{f^2(x)}}[2f(x)f'(x)] = \frac{f(x)}{|f(x)|}f'(x)$$ we get $$\boxed{|f(x)|' = \frac{f(x)}{|f(x)|}f'(x)}$$

$\endgroup$
1
  • 5
    $\begingroup$ Simple and nice, I'll accept this answer, thank you @VIVID $\endgroup$
    – HelloWorld
    Jul 11, 2020 at 7:30
4
$\begingroup$

Apparently other answers missed the following direct approach: we have $$|x|' = \frac{x}{|x|}$$ for $x\ne 0$.

So, for example, VIVID's formula $|f(x)|' = \frac{f(x)}{|f(x)|} f'(x)$ is just the chain rule.

$\endgroup$
3
  • $\begingroup$ A standard but little-used notation for the signum function is $sgn (y)$, defined as $sgn (y)=y/|y|$ when$ 0\ne y\in\Bbb R$ and $sgn (0)=0$. In the 18th century two men got hold of the British school system and did their best to destroy the ease of phonetic spelling, insisting there must be a "g" in "sign", a "b" in "debt" , a "p" in "pneumonia", and so on. $\endgroup$ Jul 31, 2021 at 2:35
  • $\begingroup$ I'm familiar with the sign function. I didn't use it on purpose because $|x|'$ doesn't exists at $0$, while $sgn$ is well defined there. $\endgroup$
    – jjagmath
    Jul 31, 2021 at 3:06
  • $\begingroup$ Yes, it is more direct, but when I was asked to find $|x|'$ for the first time, I did exactly the same thing as in my answer i.e. $|x| = \sqrt{x^2}$ and then differentiating. Otherwise, the way to prove it would be the same as how the OP did for $|\sin x|$ himself, the method which he was not satisfied. So, my answer is actually using your idea hiddenly with its proof. $\endgroup$
    – VIVID
    Jul 31, 2021 at 6:01
2
$\begingroup$

I think an even nicer way of thinking about it is in terms of the sign of $\sin(x)$ applied to the derivative of $\sin(x)$. A function $f$ that returns the sign of another function $g$ is: $f(x)=\frac{\lvert(g(x))\rvert}{g(x)}$ .
So quite simply $\lvert \sin(x) \rvert'=\frac{\lvert \sin(x)) \rvert}{\sin(x)}\cdot\cos(x)$

This is essentially just $\cos(x)$ but reflected across the axis at the intervals where $\sin(x)$ is negative, that is: $\cos(x)$ for $x \in [0,\pi]$ and $-\cos(x)$ for $x \in [\pi,2\pi]$ and so on. The reason for this is not difficult to see: when we take the absolute value of a function, then the gradients of the points belonging to the intervals that were flipped, here where $x \in [\pi,2\pi]$, are also flipped. So what ends up happening is that the derivative essentially stays the same, but is flipped on the intervals where the original function was flipped.

$\endgroup$
1
  • 5
    $\begingroup$ Notice that $|y|/y = y/|y|,$ so we can show that this formula is equivalent to the other answer, although the derivation is different. $\endgroup$
    – David K
    Jul 11, 2020 at 16:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .