% This is lecture no. 1 of MH1100/: Calculus I.

\chapter{Functions}

\section{What is a function?}

\begin{definition}
	Function.
	A function $f$ is a rule that assigns to each element $x$ in a set $D$ exactly one element, called $f(x)$, in a set $E$.
	The set $D$ is caled the domain of the funciton. The range of $f$ is the set of all possible values of $f(x)$ as $x$ varies throughout the domain.
\end{definition}

\bigbreak
\noindent
In other words, $\{x \in D |f(x) \in E \}$.

\subsection{Ways to represent a function}

\bigbreak
\noindent
There are many different ways of describing funcitons:

 \begin{itemize}
	\item verbally (by a description of words)
	\item numerically (by a table of values)
	\item visually (by using a graph)
	\item algebraically (by using an explicit formula)
\end{itemize}

\subsection{Domain and Range}
\bigbreak
\noindent
\textbf{Domain} is the $x$-span and \textbf{range} is the $y$-span.
Find the domains of the following functions:

\bigbreak
\begin{exc}
	\[
		f(x) = \frac{1}{x^2 - 5x + 6}
	.\]
\end{exc}
\begin{exc}
	\[
		g(x) = \frac{1}{1-cos^2 x}
	.\]
\end{exc}
\begin{exc}
	\[
		h(x) = \frac{1}{\sqrt{x -1}} - \sqrt{1-x}
	.\]
\end{exc}

\bigbreak

\begin{sol}
\[
	x^2 - 5x + 6 = (x-3)(x-2) \quad \therefore \{x \in \mathbb{R} | x \neq 3,2 \}	
.\]
\end{sol}
\begin{sol}
\[
	cos^2 (x) \neq 1 \quad \therefore cos (x) \neq 1,-1	\quad \therefore \{x \in \mathbb{R} | x \neq n\pi, n \in \mathbb{N}\}
.\]
\end{sol}
\begin{sol}
	\[
		x > 1, \quad x \leqslant 1 \quad \therefore \text{No solutions for } x
	.\] 
\end{sol}

\subsection{Vertical line rule}
A curve in the $xy$-plane is the graph of a function of $x$ if and only if no vertical line intersects the curve more than once.

\begin{exmp}
	The parabola $x = y^2 - 2$ is not the graph of a function of $x$ because there are vertical lines that intersect the parabola twice.
\end{exmp}

\subsection{Piecewise defined functions}

\begin{definition}
	Piecewise defined functions.
	Piecewise defined functions are functions defined by different formulas in different parts of their domains.
\end{definition}

