# Derivative of Abs(x)

1. May 6, 2004

### robousy

Hi,

I have spent some time looking in Schaums, Eric Weisstein and google for the answer but cannot find it so I thought i'd see if anyone here could.

I would like to find the second derivative or |x| please. (wrt x).

I think there are some delta functions in there but would like to see where they come from.

Richard

2. May 6, 2004

### fourier jr

Think about it geometrically, abs(x) looks like f(x) = x for x>0 and f(x) = -x for x<0. So f'(x) = 1 for x>0 and f'(x) = -1 for x<0. The derivative of any constant is 0. So f''(x) = 0 for f = abs(x). I think the easiest way to prove it rigourously would be to use the Mean Value Theorem.

3. May 7, 2004

### robousy

Hmmm, thanks for the response.

I'm reverse engineering a sakurai quantum mechanics problem involving this derivative and have found the the answer definately contains a delta function - i.e by seeing the corrrect working I know it contains this. I just want to understand it now.

4. May 7, 2004

### matt grime

|x| isn't differentiable (everywhere) so you must specify the domain, and if you want to include 0 then you're stuck.

5. May 7, 2004

### Zurtex

While bored one lesson I'm sure I ended up proving:

Where:

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

Then:

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

Is this wrong?

6. May 7, 2004

### Hurkyl

Staff Emeritus
What happens to your proof when g(x) = 0 and g'(x) != 0?

7. May 8, 2004

### Zurtex

Erm what? Well if g(x) = 0 then:

$$f'(x) = g'(x) \frac{0}{0}$$

Which is undefined right? Surely that makes sense as the change of the curve at that point is undefined. I'd be really interested to see if I got this right or not.

8. May 8, 2004

### Hurkyl

Staff Emeritus
The derivative of |x^3| does in fact exist at x = 0.

BTW, I thought you were refuting that the derivative of the abs function is somewhere nondifferentiable, so I withdraw my implication.

9. May 8, 2004

### HallsofIvy

For x> 0, |x|= x so "locally" (close to x so we are still looking only at positive numbers) |x| is the same as x and has the same derivative: 1
(You do need x> 0 so that |x|= x is true on both sides of x.)
For x< 0, |x|= -x so "locally" |x| is the same as -x and has the same derivative: -1.

Now look at x= 0 ) (|0+h|- |0|)/h= |h|/h which is 1 if h> 1 and -1 if h< 1. That is, the limit "from above" is 1 and the limit "from below" is -1. Since those two are not the same, the limit itself does not exist: |x| is not differentiable at x= 0.
That is, the derivative of |x| is 1 for x>0, -1 for x< 0 and not defined for x=0.
(A variation of the "Heavyside function" which is defined as "0 for x< 0, 1 for x> 0, not defined for x= 0".)
The second derivative is easy: Since the first derivative is a constant (1) for all x>0, the second derivative there is 0. Since the first derivative is a constant (-1) for all x< 0, the second derivative there is 0. Since the first derivative is not defined for x=0, the second derivative is not either.

That's all in terms of ordinary functions. Since you mention the Dirac delta function, you are actually talking about "distributions" (also called "generalized functions").
Although the derivative of the absolute value is not defined at 0, since that is only one point, we can talk about integrating it: let f(x) be "-1 for x< 0, 1 for x> 0, not defined for x= 0"- that is, the derivative of |x|. For any continuous function g(x), The integral, from -a to X (-a a fixed negative number, X a variable), of f(x)g(x), is simply the integral of -g(x) from -a to 0 plus the integral of g(x) from 0 to X. Since f(x) is not continuous at 0, the integral is not continuous at 0: there is a jump in the value of the integral at 0. It is easy to calculate that that jump is exactly g(0). If we were to calculate the derivative at x, we would find that the derivative is 0 at every x except 0 and is g(0) at x= 0. That is precisely the definition of the Dirac delta function.

10. May 8, 2004

### Zurtex

Oh right o.k , well err I never thought about that one. Are you sure it does exist at 0? I've not got access to any graphical tools on my home computer but other than at x=0 my formulae still works. As it gives that:

$$\frac{d}{dx} \left( \left|x^3 \right| \right) = 3\frac{\left|x^3 \right|}{x}$$

Oh well never mind, there goes my idea lol. I might try and work it out again from first principles, see if I missed something.

Last edited: May 8, 2004
11. May 8, 2004

### matt grime

simple exercise for the reader: if f is continuous at 0, then g(x) = x|f(x)| is differentiable at 0.

12. May 8, 2004

### Gokul43201

Staff Emeritus
The derivative you want is a dirac-delta at the origin. That's what Physicists are most happy with when differentiating a step function.

