The second derivative of the absolute function $\left|\frac{x+1}{x+2}\right|$

calculusderivativessoft-question

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}$

Wolfram's answer is

$\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}$


Best Answer

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