Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I while back, my calculus teacher said something that I find very bothersome. I didn't have time to clarify, but he said:

If a function is discontinuous, automatically, it's not differentiable.

I find this bothersome because I can think of many discontinuous piecewise functions like this:

$$f(x) = \begin{cases} x^2, & \text{$x≤3$} \\ x^2+3, & \text{$x>3$} \end{cases}$$

Where $f'(x)$ would have two parts of the same function, and give: $$\begin{align} f'(x) = && \begin{cases} 2x, & \text{$x≤3$} \\ 2x, & \text{$x>3$} \end{cases} \\ = && 2x \end{align}$$

So I'm wondering, what exactly is wrong with this? Is there something I'm missing about what it means to be "continuous"? Or maybe, are there special rules for how to deal with the derivatives of piecewise functions, that I don't know about.

share|cite|improve this question

marked as duplicate by Mark S., Charles, Jack's wasted life, Joel Reyes Noche, Jon Mark Perry Mar 25 at 14:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Differentiability $\implies$ Continuity, so $\neg$Continuity $\implies$ $\neg$Differentiability. In your case, the derivative of $f$ does not exist at $x = 3$. (Plot a graph to see this) Even if the derivatives nearby agree. – Henry W. Mar 24 at 18:52
"Or maybe, are there special rules for how to deal with derivatives of piecewise functions, that I don't know about" Yes! You can do piecewise differentiation as you do, but you have to verify differentiability at the changepoints. – Wouter Mar 24 at 18:57
Acceleration is the differential of speed. You're traveling in your car, going faster and slower. At time T+s1, you suddenly have no speed (you don't exist in the universe?). At time T+s2, you suddenly have a speed again (you came back?). What is your acceleration at T+s1 and T+s2? You didn't accelerate/decelerate to 0 speed, you stopped having a speed at all. – ErikE Mar 25 at 15:57
up vote 24 down vote accepted

Let's look at your function.

$$f(x) = \begin{cases} x^2, & \text{$x≤3$} \\ x^2+3, & \text{$x>3$} \end{cases}$$

Clearly, the only interesting point is when $x = 3$. So let's see differentiability at $3$. Then we look at

$$ \frac{f(3+h) - f(3)}{h} = \frac{(3+h)^2 + 3 - 3^2}{h} = \frac{3 + 6h + h^2}{h}.$$ As $h \to 0$ (from the right), you can see that this last term goes to $\infty$, and so the function is not differentiable at $3$.

If you think about it, this makes sense. The derivative gives the best local linear approximation, and the rate of change at $3$ isn't defined --- it's a jump discontinuity, and there is no tangent line there.

Do you now see where you went wrong?

share|cite|improve this answer
+1 for what I should have done. I was trying for the visual explanation that I used to use in class, but without graphs to show $\ldots$ – Dave L. Renfro Mar 24 at 19:00
Yes! That makes perfect sense. Thanks – samarbarrett Mar 24 at 19:06
Also note that you have to do the left limit differently, and it will give you o different answer (which makes it doubly nonexistent.) – PyRulez Mar 24 at 22:30

Flagrantly ignoring your specific example: suppose a function $f$ is differentiable at a point $x$. Then by definition of differentiability:

$$\lim_{h\rightarrow0}\frac{f(x+h) - f(x)}{h}$$

must exist (and by this notation I mean the limits exist in both the positive and negative directions and are equal). Since the bottom of that fraction approaches $0$, it's necessary for the top also to approach $0$, or else the fraction diverges. But the top approaching $0$ is just the definition of $f$ being continuous at $x$. So a function that isn't continuous can't be differentiable.

So, your example fails to be differentiable for the same reason that it fails to be continuous, which is that top of that fraction tends to $3$, not $0$, when approached from the positive direction.

share|cite|improve this answer
+1: I think this is the only fully correct answer, as it addresses the general case. Showing that the example non-discontinuous function is not differentiable does not prove (not even in a weak way) that there must not be any differentiable non-continuous function – Rolazaro Azeveires Mar 25 at 10:04

The problem is when you gave the derivative for $x \leq 3.$ What you gave is correct for $x < 3,$ but not for $x=3.$ Consider secant slopes to nearby points with one point fixed at $(3,9),$ which is what the definition of the derivative requires. Looking to the left, you get secant slopes that converge to $6$ as you approach the fixed point $(3,9).$ But looking to the right you get secant slopes that approach $+\infty$ as you approach the fixed point $(3,9).$

share|cite|improve this answer

The derivative depends of the behavior of the function in a neighborhood of the point. In this case, you can only say $$ f'(x) = \begin{cases} 2x, & x<3\\ 2x, & x>3 \end{cases}\\ = 2x,\qquad x\ne 3. $$ And $f'(3)$ does not exist.

share|cite|improve this answer

Draw the picture. To the left of the vertical line $x=3$ you see half of a parabola that opens upward. To the right you see half of another parabola that opens upward, but it is vertically shifted. That means there is no slope of the curve at that point. The slope approaches the same thing on either curve as you approach that vertical line, and that is what you've shown. But look at the vertical jump at that point.

Suppose that as $x\to3$ we have $$ \frac{f(x) - f(3)}{x-3} \to L $$ so that $f'(3)=L$. Then \begin{align} \lim_{x\to 3} (f(x)-f(3)) & = \lim_{x\to 3} \left( (x-3) \frac{f(x)-f(3)}{x-3} \right) \\[10pt] & = \left( \lim_{x\to 3} (x-3) \right) \left( \lim_{x\to 3} \frac{f(x)-f(3)}{x-3} \right) = 0 \cdot L \\[6pt] & \qquad\qquad (\text{where } L = f'(3) ) \\[10pt] & = 0, \end{align} which would imply $f(x)\to f(3)$, so that $f$ is continuous at $3$. Hence if $f'(3)$ exists, then $f$ is continuous at $3$.

share|cite|improve this answer

Your idea of continuity is fine but your idea of differentiable has a niave and easy to make oversight.

$f$ is differentiable at $x$ if the following limits exist and are equal:

1) $\lim_{x_0\rightarrow x^+}\frac{f(x_0) - f(x)}{x_0 - x} = \lim_{h\rightarrow 0}\frac{f(x+h) - f(x)}{h}$.

2)$\lim_{x_0\rightarrow x^-}\frac{f(x) - f(x_0)}{x - x_0} = \lim_{h\rightarrow 0}\frac{f(x) - f(x-h)}{h}$.

In your function the second limit is fine: $\lim_{x_0\rightarrow 3^-}\frac{f(3) - f(x_0)}{3 - x_0} = \lim_{h\rightarrow 0}\frac{f(3) - f(3-h)}{h}= (9^2 - 9^2 + 2*3h - h^2)/h = 6$.

But the first limit is screwed: $\lim_{x_0\rightarrow 3^+}\frac{f(x_0) - f(3)}{x_0 - 3} = \lim_{h\rightarrow 0}\frac{[f(3+h)] - f(3)}{h} = ([(3+h)^2 + 3] - 3^2]/h = [(9 + 6h + h^2 + 3) - 9]/h = (3 + 6h + h^2)/h = \infty.$

share|cite|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.