# Derivitave of a Modulus

Homework Helper
Feeling a little bit more confident about my calculus skills I was hoping to check if this is correct. Let’s say you have:

$$g(|f(x)|)$$

And you want to take the derivative with respect to x, well using the chain rule you get:

$$\bigl( g(|f(x)|) \bigr)' = (|f(x)|)' g'(|f(x)|)$$

Looking more closly at $(|f(x)|)'$. Defining it as:

$$\left( +\sqrt{(f(x))^2} \right)'$$

Then using the chain rule we get:

$$(|f(x)|)' = 2f(x) f'(x) \: \frac{1}{2} \: \frac{1}{ +\sqrt{(f(x))^2} }$$

Simplifying:

$$(|f(x)|)' = f'(x) \frac{f(x)}{|f(x)|}$$

Substituting back in the original equation and sorting out the problem of when f(x) = 0:

$$\bigl( g(|f(x)|) \bigr)' = \begin{cases} f'(x) \frac{f(x)}{|f(x)|}g'(|f(x)|) & \text{if  f(x) \neq 0} \\ \\ \lim_{f(x) \rightarrow 0} \left(f'(x) \frac{f(x)}{|f(x)|}g'(|f(x)|) \right) & \text{if  f(x) = 0 and  \lim_{f(x) \uparrow 0} \left( f'(x) \frac{f(x)}{|f(x)|}g'(|f(x)|) \right) = \lim_{f(x) \downarrow 0} \left( f'(x) \frac{f(x)}{|f(x)|}g'(|f(x)|) \right)} \\ \\ \text{Undefinied} & \text{if  f(x) = 0 and  \lim_{f(x) \uparrow 0} \left( f'(x) \frac{f(x)}{|f(x)|}g'(|f(x)|) \right) \neq \lim_{f(x) \downarrow 0} \left( f'(x) \frac{f(x)}{|f(x)|}g'(|f(x)|) \right)} \end{cases}$$

Correct? I know it all seems a bit over the top (especially when you look at the tex for it ) but I like things to be well defined and in a form like this where I understand it better.

Edit: I made a mistake, it should be correct now

Last edited:

Homework Helper
it is over the top. it is easier to use mod of Y is Y if Y is positive and -Y if Y is negative, the derivative not defined if Y=0, though it is conceivalbe that g(modY) is differentiable when Y=0.

Homework Helper
matt grime said:
it is over the top. it is easier to use mod of Y is Y if Y is positive and -Y if Y is negative, the derivative not defined if Y=0, though it is conceivalbe that g(modY) is differentiable when Y=0.
I'm not trying to find an easier method, but rather checking that my method is correct.

Although I do not claim this method to be more useful. I think it does yeld a more accurate result over some functions than the method you use, for example if you want to find the derivative with respect of x:

$$\left| x^n \right| \quad n \in \mathbb{N} \backslash \negmedspace \{ 1 \}$$

But really more than anything I just want to check it is correct.

Edit: I just realised a big mistake in it, but I've now edited the first post accordingly.

Last edited:
Homework Helper
but they are easily seen to be equivalent, indeed your f/modf is simply +/-1 depending on whether f is positive or negative, ie you are just not using the words 'when something is positive/negative' and making it neater, so yes your method is correct in spirit though i haven't checked the detail

$$\left( +\sqrt{(f(x))^2} \right)'$$