How does one calculate the derivative of the function $ f(x) = \frac{\left|x\right|}{\operatorname{sgn}\left(x\right)+x} $? How does one calculate the derivative of this function? I wrote this function based on rotations of the congruent segments of the curve $y =\frac{1}{x}$ (the segments are in the ranges [-∞, 0.5], [0.5, 0], [0, 0.5] and [0.5, +∞]).
$$ f(x) = \frac{\left|x\right|}{\operatorname{sgn}\left(x\right)+x} $$
Also, is this function infinitely differentiable, if $f(0)$ is defined as 0?
Here’s the plot:

 A: We can find the derivative analytically (as a single function! :D) through a bit of manipulation without any need of splitting domains.
For $x\neq 0$ (we manually defined the point and derivative result at $0$ so we don't have to worry about this) we have
$$\frac{\left|x\right|}{\operatorname{sgn}\left(x\right)+x}=\frac{|x|}{\frac{|x|}{x}+x}=\frac{\sqrt{x^2}}{\frac{\sqrt{x^2}}{x}+\frac{x^2}{x}}= x\cdot \frac{\sqrt{x^2}}{\sqrt{x^2}+x^2}\cdot\frac{\frac{1}{\sqrt{x^2}}}{\frac{1}{\sqrt{x^2}}}=x\cdot \frac1{1+\sqrt{\frac{x^4}{x^2}}}=\frac{x}{1+\sqrt{x^2}}$$
Now, we have
\begin{align*}
\frac{\text{d}}{\text{d}x}\left[x\cdot\left(1+\sqrt{x^2}\right)^{-1}\right]&=1\cdot\left(1+\sqrt{x^2}\right)^{-1}+x\cdot-\left(1+\sqrt{x^2}\right)^{-2}\cdot\frac{x}{\sqrt{x^2}}\\
&=\frac{-\sqrt{x^2}}{\left(1+\sqrt{x^2}\right)^2}+\frac1{1+\sqrt{x^2}}\\
&=\frac1{\left(1+\sqrt{x^2}\right)^2}=\boxed{\frac1{\left(1+|x|\right)^2}}
\end{align*}
Desmos graphically/numerically confirms the result



As for the infinitely differentiable question, this is questionable. I would say no, but we can also say a nuanced yes.
Why no? We can see this two ways, first, if we take the one sided derivative at $0$, we get $\pm1$. Hence, our expression is no longer differentiable.
If we use the same strategy as before and differentiate our derivative a second time, we get $$-\frac{2x}{|x|\left(1+|x|\right)^3}$$

If we take directional limits to and from $0$, we get $\pm1$, meaning that the derivative at $0$ does not exist. Thus, the function is not infinitely differentiable.
However, we can (sort of) make this work by setting a peicewise rule. Define our initial expression as $f(x)$. We have it such that
$$f^{(n)}(x)= \begin{cases} 
      f^{(n)}(x) & x\neq 0\text{ if }n\equiv0(\operatorname{mod} 2)\\
      0 & x=0\text{ if }n\equiv0(\operatorname{mod} 2) 
   \end{cases}
$$
But this is stupid so basically the answer is no it is not infinitely differentiable.
A: $$f(x)=\frac{-x}{-1+x}, x\le 0; f(x)=\frac{x}{1+x}, x>0$$ It is continuous at $x=0,\pm 1$
Then $f'(x\le 0)= \frac{d}{dx}\frac{x}{x-1}=-\frac{1}{(x-1)^2}.$
and $$f'(x>0)=\frac{d}{dx}\frac{x}{x+1}=\frac{1}{(x+1)^2}$$
A: Consider the following cases:

*

*$x< 0$, in this case, $f(x) = \frac{-x}{-1+x}$, so the function is differentiable.


*$x=0$: Here's the part in which things might not be as simple in the other cases, but, one can manage to still prove that $f$ is differentiable at $0$. Recall that given a function $f: A \subset \mathbb{R} \to \mathbb{R}$ and a point $a$ in the closure of $A$, $f$ has limit in $a$ if and only if its right sided and left sided limits exist and are equal. Thus, it will suffice to find these limits for $\frac{f(x) - f(0)}{x}$: let $h > 0$, then
$$\dfrac{f(h)- f(0)}{h} = \dfrac{\dfrac{h}{1+h}}{h} = \dfrac{1}{1+h}$$,
so, the right sided limit of $\dfrac{f(h)- f(0)}{h}$ is $1$. Similarly (taking $h < 0$ and finding the limit of $\frac{f(h)-f(0)}{h}$ as $h$ tends to $0$ by negative values) one proves the left limit is equal to $1$ and thus $f$ is differentiable at $0$ with $f'(0) = 1$.


*In a similar manner as in 1, consider $x>0$, evaluate $f$ in $x$ and deduce that $f$ is differentiable for these values.
To see whether the function is infinitely differentiable, find the right sided limit and the left sided limit of $\frac{f'(x) - f'(0)}{x}$ at $0$.
A: When $x\neq 0$, the derivative of $|x|$ is $\text{sgn}(x)$ and the derivative of $\text{sgn}(x)$ is $0$. We can differentiate $f$ directly
\begin{equation}
f'(x) = \frac{\text{sgn}(x)\times(\text{sgn}(x)+x) - |x|\times(0 + 1)}{(\text{sgn}(x) + x)^2} = \frac{1}{(\text{sgn}(x)+ x)^2}
= \frac{1}{(1+  |x|)^2}
\end{equation}
By defining $f(0)=0$ we see that $f$ is continuous at $0$ and that
\begin{equation}
f'(x)\mathop{\longrightarrow}_{\substack{
x\to 0\\
x\neq 0}} 1
\end{equation}
It follows that $f$ is differentiable at $0$ and $f'(0) = 1$.
