%MIT OpenCourseWare: https://ocw.mit.edu
%18.100A / 18.1001 Real Analysis, Fall 2020
%License: Creative Commons BY-NC-SA 
%For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms.

\begin{theorem}
Let $f: I \to \RR$, $g:I\to \RR$ be differentiable at $c\in I$. Then,
\begin{enumerate}
    \item (Linearity) $\forall \alpha \in \RR$, $(\alpha f+g)'(c) = \alpha f'(c) + g'(c)$ .
    \item (Product rule) $(fg)'(c) = f'(c)g(c) + f(c)g'(c)$.
    \item (Quotient rule) If $g(x)\neq 0$ for all $x\in I$, then 
    \[
    \left(\frac{f}{g}\right)'(c) = \frac{f'(c)g(c) - f(c)g'(c)}{(g(c))^2}.
    \]
\end{enumerate}
\end{theorem}
\textbf{Proof}:
\begin{enumerate}
    \item We can compute this directly:
    \[
    \lim_{x\to c} \frac{(\alpha f+g)(x) - (\alpha f + g)(c)}{x-c}= \lim_{x\to c} \alpha \frac{f(x) -f(c)}{x-c} + \frac{g(x) -g(c)}{x-c} = \alpha f'(x) + g'(x).
    \]
    \item We first write
    \[
    \frac{f(x) g(x) - f(c)g(c)}{x-c} = \frac{f(x)-f(c)}{x-c}\cdot g(x) + f(c) \cdot \frac{g(x)-g(c)}{x-c}
    \]
    and use the fact that $\lim_{x\to c}g(x) = f(c)$.
    \item The quotient rule is left as an exercise to the reader.
\end{enumerate} \qed 

\begin{theorem}[Chain Rule]
Let $I_1, I_2$ be two intervals, $g:I_1\to I_2$ be differentiable at $c\in I_1$, and $f:I_2 \to \RR$ differentiable at $g(c).$ Then, $f\circ g:I_1 \to \RR$ is differentiable at $c$ and 
\[
(f\circ g)'(c) = f'(g(c)) g'(c).
\]
\end{theorem}
\textbf{Proof:} Let $h(x) = f(g(x))$ and $d = g(c)$. We want to prove that $h'(c) = f'(d) g'(c)$. Define the following
\[
    u(y) = \begin{cases}
    \frac{f(y) - f(d)}{y-x} & y\neq d \\
    f'(d) & y=d
    \end{cases} \hspace{.25cm} \text{and} \hspace{.25cm}
    v(y) = \begin{cases}
    \frac{g(x) - g(c)}{x-c} & x\neq c \\
    g'(d) & x=c
    \end{cases}.
\]
Then, 
\[
\lim_{y\to d} u(y) = \lim_{y\to d} \frac{f(y)-f(d)}{y-d} = f'(d) = u(d).
\]
Similarly, 
\[
\lim_{x\to c} v(x) = \lim_{x\to c} \frac{g(x)-g(c)}{x-c} = g'(c) = v(c).
\]
In other words, $u$ is continuous at $d$ and $v$ is continuous at $c$. Now, 
\begin{align*}
    f(y)-f(d) &= u(y) (y-d) \\
    g(x)-g(c) &= v(x)(x-c) \\
    \implies h(x)-h(c) &= f(g(x)) - f(d) \\
    &= u(g(x))(g(x)-g(c)) \\
    &= u(g(x))v(x)(x-c).
\intertext{Therefore,}
    \lim_{x\to c} \frac{h(x)-h(c)}{x-c} &= \lim_{x\to c} u(g(x))v(x) \\
    &= u(g(c))v(c) \\
    &= f'(g(c))g'(c).
\end{align*}\qed 

\noindent\underline{\textbf{Mean Value Theorem}}
\begin{definition}[Relative Maximum/Minimum]
Let $S \subset \RR$ and $f:S\to \RR$. Then, $f$ has a \vocab{relative maximum} at $c\in S$ if $\exists \delta>0$ such that for all $x\in S$, $|x-c|<\delta \implies f(x) \leq f(c).$ The definition for \vocab{relative maximum} is analogous.
\end{definition}
\begin{figure}[h]
    \centering
    \includegraphics{pics/fig08.PNG}
\end{figure}

\begin{theorem}
If $f:[a,b]\to \RR$ has a relative max or min at $c\in (a,b)$ and $f$ is differentiable at $c$, then 
\[
f'(c) = 0.
\]
\end{theorem}
\textbf{Proof}: If $f$ has a relative maximum at $c\in (a,b)$ then $\exists \delta>0$ such that $(c-\delta, c+\delta) \subset (a,b)$ and $\forall x\in (c-\delta, c+\delta)$, $f(x) \leq f(c)$. Let 
\[
x_n = c - \frac{\delta}{2n} \in (c-\delta, c).
\]
Then, $x_n\to c$ so
\[
f'(c) = \lim_{n\to \infty} \frac{f(x_n) - f(c)}{x_n-c} \geq 0.
\]