\begin{exmp}
	The following is a piecewise defined function:
	\[
		f(x) = \left\{
			\begin{array}{rl}
				1-x, & x \leqslant -1 \\
				x^2, & x > -1
			\end{array} \right
	.\] 
\end{exmp}

\subsection{Even \& Odd Functions}

Even and odd functions are used to define whether a function is symmetrical or perfectly asymmetrical about the line $x = 0$.

\begin{definition}
	Even function.
	An even function is a function that satisfies the following:
	\[
		f(-x) = f(x)
	.\] for all $x$ in its domain.
	Even functions show symmetry about the line $x=0$.
\end{definition}

\begin{exmp}
	The function $cos(x)$ is symmetric about the line $x=0$ and $cos(-x) = cos(x)$ is true, therefore, $cos(x)$ is an even function.
\end{exmp}

\begin{definition}
	Odd function.
	An odd function is a function that satisfies the following:
	\[
		f(-x) = -f(x)
	.\] for all $x$ in its domain.
	Odd functions show perfect asymmetry about the line $x=0$.
\end{definition}

\begin{exmp}
	The function $sin(x)$ is perfectly asymmetric about the line $x=0$ and $sin(-x) = -sin(x)$ is true, therefore, $sin(x)$ is an odd function.
\end{exmp}

Determine whether each of the following functions is even, odd, or neither even nor odd:

\begin{exc}
	\[
		f(x) = x^5 + x
	.\]
\end{exc}
\begin{exc}
	\[
		g(x) = 1 - x^4
	.\] 
\end{exc}
\begin{exc}
	\[
		h(x) = 2x - x^2
	.\] 
\end{exc}

\begin{sol}
	\begin{align*}
		f(-x) & = (-x)^5 + (-x) \\
		      & = -x^5 - x \\
		      & = -(x^5+x) \\
		      & = -f(x).
	\end{align*}
	Therefore, $f$ is an odd function.
\end{sol}

\bigbreak

\begin{sol}
	\begin{align*}
		g(-x) & = 1-(-x)^4 \\
		      & = 1-x^4 \\
		      & = g(x).
	\end{align*}
	Therefore, $g$ is an even function.
\end{sol}

\bigbreak

\begin{sol}
	\begin{align*}
		h(-x) & = 2(-x) - (-x)^2 \\
		      & = -2x - x^2 \\
	\end{align*}
	Since $h(-x) \ne h(x)$ and $h(-x) \ne -h(x)$, we conclude that $h$ is neither even nor odd.
\end{sol}

\begin{prf}
	Prove that a function $f$ is the sum of an even and an odd function in the range $(-a,a)$.
	\begin{align*}
		f(x) & = e(x) + o(x) \\
		f(-x) & = e(-x) + o(-x) \\
		f(-x) & = e(x) + o(-x) \\
		f(-x) & = e(x) - o(x) \\
	\end{align*}
\end{prf}

\subsection{Increasing \& Decreasing Functions}

\begin{definition}
	Increasing Function.
	A function $f$ is called increasing on an interval $I$ if:
	\[
		f(x_1) < f(x_2) \qquad \text{whenever } x_1 < x_2 \text{ in } I
	.\] 
	The inequality $f(x_1) < f(x_2)$ must be satisfied for every pair of numbers $x_1$ and $x_2$ in $I$ with $x_1 < x_2$.
\end{definition}

The opposite is true for decreasing functions.

\section{A catalog of essential functions}

\begin{definition}
	Polynomial.
	A function $P$ is called a polynomial if it is of the form:
	\[
		P(x) = a_nx^n + a_{n-1}x^{n-1} + \ldots + a_2x^2 + a_1x + a_0
	.\]
	where $n$ is a non-negative integer and the numbers $a_0,a_1,a_2,\ldots,a_n$ are constants called the coefficients of the polynomial.
	The domain of any polynomial is $\mathbb{R} = (-\infty,\infty)$.
	If the leading coefficient $a_n \neq 0$, then the degree of the polynomial is $n$.
\end{definition}

\begin{definition}
	Power Functions.
	A function of the form:
	\[
		f(x) = x^a
	.\]
	where $a$ is a constant, is called a power function.
\end{definition}

\begin{definition}
	Rational Functions.
	A rational function $f$ is a ratio of two polynomials:
	\[
		f(x) = \frac{P(x)}{Q(x)}
	.\]
	where $P$ and $Q$ are polynomials. The domain consists of all values of $x$ such that $Q(x)\neq 0$.
\end{definition}

\begin{definition}
	Algebraic functions.
	A function is called an algebraic function if it can be constructed using algebraic operations starting with polynomials.
\end{definition}

\begin{definition}
	Exponential Functions.
	The exponential functions are the functions of the form $f(x) = b^x$, where the base $b$ is a positive constant.
\end{definition}

\section{Transformation of Functions}

Suppose $c > 0$. To obtain the graph of:
\begin{itemize}
	\item $y = f(x) + c$, shift the graph of $y = f(x)$ a distance $c$ units upward.
	\item $y = f(x) - c$, shift the graph of $y = f(x)$ a distance $c$ units downward.
	\item $y = f(x - c)$, shift the graph of $y = f(x)$ a distance $c$ units to the right.
	\item $y = f(x + c)$, shift the graph of $y = f(x)$ a distance $c$ units to the left.
	\item $y = cf(x)$, stretch the graph of $y = f(x)$ vertically by a factor of $c$.
	\item $y = \frac{1}{c}f(x)$, shrink the graph of $y = f(x)$ vertically by a factor of $c$.
	\item $y = f(cx)$, shrink the graph of $y = f(x)$ horizontally by a factor of $c$.
	\item $y = f(\frac{x}{c})$, stretch the graph of $y = f(x)$ horizontally by a factor of $c$.
	\item $y = -f(x)$, reflect the graph of $y = f(x)$ about the $x$-axis.
	\item $y = f(-x)$, reflect the graph of $y = f(x)$ about the $y$-axis.
\end{itemize}

\section{Combinations of Functions}

\begin{definition}
	Sum and difference functions.
	The sum and difference functions are defined by:
	\[
		(f+g)(x) = f(x) + g(x) \quad (f-g)(x) = f(x) - g(x)
	.\]
	If the domain of $f$ is $A$ and the domain of $g$ is $B$, then the domain of $f \pm g$ is the intersection $A \cap B$ because both $f(x)$ an $g(x)$ have to be defined.
\end{definition}

\begin{definition}
	Product and quotient functions.
	The product and quotient functions are defined by:
	\[
		(fg)(x) = f(x)g(x) \quad \left(\frac{f}{g}\right)(x) = \frac{f(x)}{g(x)}
	.\]
	The domain of $fg$ is $A\cap B$.
	Because we cannot divide by 0, the domain of $\frac{f}{g}$ is therefore $\{x\in A \cap B|g(x) \neq 0\}$.
\end{definition}

\begin{definition}
	Composite functions.
	Given two functions $f$ and $g$, the composite function $f \circ g$ (also called the composition of $f$ and $g$) is defined by:
	\[
		(f\circ g)(x) = f(g(x))
	.\]
	The domain of $f \circ g$ is the set of all $x$ in the domain of $g$ such that $g(x)$ is in the domain of $f$:
	\[
		Dom(f\circ g)=\{x \in Dom(g)|g(x)\in Dom(f)\}
	.\]
\end{definition}
