Calculus – Differentiability of |cos x|

calculuscontinuityderivativesfunctions

I don't know if I understand differentiability and continuity. So by my understanding, if a function is continuous at a point, it may or may not be differentiable at that point; but if it isn't continuous at some point, then it can't be differentiable at that point. So for functions I can first test the continuity, then the differentiability. If a function is continuous at that point I can use the differentiation rules, if I am not allowed to test continuity first, then I have to do it by definition of a derivative.

For $f(x)=\lvert\cos x\rvert$, that function is continuous on all $\mathbb R$, but we have to check at a point $x= \pi/2$, since the absolute value is $0$ there, and check it by definition. I don't quite understand is the function differentiable or not. When find the right and left derivative, they turn out the same to me, but in my answer sheet it says it isn't for $\pi/2$.

Best Answer

  1. Yes, there is a theorem which says that if a function $f$ is differentiable at some point in its domain, then it is continuous at that point. However, this is not a very useful result for checking differentiability—it is useful for showing that a function is not differentiable (i.e. if $f$ is discontinuous at $a$, then $f$ is certainly not differentiable at $a$). This theorem is a bit of a red herring with respect to the function defined on $\mathbb{R}$ by the formula $$f(x) = \lvert \cos(x)\rvert,$$ since $f$ is continuous on $\mathbb{R}$.

    Indeed, it isn't too hard to see that $f$ is continuous: there is a another theorem which states that the composition of continuous functions is continuous, and $f$ is the composition of the functions $g$ and $h$, given by the formulae $$ g(x) = \lvert x \rvert \qquad\text{and}\qquad h(x) = \cos(x) $$ (that is, $f = g\circ h$). Both $g$ and $h$ are continuous, so $f$ is continuous as well.

    But, again, continuity is a bit of a red herring here.

  2. The cosine function is periodic with period $2\pi$, from which it follows that the function $f$, defined by $f(x) = \lvert \cos(x)\rvert$, is $2\pi$-periodic. Thus, in order to determine the differentiability of $f$ on $\mathbb{R}$, it is sufficient to show that it is differentiable on the closed interval $[0,2\pi]$.

    • if $x \in [0,\pi/2) \cup (3\pi/2,2\pi]$, then $\cos(x) > 0$, from which it follows that \begin{align*} f(x) = \lvert \cos(x) \rvert = \cos(x) \implies f'(x) = \frac{\mathrm{d}}{\mathrm{d}x} \cos(x) = \sin(x). \end{align*}

    • if $x \in (\pi/2,3\pi/2)$, then $\cos(x) < 0$, from which it follows that \begin{align*} f(x) = \lvert \cos(x) \rvert = -\cos(x) \implies f'(x) = -\frac{\mathrm{d}}{\mathrm{d}x} \cos(x) = -\sin(x). \end{align*}

    • if $x = \pi/2$ or $x = 3\pi/2$, then $\cos(x) = 0$, and there is a bit of a problem using known derivatives to compute $f'$, since $\cos$ is being composed with the absolute value, which is not differentiable when $x=0$. It is not automatically true that $f$ is not differentiable, which means that something needs to be done to determine whether or not $f$ is differentiable here.

      In general, I prefer to use more elementary tools for a problem like this, so recall the definition of the derivative: if the derivative of $f$ exists, then it is given by a limit (and if that limit doesn't exist, then the derivative does not exit). Evaluating the limit (and abusing notation a bit) gives \begin{align} \lim_{h\to 0} \frac{f(\pi/2 + h) - f(\pi/2)}{h} &= \lim_{h\to 0} \frac{\lvert \cos(\pi/2+h) \rvert - \lvert \cos(\pi/2) \rvert}{h} \\ &= \begin{cases} \displaystyle \lim_{h\to 0} \frac{\cos(\pi/2+h) - 0}{h} & \text{if $0<h$, and} \\[2ex] \displaystyle \lim_{h\to 0} \frac{-\cos(\pi/2+h) - 0}{h} & \text{if $0>h$,} \end{cases} \\ &= \begin{cases} 1 & \text{if $0<h$, and} \\ -1 & \text{if $0>h$.} \end{cases} \end{align} The left-hand and right-hand limits disagree, so the limit does not exist. Therefore $f$ is not differentiable at $\pi/2$. By similar reasoning, it fails to be differentiable at $3\pi/2$, or at either of these points plus an even multiple of $\pi$.

  3. It is often helpful to look at the graph of a function when trying to work out differentiability of a function. This is not a rigorous approach, but the graph can give insight into where one should focus their attention. In the case of $\lvert \cos(x)\rvert$, the graph is given by

    enter image description here

    A differentiable function must be "smooth"—it does not have "cusps" or "corners". The graph of this function has cusps at odd multiples of $\pi/2$, which suggests that this function is not differentiable at these points. This further suggests that when trying to determine whether or not this function is differentiable, one should focus their attention on these cusp points.