11

The question here asks:

Given that $f$ and $g$ are two real functions and both are differentiable, is it true to say that $h=max(f,g)$ is differentiable too?

Convincing arguments have been presented there that the answer is No.

So, how about a slightly weaker question: Given that $f$ and $g$ are two real, differentiable functions, is it always true that $h=max(f,g)$ is piecewise-differentiable?

(For the purposes of this question, 'piecewise' is to be taken as user86418 defined it in a comment: "The domain can be divided into subintervals so that the set of endpoints is discrete", i.e., "each endpoint is isolated in the set of endpoints." Further, the set of endpoints may or may not be finite.)

hBy2Py
  • 337
  • 3
  • 17
  • 1
    What do you mean by "piecewise"? In the sense: do you want the set of points where the derivative fails to exist to be finite? –  Apr 22 '15 at 19:12
  • @G.Sassatelli or presumably countably infinite. – Matt Gutting Apr 22 '15 at 19:18
  • 1
    @G.Sassatelli A countably infinite number of such points is fine [e.g., $h(x) = max(cos(x), sin(x))$]. – hBy2Py Apr 22 '15 at 19:31
  • Math is not my background, so I'm open to suggestions for better terms than 'piecewise differentiable' for what I'm looking for -- I will gladly revise the question if you all can help me identify a more precis term for what I'm envisioning. – hBy2Py Apr 22 '15 at 19:33
  • 4
    @Brian: In my experience, "piecewise" usually means "the domain can be divided into subintervals so that the set of endpoints is discrete", i.e., "each endpoint is [isolated](https://en.wikipedia.org/wiki/Isolated_point) in the set of endpoints". With that definition, the answer is still **no**: If $f(x) = x^{2} \sin(1/x)$, $f(0) = 0$, and $g(x) = 0$, then their maximum fails to be differentiable at a set of points having $0$ as a limit point. – Andrew D. Hwang Apr 22 '15 at 20:10
  • Let's go with that definition of 'piecewise,' I think it captures what I'm picturing. Is $f(x) = x^2 \mathrm{sin}(1/x)$ itself a differentiable function, though? Doesn't its being undefined at $x=0$ disqualify it? – hBy2Py Apr 22 '15 at 20:20
  • @Brian: We explicitly define $f(0) = 0$. :) This $f$ is the standard example of an everywhere-differentiable function with discontinuous derivative. (One has to use the difference quotient to prove $f'(0)$ exists.) – Andrew D. Hwang Apr 22 '15 at 22:11
  • @user86418 Ahhhh, now I see, you're explicitly declaring $f(x)$ as a piecewise-defined function. Didn't catch that. – hBy2Py Apr 23 '15 at 00:13
  • @Brian: Regarding the new wording: 1. The same oscillatory example shows that the intervals' endpoints (in the domain of $h'$) can "accumulate" in the technical sense, so the answer is still "no". :) 2. Even if $h$ _is_ differentiable everywhere, its derivative needn't be piecewise continuous. (It may be important to note that _piecewise continuity_ of a function $F$ usually comes with a condition in addition to "isolated endpoints": One requires $F$ to have one-sided limits at each discontinuity.) – Andrew D. Hwang Apr 23 '15 at 00:51
  • Aaaand, this shows how completely out of my depth I am. :-) I hesitated posting this question for exactly this sort of reason -- I know how little I know about formal mathematics. Thank you for your time! – hBy2Py Apr 23 '15 at 00:56

4 Answers4

9

With the indicated definition of "piecewise", the answer is no: If $g$ is the zero function and $$ f(x) = \begin{cases} x^{2} \sin(1/x) & \text{if $x \neq 0$,} \\ 0 & \text{if $x = 0$,} \end{cases} $$ (which is well-known to be everywhere-differentiable), then their maximum, $$ \max(f, g)(x) = \frac{f(x) + \left|f(x)\right|}{2} $$ fails to be differentiable at each point $x$ with $\sin(1/x) = 0$, namely for $x_{n} = 1/(n\pi)$ with $n \neq 0$ an integer, since $f'(x_{n}) \neq 0 = g'(x_{n})$. (Vertical scale below exaggerated for clarity.)

A maximum of differentiable functions that is not piecewise-differentiable

Since the set of "corners", $$ E = \{1/(n\pi) : n \neq 0\}, $$ has $0$ as a limit point, $\max(f, g)$ is not piecewise-differentiable.

Andrew D. Hwang
  • 74,491
  • 5
  • 90
  • 177
  • @Brian: That's okay. :) But if I understand your revised intent, the same function is still a counterexample: The domain of $h'$ is a union of open intervals whose endpoints accumulate at $0$. – Andrew D. Hwang Apr 23 '15 at 00:52
  • Mmm... because the spacing between $E\{n\}$ goes to zero as $n \rightarrow \infty$? – hBy2Py Apr 23 '15 at 00:53
  • I de-revised the question, sorry for the back and forth. – hBy2Py Apr 23 '15 at 00:53
  • 3
    1. Yes, exactly. (If necessary, we can arrange more pathological behavior.... :) 2. This is the reality of mathematical exploration and discovery; it takes trial and error. Lecturers and textbook authors make it look easy, but formulating one's thoughts precisely can be tricky. So, no need to apologize. – Andrew D. Hwang Apr 23 '15 at 00:57
  • Wow, I definitely thought the answer to this was yes. Nice answer! – Cruncher Apr 23 '15 at 13:33
