6
$\begingroup$

In high school Calculus a few weeks ago we were given the following problem - it has haunted me ever since and I finally decided to ask about it here:

$$f(x) = \left\{\begin{array}{ll} 2x^2+x+1\ &\text{if }x\leq 0,\\ ax+b &\text{if }x>0. \end{array}\right.$$

1. Determine the values of $a$ and $b$ such that $f$ is continuous for all x-values.

2. Determine the values of $a$ and $b$ such that $f$ is differentiable for all x-values. (Hint/reminder: for $f$ to be differentiable, both $f$ and $f'$ must be continuous.)


Part 1 was easy and I believe I understand why it works. And clearly $b=1$ because that's the solution to $a(0)+b = 2(0)^2+0+1$.

Part 2 was conceptually much more difficult. The first issue is that the statement in the question that "for $f$ to be differentiable ... $f'$ must be continuous" is demonstrably false. Being the math nerd that I am, I remembered quickly that in fact the function $f(x)=x^2\sin(1/x)$, where $f(0)=0$, is differentiable at $x=0$ but nevertheless $f'$ is NOT continuous there.

The second tricky thing is that even though my teacher's premise was apparently false, the solution they derived from that premise was apparently correct! (or at least I have no reason to believe it was incorrect) Specifically, they set the derivative at $x=0$ of the top expression, $4(0)+1$, equal to that of the bottom expression, $a$, and quickly found $a=1$ ($b$ is, of course, still 1 as well).

That's a really nifty trick -- just set the derivatives of the two expressions equal to one another and solve. So at this point I'm super confused. Assuming the method my teacher used did in fact work, why did it work?

Furthermore, when researching this topic I came across the idea of right and left-hand derivatives. My understanding is that those two terms are related to, but distinct from, the left and right-hand limits of the derivative function at a point. In other words, my understanding is that the left derivative at $x=a$ is defined as....

$$f'_{-}(a)=\lim_{h\to 0^-}\frac{f(a+h)-f(a)}{h}$$

... while the limit of the derivative function as $x$ approaches $a$ from the left is simply... $$\lim_{x\to a^-}f'(x)$$

Am I correct that there's a difference between those two concepts (and, regardless, does it matter to my ultimate inquiry?)

I am aware that others have asked somewhat similar questions here in the past (e.g. here and here). However, the answers I have seen either gloss over things I'm confused about or otherwise have not helped me achieve full understanding.

I'll note, lastly, that I've also tried to think about this problem graphically. I suppose that has shown me that the teacher's solution was somewhat sensible (it did give me an intuitive idea that the "slopes" need to "match" on each side), but it has not completely convinced me in the way a formal justification would. Furthermore, oftentimes it just takes me back in circles to the difference (if any) between a right-hand derivative and the right-hand limit of the derivative function.

$\endgroup$
10
  • 1
    $\begingroup$ First off, if a function is not clearly differentiable, you can't use $f'$. It may not be defined. So I have no idea as to what 2. of the question means. $\endgroup$ Oct 19, 2019 at 4:40
  • 1
    $\begingroup$ "Am I correct that there's a difference between those two concepts (and, regardless, does it matter to my ultimate inquiry?)" Yes, you are right. The second limit might not even exist while the first one does (as your example $x^2\sin(1/x)$ shows). $\endgroup$
    – amsmath
    Oct 19, 2019 at 4:46
  • 1
    $\begingroup$ I think what should have been said for part 2 is that in order for $f$ to be differentiable, it is sufficient that $f$ and $f'$ are both continuous. What was actually written is that it is necessary that $f$ and $f'$ are both continuous, which is a very different claim and (as you found) a false claim. $\endgroup$
    – David K
    Oct 19, 2019 at 5:03
  • 1
    $\begingroup$ The teacher's trick worked because the left and right functions are both differentiable everywhere, so for the piecewise function to be differentiable the left and right quotient limits must be equal. $\endgroup$
    – copper.hat
    Oct 19, 2019 at 5:15
  • 1
    $\begingroup$ Because the left-hand limit of the derivative doesn't exist but the left derivative does. $\endgroup$
    – David K
    Oct 19, 2019 at 12:34

1 Answer 1

6
$\begingroup$

For continuity, the only point of concern is $x=0$ and we need $\lim_{x \uparrow 0} f(x) = 1 = \lim_{x \downarrow 0} f(x) = b$.

Hence $f$ is continuous everywhere iff $b=1$.

Since $f_-(x)= 2x^2+x+1$ and $f_+(x)= ax+b$ are both smooth everywhere, the only way that $f$ can fail to be differentiable at $x=0$ is if $f_-'(0) \neq f_+'(0)$.

Hence we need $f_-'(0) = 1 = f_+'(0) = a$.

It is not true in general that $f'$ needs to be continuous. In fact, $f'$ may only exist at one point. For example, take $f(x) = x^2 1_\mathbb{Q}(x)$ (indicator function of the rationals multiplied by $x^2$), then $f$ is differentiable at $x=0$ but is not even continuous for $x \neq 0$.

In general, if one has $f_-$ and $f_+$ (defined for $x \le 0$ and $x>0$), then to be differentiable at $x=0$ we need $\lim_{x \uparrow 0} f_-(x) = f_-(0) = \lim_{x \downarrow 0} f_+(x)$ (this is just continuity) and $\lim_{h \uparrow 0} {f_-(h) - f_-(0) \over h} = \lim_{h \downarrow 0} {f_+(h) - f_-(0) \over h}$.

In the above case, these two limits are just $f_-'(0), f_+'(0)$.

Answer to questions in comments:

In general, suppose we are given $f$ defined as $f_1$ for $x \le 0$ and $f_2$ for $x>0$.

Note that the value of $f$ at $x=0$ is $f_1(0)$. (Here, $0$ is not even in the domain of $f_2$.)

Then $f$ is differentiable at $x=0$ iff the following two limits exist and are equal: $$ \lim_{h \uparrow 0} {f_1(h)-f_1(0) \over h} \ \ \ \ \ \ \ \ \lim_{h \downarrow 0} {f_2(h)-f_1(0) \over h} $$ Note that the value at $x=0$ is $f_1(0)$ in both cases.

Now suppose further that there are two functions $g_1,g_2$ that are differentiable at $x=0$ (that is, two usual sided derivatives at $x=0$), and that $f_1(x)=g_1(x)$ for $x \le 0$ and $f_2(x)=g_2(x)$ for $x>0$. (Note that since $g_1,g_2$ are differentiable at $x=0$ then they are continuous at $x=0$.)

Then the above limit conditions are equivalent to showing $g_1(0) = g_2(0)$ and $g_1'(0) = g_2'(0)$.

Note that to conclude this, we only need $g_1,g_2$ to be differentiable at $x=0$. It is not necessary to have anything like $C^1$.

$\endgroup$
23
  • 1
    $\begingroup$ It does explain why. Read the last two paragraphs. Carefully. $\endgroup$
    – copper.hat
    Oct 19, 2019 at 14:56
  • 1
    $\begingroup$ The intuition is straightforward, the slope from the right and the slope from the left must match. However, the rest is technical detail, so I'm not sure what you are expecting there. If you have specific questions about the above please ask. However, it is difficult to elaborate unless you are more specific. $\endgroup$
    – copper.hat
    Oct 19, 2019 at 15:07
  • 1
    $\begingroup$ @Will: It means the limit as $h \to 0$ and $h \ge 0$, so the limit from the right. It is just the slope 'viewed' from the $x\ge 0$ perspective. $\endgroup$
    – copper.hat
    Oct 19, 2019 at 15:25
  • 1
    $\begingroup$ Well, that was the point of my previous comment. $f_+$ on only defined (in this context) for $x>0$. So $f_+(0)$ is not defined. That is why you need the limit mentioned in that comment to hold. (Essentially, you need to be able to extend the domain of $f_+$ to include $0$) $\endgroup$
    – copper.hat
    Oct 19, 2019 at 15:54
  • 1
    $\begingroup$ But to answer your question, there is no typo. $\endgroup$
    – copper.hat
    Oct 19, 2019 at 15:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .