Does chain rule enable you yo calculat derivative of $|x^2|$ at x = 0

The question states as following: "Does the Chain Rules anble you to calculate the derivates of |x^2| and |x|^2 at x=0? Do these functoins have derivatives at x = 0? why?"

So using the chain rule for both of these I got two different answer.

For $|x|^2$ I got $f'(x)= 2|x|*\frac {x}{|x|}$ i.e $2x$

For $|x^2|$ using the chain rule I got $f'(x)=\frac {2x}{|x|}$

Two very different answers. And and only one of these derivatives is differentiable at x = 0.

Which I know is strange since I know for $y = x^2$ => $y' = 2x$

$y'$ is differentiable at x = 0.

So how am I not able to reach the same conclusion using the chainrule?

• The chain rule is not applicable because one of the functions being composed is not differentiable at $0$.
– amd
Nov 23, 2017 at 1:07
• But how is that possible? We know $f'(x) =x^2$ differentiable at x = 0 but $f'(x)=|x^2|$ is'nt according to the chain rule? Nov 23, 2017 at 1:13
• You are right to note that this is an odd question and it throws me off too. Youre second one for $|x^2|$ is incorrectly computed. I get a derivative of $\frac{x^2}{|x^2|} 2x$. Nov 23, 2017 at 1:13
• Since $x^2$ is always positive anyway, derivative of $|x^2|$ simplifies to the derivative of just $x^2$, which is $2x$. And because of vertical reflectivity of the function across y-axis, $|x^2|$ is equal to $|x|^2$. This much is clear. They would be equivalent. The algebraic process to show this is a bit confused, however. Nov 23, 2017 at 1:15
• $|x|$ is not differentiable at the origin, so the chain rule, which requires that the functions being composed be differentiable at the appropriate points, is not applicable. That’s not to say that the compositions $|x^2|$ and $|x|^2$ aren’t differentiable, only that you can’t invoke the chain rule to prove it.
– amd
Nov 23, 2017 at 1:25

This is something of a trick question that highlights an often-overlooked subtlety: The chain rule requires that both of the functions being composed be differentiable at the appropriate points. In this problem we have $f:x\mapsto x^2$ and $g:x\mapsto|x|$. The latter function is not differentiable at $0$, so the conditions for applying the chain rule are not met. It’s a simple matter to show that the two compositions $f\circ g$ and $g\circ f$ are in fact differentiable at $0$ (and that their derivatives are equal to $0$ there), but you can’t use the chain rule to do so.

• That makes sense. Thank you! Nov 23, 2017 at 2:00

Your first answer is correct. (Consider that $|x^2| = |x|^2=x^2$.)

For the second one, you should have: $$\frac{x^2}{|x^2|}2x = 2x.$$

Edit: amd makes a good point in the comments that using the chain rule at $x=0$ here is unfounded since $|x|$ is not differentiable there (although it works for all $x\ne0$... I had skimmed over the first sentence where the actual question was stated and not realized it was a theory question very particularly about $x=0$.). However since $|x|^2=|x^2|=x^2$ they are all the same function and differentiable at the origin since $$\lim_{h\to 0} \frac{f(0+h)-f(0)}{h}=\lim_{h\to 0}\frac{h^2-0}{h}=0.$$

• is it sufficent to say that; since the derivative of both functions is 2x they are both differentiable at x =0? Nov 23, 2017 at 1:09
• It's sufficient for me. (And they are the same function.) Nov 23, 2017 at 1:12
• You cant infer the derivative if you cannot show differentiability. You first conclude that the derivative is known and use that to justify differentiability; its non-sequitur, circular reasoning. Nov 23, 2017 at 1:18
• Since you are invoking the limit definition, perhaps you would work out the solution with the appropriate expressions? Nov 23, 2017 at 1:40

Im in my senior year of a math bachelors, taking a special topics course whose kinks and curriculum havent even been worked out yet - its more of a graduate course. Anyway, I am just now being introduced to this concept.

I believe the solution lies in the concept of the subgradient.

What is a subgradient? Basically, its the set of all possible gradients at a given point. For a differentiable function the subgradient contains a single value, the gradient that point. For a non-differentiable point, the subgradient contains every possible value, from the derivative at one side of the point to the derivative at the other, as an interval.

So if you look strictly at the function $|x|$, the derivative is $-1$ when $x<0$, it is $1$ when $x>0$. But at $x=0$ it is the set of all values in $[-1,1]$. Because we are sort of defining a derivative at $x=0$, we can get away with the chain rule.

Given that $f_1(x) = |x|^2$ we can differentiate this as $f_1'(x) = 2x\frac{x}{|x|}$, where we are representing the derivative of $|x|$ at non-zero values as $\frac{x}{|x|}$. But what about at $x=0$, that is the question.

Using the subgradient, let us represent the "derivative" at $x=0$ of $f_1$ as $\partial f_1(x)=2x\cdot[-1,1]$. I used the chain rule - which is allowable because I defined the derivative of the functions with the subgradient. Remember, we have continuity, just not standard differentiability, but we've defined a pseudo-derivative in its place. And in a way of thinking, the derivative becomes continuous too when you think of sliding across the interval.

Here, the interval $[-1,1]$ represents all possible gradients at $x=0$ of the $|x|$ function by itself. When we plug in $x=0$ - bare in mind the expression is only valid for $x=0$ anyway - then the subgradient reduces to a single value of $0$ because of the extra factor $x$. And $0$ is what we expect for a derivative of this function.

Similarly, if we try for $f_2(x)=|x^2|$ we get for non-zero values $f_2'(x) = \frac{x^2}{|x^2|}2x$, where $\frac{x^2}{|x^2|}$ is representative of the derivative at non-zero values, as before. But at $x=0$ the subgradient becomes the interval $[1,1]=1$ of possible instantaneous slopes. So in fact $\partial f_2(x) = 2x\cdot 1$. At $x=0$, which is the only point this expression is valid for anyway, the gradient reduces to $0$. As expected.

You can also find optimum points using subgradient theory. In order to have a maximum or a minimum, the subgradient must contain a $0$. Notice that for the function $|x|$, at $x=0$ we have $0\in [-1,1]=\partial |x|$, and so we have found an optimum. This would not have been possible with standard differential calculus, though its an obvious graphical solution.