4

Suppose $f,g : \mathbb {R}\to \mathbb {R}$ are differentiable and $E$ is the set of points where $\max(f,g)$ is not differentiable. Then every point in $E$ is isolated in $E.$ In particular, $E$ is countable. Furthermore, the right derivative and left derivative of $\max(f,g)$ exist at every point of $E$ (hence at every point of $\mathbb {R}$).

Proof: Let's go through some cases. Suppose $f(a)\ne g(a).$ WLOG, $f(a)< g(a).$ Then by continuity, $f<g$ in a neighborhood of $a.$ Thus $\max (f,g)=g$ in a neighborhood of $a,$ which implies $\max (f,g)$ is differentiable in a neighborhood of $a.$ So such an $a$ is not in $E.$

Now suppose $f(a)= g(a).$ Two subcases: (i) $f'(a)\ne g'(a).$ WLOG, $f'(a)< g'(a).$ Then $g\ge f$ in $[a,a+\delta)$ for some $\delta > 0.$ That implies $\max (f,g)=g$ in that interval, hence $\max (f,g)$ is differentiable in $[a,a+\delta),$ with the right derivative at $a$ equal to $g'(a).$ Similarly, $\max (f,g)=f$ in some $(a-\delta,a],$ hence $\max (f,g)$ is differentiable there, with the left derivative at $a$ equal to $f'(a).$ Since the right and left derivatives at $a$ disagree, $a\in E,$ but $\max(f,g)$ is differentiable elsewhere in $(a-\delta,a+\delta).$

The other subcase is $f(a)= g(a), f'(a)= g'(a).$ Here we have a common tangent line, let's call it $l(x).$ By definition of a derivative, near $a$ we have

$$f(x) = l(x) + r(x)(x-a), g(x) = l(x) + s(x)(x-a),$$

where both $r(x), s(x) \to 0$ as $x\to a.$ It follows that

$$l(x) - |x-a|(|r(x)| + |s(x)|) \le \max (f,g)(x) \le l(x) + |x-a|(|r(x)| + |s(x)|)$$ near $a.$ This shows $\max(f,g)'(a)$ exists, so this $a\not \in E.$

Put all this together to get the claims made at the beginning of this post.

zhw.
  • 103,861
  • 6
  • 54
  • 108
  • I'm not sure which version of my question you were answering here... I edited and de-edited it in rapid succession. My apologies and thank you for your time if you responded to the now-obliterated edit! – hBy2Py Apr 23 '15 at 00:54
  • 1
    Is $\max (f,g)$ differentiable everywhere? No. Is it differentiable somewhere? Well yes, at quite a few points (see my post). You ask a question to an audience of mathematicians, and there's no telling what they might do with it. – zhw. Apr 23 '15 at 01:03
  • Perfect answer. Combined with the zero-accumulation point example, it basically answers all versions of the question. – osa Apr 23 '15 at 01:43
  • While this gives an interesting complement, it does not give an answer to any of the versions of the question, all of which mention "piecewise", and (apart from the very first version) "endpoints", and not the "points of non-differentiability", the set $E$ of this answer. Important difference: the end points in any piecewise definition _must_ be closed, as any limit point is not in the interior of any interval, so must be an endpoint itself for the function to be defined there. However the set $E$ need not be closed, and while $E$ is discrete (as proved here), $\overline E$ might not be so. – Marc van Leeuwen Apr 23 '15 at 06:47
  • So to summarize: the essential point is that this answer only shows that any point is _either_ a point of differentiability, _or_ has a neighbourhood containing no other points where differentiability fails. But there may be points where $\max(f,g)$ is differentiable (so not in $E$), but which are limit point of points of$~E$. – Marc van Leeuwen Apr 23 '15 at 06:55
2

Obviously, it depends on what you mean by "piecewise differentiable." I'll show the following:

Claim: There exists a differentiable function $f: [0,1] \rightarrow \mathbb R$, such that if $R$ is the set where the function $\max\{f,0\}$ is differentiable, $R$ cannot be written as a countable union of intervals.

I'd argue that this $f$ is therefore not piecewise differentiable, for any reasonable definition of "piecewise differentiable".

Proof of Claim:

Step 1. Constructing $f$:

For $m \geq 0$, let $\mathcal A_m$ be the space of $m$-tuples $(a_1, ..., a_m)$ where each $a_i$ is either $0$ or $2$. If $A \in \mathcal A_m$, we define the open interval $I_A = (b_A + \frac 13 3^{-m}, b_A + \frac 23 3^{-m})$, where $b_A = \sum_{i=1}^m a_i 3^{-i}$. One can check that these intervals are disjoint.

The intervals $I_A$ for $A \in \mathcal A_m$ are precisely the open intervals removed in step $(m+1)$ in the standard construction of the Cantor set. So we can set

$$C = [0, 1] \setminus \bigcup_{m=0}^\infty \bigcup_{A \in \mathcal A_m} I_A\text;$$

this is then the standard Cantor set.

We will define $f$ as follows: If $x \in C$, then we set $f(x) = 0$. Otherwise, there is a unique $m \geq 0$ and a unique $A \in \mathcal A_m$ such that $x \in I_A$. We can write $I_A = (c_A, d_A)$, where $d_A - c_A = 3^{-m-1}$. Let $z(x) = 3^{m+1}(x - c_A)$, and let $f(x) = 3^{-2m-2} h(z(x))$, where $h(z) = z^2 (z-1)^2 (z-1/2)$. (The precise form of $h$ doesn't matter; the properties we need are that $h(0) = h'(0) = h(1) = h'(1) = h(1/2) = 0$, and $h'(1/2) \neq 0$.)

[A less formal but more readable definition of $f$: In each of the intervals that you remove to get a Cantor set, glue in a copy of $h$ above, where the values are rescaled according to the square of the length of the interval.]

Step 2. Check that $f$ is differentiable:

In the interior of each $I_A$, it is clear that $f$ is differentiable, since it is defined as a composition of differentiable functions. So we only need to check that $f$ is differentiable at each point in $C$. In fact, I claim that $f'(x) = 0$ whenever $y \in C$:

To show this, we will prove that $\lvert f(x)\rvert \leq (x-y)^2$ for all $x \in [0,1]$. To see this, suppose that $x \in I_A$, where $A \in \mathcal A_m$ for some $m$. (If not, then by definition $f(x) = 0$, and the inequality is obviously true.) Again, write $I_A = (c_A, d_A)$. Certainly, $\lvert x-y\rvert \geq d$, where $d = \min \{x-c_A, d_A - x\}$ is the distance from $x$ to the boundary of $I_A$. Referring to $z(x)$ from the definition of $f$, it follows that $\lvert x-y\rvert \geq 3^{-m-1} \min\{z(x), 1 - z(x)\}$. For $0 \leq z \leq 1$, it is easy to check that $\lvert h(z)\rvert \leq (\min \{z, 1-z\})^2$. Piecing everything together, the definition $f(x) = 3^{-2m-2} h(z(x))$ gives $\lvert f(x)\rvert \leq (x-y)^2$.

From this inequality, the definition of the derivative quickly shows that $f'(y) = 0$.

Step 3. The set where $\max\{f, 0\}$ is not differentiable:

Let $g = \max\{f, 0\}$. Let $S$ be the set of midpoints of the intervals $I_A$, for $A \in \bigcup_{m=0}^\infty \mathcal A_m$. I claim if $x \in S$, then $g$ is not differentiable at $x$.

This is pretty easy to check. In fact, if $x$ is the midpoint of $I_A$, where $A \in \mathcal A_m$, then using the chain rule, we can check that $f'(x) = 3^{-m-1} h'(1/2) = 3^{-m-1}/4$. This will be the right derivative of $g$ at $x$, whereas the left derivative will be zero, so $g$ is not differentiable at $x$.

Step 4. The set of points where $g$ is differentiable cannot be written as a countable union of intervals:

Suppose that $I$ is an interval where $g$ is differentiable. Then $I$ can contain at most one point of $C$, because between any two points of $C$, there must be one of the ""removed intervals" $I_A$, and therefore one point of $S$. Since the Cantor set $C$ is uncountable, this shows that $[0,1] \setminus S$ cannot be written as the union of such intervals.

ZH Liu
  • 511
  • 2
  • 4
1

There's a theorem that says that if $f(x)$ is monotonically increasing, then it's differentiable almost everywhere, which for your purposes suffices to be called "piece-wise" differentiable [really it's differentiable at almost any location but not necessarily on intervals]. So the statement should be true for functions $f,g$ which are of bounded variation since they can be written as the difference of monotonically increasing functions.

Alex R.
  • 32,263
  • 1
  • 37
  • 76
  • I don't agree that almost everywhere corresponds well with "piecewise". A monotonic function might not be differentiable on any interval, whereas by piecewise we generally want countable number of intervals where the property holds, where those intervals cover all but a discrete collection of points. – user24142 Apr 22 '15 at 19:20
  • @user24142: you're absolutely right but, I'm guessing OP isn't familiar with the concept of "almost-everywhere" in a rigorous sense. – Alex R. Apr 22 '15 at 19:33
  • @AlexR. is absolutely correct. Please help me select a better term. – hBy2Py Apr 22 '15 at 19:33
  • Interesting answer! I have a [related question](https://math.stackexchange.com/q/2713384/167226) and would be very happy if you could have a look at it. It seems to me that the answer is quite direct consequence of your observation but I'd be very happy if you could confirm. – idm Mar 29 '18 at 15:36