# What is the second derivative of the absolute function $\left|\frac{x+1}{x+2}\right|$?

I calculated the derivative of $$\left|\frac{x+1}{x+2}\right|$$ in the same way that I would do with $$\frac{x+1}{x+2}$$ in order to study the function.

But when I verified on wolfram, I noticed it is all wrong. Wolfram uses the chain rule as you can see here.

I don't get it. The only rule I've been taught as far as absolute function derivatives are concerned, is $$|x|' = \frac{x}{|x|}$$. Does a similar rule apply for $$f(x)$$? And why does wolfram uses chain rule?

Edit

I calculated the derivatives as there is no absolute and then, at the result, I applied the absolute.

My answers are $$|(\frac{x+1}{x+2})|' = |(\frac{x+1}{x+2})'| = \frac{1}{\left(x+2\right)^2}$$ and $$|(\frac{x+1}{x+2})|'' = |(\frac{x+1}{x+2})''| = \frac{2}{\left(x+2\right)^3}$$

$$\left(\left|\frac{x+1}{x+2}\right|\right)'\:=\frac{\left|x+2\right|\left(x+1\right)}{\left|x+1\right|\left(x+2\right)^3}$$

• What answer did you get? It's easier to answer "why use the chain rule" if we can point out exactly where you went wrong. Aug 25, 2020 at 6:58
• We can't guess what you did, so we can't tell where "it is all wrong".
– user65203
Aug 25, 2020 at 7:02
• I edited the question Aug 25, 2020 at 7:04

This is how I deal with absolute functions:

\begin{align} \left|\frac{x+1}{x+2}\right|&=\sqrt{\left(\frac{x+1}{x+2}\right)^{2}}\\ \\ \frac{d}{dx} \left|\frac{x+1}{x+2}\right|&=\frac{d}{dx} \sqrt{\left(\frac{x+1}{x+2}\right)^{2}}\\ &=\frac{1}{2 \sqrt{\left(\frac{x+1}{x+2}\right)^{2}}}\cdot 2 \left(\frac{x+1}{x+2}\right)\cdot\frac{1}{\left(x+2\right)^{2}}\\ &=\frac{x+1}{\left(x+2\right)^{3}\cdot\left|\frac{x+1}{x+2}\right|} \end{align}

Notice the chain rule when I differentiate the square root

• Great, thank you! Aug 25, 2020 at 7:14
• The term $\left(\frac{1}{x+2}\right)^{2}$ would be better writen as $\frac{1}{\left(x+2\right)^{2}}$ – it's the denominator which gets squared in differentating a ratio. The numerator reduces to $1$ and $1$ squared equals $1$, so the equality holds whith $1^2$, but there's no reason to introduce squaring to numerator. Aug 25, 2020 at 8:27
• @CiaPan that is spot on! Edited it, thanks. Aug 25, 2020 at 8:35
• @RezhaAdrianTanuharja goodness, thank you so much for that original approach, it will be really useful to me!! :)) Aug 25, 2020 at 8:42
• @A-levelStudent ur welcome mate Aug 25, 2020 at 9:55

As an alternative, using sign function we have that for $$x\neq -1,-2$$

$$\left|\frac{x+1}{x+2}\right|=\frac{x+1}{x+2}\cdot \frac{\left|\frac{x+1}{x+2}\right|}{\frac{x+1}{x+2}}=\frac{x+1}{x+2} \operatorname{sign}\left(\frac{x+1}{x+2}\right)$$

therefore by chain rule, since $$(\operatorname{sign}(x))'=0$$ for $$x\neq 0$$, we obtain

$$\frac d{dx}\left|\frac{x+1}{x+2}\right|=\left(\frac d{dx}\frac{x+1}{x+2}\right)\operatorname{sign}\left(\frac{x+1}{x+2}\right)=\frac1{(x+2)^2}\operatorname{sign}\left(\frac{x+1}{x+2}\right)=\frac{\left|\frac{x+1}{x+2}\right|}{(x+1)(x+2)}$$

which is an equivalent form for the derivative.

• That was really nice! Aug 28, 2020 at 7:24
• You are welcome! Bye
– user
Aug 28, 2020 at 7:27

Hint:

As

$$\left|\frac{x+1}{x+2}\right|=\pm\frac{x+1}{x+2},$$

it is legitimate to take the derivative of the fraction without the absolute value.

Instead of an absolute value, you will use a piecewise definition where the sign is adjusted in every interval, and the derivatives naturally follow.

• Altough it seems right to me, I think it comes in contrast with the result Wolfram suggested i.e $\left(\left|\frac{x+1}{x+2}\right|\right)'\:=\frac{\left|x+2\right|\left(x+1\right)}{\left|x+1\right|\left(x+2\right)^3}$ Aug 25, 2020 at 7:06
• @Euler: how can you tell that these answers differ ?
– user65203
Aug 25, 2020 at 7:07
• @Euler: I don't think that you learnt from this case. :-(
– user65203
Aug 25, 2020 at 7:21
• @Euler: instantiate $\pm$ accordingly.
– user65203
Aug 28, 2020 at 7:51