Now let 
\[
y_n = c + \frac{\delta}{2n} \in (c, c+\delta).
\]
Then, $y_n\to c$ so
\[
f'(c) = \lim_{n\to \infty} \frac{f(y_n) - f(c)}{y_n-c} \leq 0.
\]
Therefore, $f'(c) = 0$. The proof for relative minimum is similar and thus left to the reader. \qed 

\begin{theorem}[Rolle]
Let $f:[a,b]\to \RR$ be continuous and differentiable on $(a,b)$. If $f(a) = f(b)$, then $\exists c\in (a,b)$ such that $f'(c) = 0$.
\end{theorem}
\begin{figure}[h]
    \centering
    \includegraphics{pics/fig09.PNG}
\end{figure}
\begin{remark} Are the hypotheses all necessary? This is left to the reader to figure out.
\end{remark}

\textbf{Proof}: Let $K = f(a) = f(b)$. Since $f$ is continuous on $[a,b]$, $\exists c_1,c_2\in [a,b]$ such that $f$ achieves an absolute maximum at $c_1$ and absolute minimum at $c_2$. If $f(c_1) >K \implies c_1\in (a,b)$. Therefore, $f'(c_1) = 0$ by the previous theorem. Similarly, if $f(c_2) < K$, then $c_2\in (a,b) \implies f'(c_2) =0$. If 
\[
f(c_1)\leq K \leq f(c_2) \implies f(x) = K ~\forall x\in [a,b] \implies f'(c) - 0 \text{~~for any~~} c\in (a,b).
\]\qed 

\begin{theorem}[Mean Value Theorem]
Let $f:[a,b] \to \RR$ be continuous, and let $f$ be differentiable on $(a,b)$. Then, $\exists c\in (a,b)$ such that 
\[
f(b)-f(a) = f'(c)(b-a).
\]
\end{theorem}
\begin{remark}
The Mean Value Theorem is sometimes denoted MVT.
\end{remark}

\begin{figure}[h]
    \centering
    \includegraphics{pics/fig10.PNG}
\end{figure}

\textbf{Proof}: Define $g:[a,b]\to \RR$ with
\[
g(x) = f(x) - f(b) + \frac{f(b)-f(a)}{b-a}(b-x).
\]
Then, $g(a) = g(b) = 0$. Thus, by Rolle's theorem, $\exists c\in (a,b)$ with $g'(c) = 0$, and hence 
\[
0 = f'(c) - \frac{f(b)-f(a)}{b-a}.
\]\qed 

We now look at some useful applications of the MVT.

\begin{theorem}
If $f:I\to \RR$ is differentiable and $f'(x) = 0$ for all $x\in I$, then $f$ is constant.
\end{theorem}
\textbf{Proof}: Let $a,b\in I$ with $a<b$. Then, $f$ is continuous on $[a,b]$ and differentiable on $(a,b)$. Therefore, $\exists c\in (a,b)$ such that $f(b) -f(a) = (b-a) f'(c) = 0$. Hence, $f(b) = f(a)$ for all $a,b\in I$ such that $a<b$. \qed 

\begin{theorem}
Let $f:I\to \RR$ be differentiable. Then,
\begin{enumerate}
    \item $f$ is increasing if and only if $f'(x) \geq 0$ for all $x\in I$ and
    \item $f$ is decreasing if and only if $f'(x) \leq 0$ for all $x\in I.$ 
\end{enumerate}
\end{theorem}
\textbf{Proof}:
\begin{enumerate}
    \item ($\impliedby$) Suppose $f'(x) \geq 0$ for all $x\in I$. Let $a,b\in I$ with $a<b$. Then, by MVT, $\exists c\in (a,b)$ such that 
    \[
    f(b)-f(a) = (b-a)f'(c) \geq 0 \implies f(a) \leq f(b).
    \]
    
    ($\implies$) Suppose $f$ is increasing. Let $c\in I$ and let $\{x_n\}$ be a sequence in $I$ such that $x_n\to c$ such that $\forall n$, $x_n< c$. Then, for all $n$, $f(x_n) - f(c) \leq 0 \implies \frac{f(x_n) - f(c)}{x_n-c}\geq 0$. Therefore, \[
    f'(c) = \lim_{n\to \infty} \frac{f(x_n) - f(c)}{x_n-c} \geq 0.
    \]
    
    Now let $\{x_n\}$ be a sequence in $I$ such that $x_n\to c$ such that $\forall n$, $x_n> c$. Then, for all $n$, $f(x_n) - f(c) \geq 0 \implies \frac{f(x_n) - f(c)}{x_n-c}\geq 0$. Therefore, \[
    f'(c) = \lim_{n\to \infty} \frac{f(x_n) - f(c)}{x_n-c} \geq 0.
    \]
    
    Hence, in either case, $f'(c) \geq 0$.
    
    \item Notice that $f$ is decreasing if and only if $-f$ is increasing, and apply 1. to $-f$.
\end{enumerate} \qed
%stopped 600, 5.5 hrs TOTAL
%edited 7-8, 6.5 hrs total 3/24
%started again 8