Think of the first derivative as the limiting case of a function that is defined as :
(i) f(x) = 1, x > x0, x0 > 0
(ii) f(x) = -1, x < -x0,
(iii) f(x) is an s-shaped curve from (-x0,-1) to (x0,1) passing thru' O,

The second derivative is thus a bell shaped curve from -x0 to x0.
And when you make x0 --> 0, you get the dirac-delta.

13. May 8, 2004

### Zurtex

matt grime sorry I don't know what your talking about

But my formulae thing might still work:

$$\frac{d}{dx} \left( \left|x^3 \right| \right) = 3x^2 \frac{ \left| x^3 \right| }{x^3}$$

$$\frac{d}{dx} \left( \left|x^3 \right| \right) = 3\frac{\left|x^3 \right|}{x}$$

$$\frac{d}{dx} \left( \left|x^3 \right| \right) = 3\frac{|x|x^2}{x}$$

$$\frac{d}{dx} \left( \left|x^3 \right| \right) = 3|x|x$$

Yey!

14. May 8, 2004

### matt grime

gokul, i hope you aren;'t trying to say that |x| is differentiable at the origin. it isn't.

and zurtex, rather than relying on intuition and/or a graphical calculator why don't you just work out the derivative properly? The limit as h tends to zero of (f(x+h)-f(x))/h, which is after all the definition of derivative, and shows that |x| is not differentiable at the origin since the limit is not well defined.

15. May 8, 2004

### Zurtex

My formulae is not intuition, I remember working it out from:

$$|x| = + \sqrt{x^2}$$

And then some very careful use of the chain rule.

P.S. Been meaning to ask if it was right for quite some time but kept forgetting.

16. May 8, 2004

### matt grime

well, according to your formula, you appear to claim that things are differentiable (at 0) when they aren't; do it from first principles as you mentioned you were going to do and you'll get the answer for all x, not just those points where it works; you need to examine the parts where the function is zero very carefully, but the simple proof that if f is continuous at the origin, then xf(x) is differentiable there can be of some help. you make no restrictions on where your formula is valid, and thus appear to claim |x| is differentiable at 0, when it isn't, but |x|^3 is, with the derivative as you've worked out.

17. May 8, 2004

### Gokul43201

Staff Emeritus
Matt,

|x| is strictly not differentiable at x=0. But for physical systems that exhibit step function like behavior, the derivative looks like a spike at the stepping point. Physicists call this the dirac-delta function, and define it as the derivative of the step function, because they can not accept "undifferentiable" if the derivative is a physical thing. Google 'dirac-delta' to see more about this function.

Robousy,

If you are solving Sakurai problems, I'm assuming you've gone through more elementary texts like Jackson or Griffiths (E&M). You should have come across dirac-deltas in there, in solving charge density based problems for point charges.

18. May 8, 2004

### Zurtex

Sorry but I am getting really confused. Where have I said that |x| is differentiable at 0? In fact if you use my assume my formulae is correct then it is not!

I'll have a look over the maths, but are you saying my formulae is wrong and if so why?

19. May 8, 2004

### matt grime

Gokul, I am pefectly aware of the dirac delta distribution, however mod(x) doesn't display step like properties so that information is useless, unless you wish to clarify for me what you mean by 'step like', and the delta is not a spike, though it is in approximations a limit of spikes. so what do you think a physicist would define the derivative of mod(x) to be? In you limit case you didn't state what the limit would be, but we can imagine it to be -1,0,1 for x strictly negative, zero, and strictly positive respectively.

Zrutex, in post five if we subs in g(x)=x, then we get that undefined thing, right? but later you use it to work out the derivative of |x|^3, which still has an undefined thing at the origin but is still differentiable there, so which do you want to claim? that the derivative is always undefined for g(x)=0? cos it isn't. you need to clear up these cases; the formula as is is not correct becuase you're omitting the 'interesting' cases. you're correct for the points where g is not zero, since f is either g or -g in some neighbourhood of such point.

20. May 8, 2004

### Zurtex

Sorry if this seems like I am hijacking somebodies post, if so just say so and I will make a new thread, but this really does seem relevant. Now here is my working please say if I am wrong:

\begin{align*} f(x) = |x| = +\sqrt{x^2} \\ \\ f'(x) = \frac{ \frac{1}{2} 2x}{+\sqrt{x^2}} \\ \\ f'(x) = \frac{x}{|x|} \end{align*}

Whoops looks like I got x and |x| the wrong way around in my previous post. But if we carry this on, where:

$$y = fg(x)$$

Then by chain rule:

$$y' = g'(x)f'g(x)$$

Using previous result:

$$y' = g'(x)\frac{g(x)}{|g(x)|}$$