%%%%%%%%%%
% AVOIDS "x to a" definition derivative, lest fuss with f'(a) vs f'(x)
% AVOIDS "x to a" proof of power rule (slick, but less insight)
%%%%%%%%%%

\documentclass[17pt, handout]{beamer}
\usetheme{Pittsburgh}
\setbeamertemplate{enumerate items}[default]
%\setbeamercovered{transparent}
\usepackage[thicklines]{cancel}
\usepackage{mathtools, multicol, tikz-cd}
%\usepackage{stackengine}
%\stackMath
\theoremstyle{remark}
\newtheorem{exercise}{Exercise}
\newtheorem{plickers}{Exercise}
%\newtheorem{plickers}{Plickers Exercise}
\AtBeginSection[]{
	\begin{frame}\relax
	\tableofcontents[currentsection]
	\end{frame}
	}

\begin{document}
%\section{Power Rule}
\begin{frame}
\begin{theorem}[Power Rule]
\[\Big(x^n\Big)' = \pause nx^{n-1}\]
\end{theorem}

\pause
\begin{plickers}
Find the derivative of $f(x) = x^3$.
\begin{multicols}4
\begin{enumerate}[A.]
\item $3x^2$ \item $3x$ \item $6x$ \item $6$
\end{enumerate}
\end{multicols}
\end{plickers}
\end{frame}

\begin{frame}
\begin{fact}
\par\bigskip
$(x+h)^2 = \pause x^2 + 2xh + h^2$ \pause\par\bigskip
$(x+h)^3 = \pause x^3 + 3x^2h + 3xh^2 + h^3$ \pause\par\bigskip
$(x+h)^4 = x^4 + 4x^3h + 6x^2h^2 + 4xh^3 + h^4$ \pause\par\bigskip\bigskip

%$(x+h)^3 = \pause x^3 + 3x^2h + 
%	\uncover<5->(
%	3x\uncover<-4>{h^2} +
%	h\uncover<-4>{^3}
%	\uncover<5->{)h^2}$ \pause[6]
%
%$(x+h)^3 = \pause x^3 + 3x^2h + \uncover<-4>{3xh^2 + h^3}$
%\pause\par
%$\phantom{(x+h)^3 = x^3 + 3x^2h + {}} \mathllap(3x\phantom{h^2}+h\phantom{^3})h^2$

$\phantom{(x+h)^n = {}}x^n \pause + nx^{n-1}h \pause \quad+\quad (\hspace{0.6ex}\cdots)h^2$ 

%\Large\quad$
%	x^n \quad nx^{n-1}\!h \quad (\,\cdots)h^2
%	$
\end{fact}
\end{frame}

%%%%%%%%%%%%%%%
% OLD STYLE PROOF
%%%%%%%%%%%%%%%
%\begin{frame}
%\begin{proof}
%Fix a positive integer $n$.
%\vspace{-1.5ex}
%\begin{align*}
%	f(x) &= x^n 
%	&&\text{(given)} \\
%	f'(x) &= \lim_{h\to0} \textstyle \frac{f(x+h) - f(x)}h 
%	&&\text{(definition)} \\
%	&= \lim_{h\to0} \textstyle \frac{(x+h)^n - x^n}h 
%	&&\text{(sub in $f$)} \\
%	&= \lim_{h\to0} \textstyle \frac{x^n + nx^{n-1}h + (\,\cdots)h^2 \,\,-\,\, x^n}h 
%	&&\text{(use fact)} \\
%	&= \lim_{h\to0} \textstyle \frac{nx^{n-1}h}h + \frac{(\,\cdots)h^2}h \\
%	&= nx^{n-1} &&\qedhere
%	\end{align*}
%\end{proof}
%\end{frame}

%%%%%%%%%%%%%%%
% NEW STYLE PROOF
%%%%%%%%%%%%%%%
%\newcommand\mystack[3]{\overset{\mathclap{\substack{\textstyle #3 \\[1.5ex] \textstyle #2 \vphantom) \\[1.5ex]}}}{\quad\,\,#1\quad\,\,}}
%\begin{frame}
%\begin{proof}
%Fix a positive integer $n$.
%Let $f(x) = x^n$.
%\begin{align*}
%	f'(x) &= \lim_{h\to0} 
%	\frac{
%		\mystack{f(x+h)}{(x+h)^n}{
%			\bcancel{x^n}
%			+ nx^{n-1}\bcancel h
%			+ (\,\cdots)h^{\bcancel2}
%			}
%		- \mystack{f(x)}{x^n}{}
%		}{\bcancel h}
%	\\[1.5em] &= nx^{n-1} \qedhere
%	\end{align*}
%\end{proof}
%\end{frame}

%%%%%%%%%%%%%%%
% NEWer STYLE PROOF
%%%%%%%%%%%%%%%

\begin{frame}
\begin{block}{Proof (Power Rule)}
Fix a positive integer $n$.
Let $f(x) = x^n$. So,

\bigskip\pause
\phantom{=}
$\uncover<8->{\lim_{h\to0}}
	\uncover<5->{\Big(}
	f(x+h) \uncover<3->{{}- f(x)}
	\uncover<5->{\Big)\Big(\tfrac1h\Big)}$

\bigskip
= $\uncover<8->{\lim_{h\to0}}
	\uncover<5->{\Big(}
	\alt<-3>{x^n}{\bcancel{x^n}}
	+ nx^{n-1}\alt<-5>h{\bcancel h}
	+ (\cdots\hspace{-0.1ex})h\alt<-5>{^2}{^{\bcancel2}}
	\uncover<3->{{}-\alt<-3>{x^n}{\bcancel{x^n}}}
	\uncover<5->{\Big)\Big(\tfrac1{\alt<-5>h{\bcancel h}}\Big)}$

\bigskip\pause[7]
= $\uncover<8->{\lim_{h\to0}} \phantom{\Big(} nx^{n-1} + (\cdots\hspace{-0.1ex})h$

\bigskip\pause\pause
= $\phantom{\lim_{h\to0}\Big(}nx^{n-1}$
\end{block}
\end{frame}

\end{document}