# Math4121 Lecture 2

## Chapter 5: Differentiation

### Continue on Differentiation

#### Theorem 5.5: Chain Rule

Suppose

1. $f:[a,b]\to \mathbb{R}$ is continuous on $[a,b]$ (or some neighborhood of $x$)
2. $f'(x)$ exists at some point $x\in (a,b)$ ($f$ is differentiable at $x$)
3. $g$ is defined on an interval $[c,d]$ containing the range of $f$, ($f([a,b])\subset [c,d]$)
4. $g$ is differentiable at the point $f(x)$

Let $h=g\circ f$ ($h=g(f(x))$) where $f$ is differentiable at $x$ and $g$ is differentiable at $f(x)$. Then $h$ is differentiable at $x$ and

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

Proof:

Let $y=f(x)$ and $u(t)=\frac{f(t)-f(x)}{t-x}-f'(x)$ for $t\neq x,t\in [a,b]$, $v(s)=\frac{g(s)-g(y)}{s-y}-g'(y)$ for $s\neq y,s\in [c,d]$.

Notice that $u(t)\to 0$ as $t\to x$ and $v(s)\to 0$ as $s\to y$.

Pick $s=f(t)$ for $t\in [a,b]$ so that $s\to y$ as $t\to x$. Then

$$
\begin{aligned}
h(t)-h(x) &= g(f(t))-g(f(x)) \\
&= g(t)-g(y) \\
&= (s-y)(g'(y)+v(s)) \\
&= (f(t)-f(x))(g'(y)+v(s)) \\
&= (t-x)(f'(x)+u(t))(g'(y)+v(s)) \\
\end{aligned}
$$

So $h'(x)=\frac{h(t)-h(x)}{t-x}=(f'(x)+u(t))(g'(y)+v(s))$. Since $u(t)\to 0$ and $v(s)\to 0$ as $t\to x$ and $s\to y$, we have $h'(x)=g'(y)f'(x)$.

QED

#### Example 5.6

(a) Let $f(x)=\begin{cases}
x\sin\frac{1}{x} & x\neq 0 \\
0 & x=0
\end{cases}$

For $x\neq 0$,

$$
\begin{aligned}
f'(x) &= 1\cdot\sin\frac{1}{x}+x\cos\frac{1}{x}\cdot\frac{-1}{x^2} \\
&= \sin\frac{1}{x}-\frac{\cos\frac{1}{x}}{x}
\end{aligned}
$$

For $x=0$,

$$
\begin{aligned}
f'(0) &= \lim_{x\to 0}\frac{f(x)-f(0)}{x-0} \\
&= \lim_{x\to 0}\frac{x\sin\frac{1}{x}}{x} \\
&= \lim_{x\to 0}\sin\frac{1}{x}
\end{aligned}
$$

This limit does not exist, so $f$ is not differentiable at $x=0$.

(b) Let $f(x)=\begin{cases}
x^2 \sin\frac{1}{x} & x\neq 0 \\
0 & x=0
\end{cases}$

For $x\neq 0$,

$$
\begin{aligned}
f'(x) &= 2x\sin\frac{1}{x}+x^2\cos\frac{1}{x}\cdot\frac{-1}{x^2} \\
&= 2x\sin\frac{1}{x}-\cos\frac{1}{x}
\end{aligned}
$$

For $x=0$,

$$
\begin{aligned}
f'(0) &= \lim_{x\to 0}\frac{f(x)-f(0)}{x-0} \\
&= \lim_{x\to 0}\frac{x^2\sin\frac{1}{x}}{x} \\
&= \lim_{x\to 0}x\sin\frac{1}{x}\\
&= 0
\end{aligned}
$$

So $f'(x)=\begin{cases}
2x\sin\frac{1}{x}-\cos\frac{1}{x} & x\neq 0 \\
0 & x=0
\end{cases}$.

Notice that $f'(x)$ is not continuous at $x=0$ since $\lim_{x\to 0}f'(x)$ is undefined.

### Mean Value Theorem

#### Definition 5.7: Local Extrema

Let $f:[a,b]\to \mathbb{R}$. We say that $f$ has a local maximum (or minimum) at $x\in [a,b]$ if there exists some $\delta>0$ such that 

$$
f(x)\geq f(t) \text{ for all }|x-t|<\delta
$$

for local maximum, and

$$
f(x)\leq f(t) \text{ for all }|x-t|<\delta
$$

for local minimum.

#### Theorem 5.8

If $f:[a,b]\to \mathbb{R}$ has a local maximum (or minimum) at $x\in (a,b)$ and $f$ is differentiable at $x$, then $f'(x)=0$.

Proof:

We can find $\delta>0$ such that $a<x-\delta<x<x+\delta<b$.

And for all $x-\delta<t<x+\delta$,

If $x-\delta<t<x$, then $f(x)\geq f(t)$ so $\frac{f(t)-f(x)}{t-x}\leq 0$.

If $x<t<x+\delta$, then $f(x)\geq f(t)$ so $\frac{f(t)-f(x)}{t-x}\geq 0$.

So $\lim_{t\to x}\frac{f(t)-f(x)}{t-x}=0$.

QED
