\documentclass[methods-collated.tex]{subfiles}

\begin{document}

\section{Calculus}

\subsection*{Average rate of change}

\[m \operatorname{of} x \in [a,b] = \dfrac{f(b)-f(a)}{b - a} = \frac{dy}{dx}\]

\colorbox{cas}{On CAS:} Action \(\rightarrow\) Calculation
\(\rightarrow\) \texttt{diff}

\subsection*{Average value}

\[ f_{\text{avg}} = \dfrac{1}{b-a} \int^b_a f(x) \> dx \]

\subsection*{Instantaneous rate of change}

\textbf{Secant} - line passing through two points on a curve\\
\textbf{Chord} - line segment joining two points on a curve

\subsection*{Limit theorems}

\begin{enumerate}
    \def\labelenumi{\arabic{enumi}.}
    \tightlist
  \item For constant function \(f(x)=k\), \(\lim_{x \rightarrow a} f(x) = k\)
  \item \(\lim_{x \rightarrow a} (f(x) \pm g(x)) = F \pm G\)
  \item \(\lim_{x \rightarrow a} (f(x) \times g(x)) = F \times G\)
  \item \({\lim_{x \rightarrow a} {f(x) \over g(x)}} = {F \over G}, G \ne 0\)
\end{enumerate}

A function is continuous if \(L^-=L^+=f(x)\) for all values of \(x\).

\subsection*{First principles derivative}

\[f^\prime(x)=\lim_{h \rightarrow 0}{{f(x+h)-f(x)} \over h}\]

Not differentiable at:
\begin{itemize}
    \tightlist
  \item discontinuous points
  \item sharp point/cusp
  \item vertical tangents (\(\infty\) gradient)
\end{itemize}

\subsection*{Tangents \& gradients}

\textbf{Tangent line} - defined by \(y=mx+c\) where
\(m={dy \over dx}\)\\
\textbf{Normal line} - \(\perp\) tangent
(\(m_{{tan}} \cdot m_{\operatorname{norm}} = -1\))\\
\textbf{Secant} \(={{f(x+h)-f(x)} \over h}\)

\begin{cas}
  \textbf{In main}: Interactive \(\rightarrow\) Calculation \(\rightarrow\) Line \\
  \-\hspace{1em} \texttt{tanLine(f(x), x, p)} \\
  \-\hspace{1em} \texttt{normal(f(x), x, p)} \\
  where \texttt{p} is the \(x\)-value of the coordinate

  \textbf{In graph}: define function, then Analysis \(\rightarrow\) Sketch \(\rightarrow\) (Normal \textbar{} Tan line). Type \(x\) value to solve for a point. Return to show equation for line.
\end{cas}

\subsection*{Strictly increasing/decreasing}

For \(x_2\) and \(x_1\) where \(x_2 > x_1\):

\begin{itemize}
    \tightlist
  \item \textbf{strictly increasing}\\ where \(f(x_2) > f(x_1)\) or \(f^\prime(x)>0\)
  \item \textbf{strictly decreasing}\\ where \(f(x_2) < f(x_1)\) or \(f^\prime(x)<0\)
  \item Endpoints are included, even where gradient \(=0\)
\end{itemize}

\subsection*{Stationary points}

\begin{align*}
  \textbf{Stationary point:} && f^\prime(x) &= 0 \\
  \textbf{Point of inflection:} && f^{\prime\prime} &= 0
\end{align*}

\begin{tikzpicture}
  \begin{axis}[xmin=-21, xmax=21, ymax=1400, ymin=-1000, ticks=none, axis lines=middle]
    \addplot[color=red, smooth, thick] gnuplot [domain=-15:15,unbounded coords=jump,samples=500] {x^3-3*x^2-144*x+432} node [black, pos=1, right] {\(f(x)\)};
    \addplot[color=darkgray, dashed, smooth, thick] gnuplot [domain=-15:15,unbounded coords=jump,samples=500] {3*x^2-6*x-144} node [black, pos=1, right] {\(f^\prime(x)\)};
    \addplot[mark=*, blue] coordinates {(1,286)} node[above right, align=left, font=\footnotesize]{inflection \\ (falling)} ;
    \addplot[mark=*, orange] coordinates {(-6,972)} node[above left, align=right, font=\footnotesize]{stationary \\ (local max)} ;
    \addplot[mark=*, orange] coordinates {(8,-400)} node[below, align=left, font=\footnotesize]{stationary \\ (local min)} ;
  \end{axis}
\end{tikzpicture}\\
\begin{tikzpicture}
  \begin{axis}[enlargelimits=true, xmax=3.5, ticks=none, axis lines=middle]
    \addplot[color=blue, smooth, thick] gnuplot [domain=0.74:3,unbounded coords=jump,samples=500] {(x-2)^3+2} node [black, pos=0.9, left] {\(f(x)\)};
    \addplot[color=darkgray, dashed, smooth, thick] gnuplot [domain=1:3,unbounded coords=jump,samples=500] {3*(x-2)^2} node [black, pos=0.9, right] {\(f^\prime(x)\)};
    \addplot[mark=*, purple] coordinates {(2,2)} node[below right, align=left, font=\footnotesize]{stationary \\ inflection} ;
  \end{axis}
\end{tikzpicture}

\include{../spec/calculus-rules}

\end{document}
