A **function** is a rule where each input has exactly one output, which can be determined by the **vertical line test**.
!!! definition
- The **domain** is the set of allowable independent values.
- The **range** is the set of allowable dependent values.
Functions can be **composed** to apply the result of one function to another.
$$
(f\circ g)(x) = f(g(x))
$$
!!! warning
Composition is not commutative: $f\circ g \neq g\circ f$.
## Inverse functions
The inverse of a function swaps the domain and range of the original function: $f^{-1}(x)$ is the inverse of $f(x)$.. It can be determined by solving for the other variable:
$$
\begin{align*}
y&=mx+b \\
y-b&=mx \\
x&=\frac{y-b}{m}
\end{align*}
$$
Because the domain and range are simply swapped, the inverse function is just the original function reflected across the line $y=x$.
<imgsrc="https://upload.wikimedia.org/wikipedia/commons/1/11/Inverse_Function_Graph.png"width=300>(Source: Wikimedia Commons, public domain)</img>
If the inverse of a function is applied to the original function, the original value is returned.
$$f^{-1}(f(x)) = x$$
A function is **invertible** only if it is "**one-to-one**": each output must have exactly one input. This can be tested via a horizontal line test of the original function.
If a function is not invertible, restricting the domain may allow a **partial inverse** to be defined.
!!! example
<imgsrc="https://upload.wikimedia.org/wikipedia/commons/7/70/Inverse_square_graph.svg">(Source: Wikimedia Commons, public domain)</img>
By restricting the domain to $[0,\inf]$, the **multivalued inverse function** $y=\pm\sqrt{x}$ is reduced to just the partial inverse $y=\sqrt{x}$.
## Symmetry
An **even function** satisfies the property that $f(x)=f(-x)$, indicating that it is unchanged by a reflection across the y-axis.
An **odd function** satisfies the property that $-f(x)=f(-x)$, indicating that it is unchanged by a 180° rotation about the origin.
The following properties are always true for even and odd functions:
- even × even = even
- odd × odd = even
- even × odd = odd
Functions that are symmetric (that is, both $f(x)$ and $f(-x)$ exist) can be split into an even and odd component. Where $g(x)$ is the even component and $h(x)$ is the odd component:
$$
\begin{align*}
f(x) &= g(x) + h(x) \\
g(x) &= \frac{1}{2}(f(x) + f(-x)) \\
h(x) &= \frac{1}{2}(f(x) - f(-x))
\end{align*}
$$
!!! note
The hyperbolic sine and cosine are the even and odd components of $f(x)=e^x$.
The Heaviside function effectively returns a boolean whether the number is greater than 0.
$$
\begin{align*}
H(x) = \begin{cases}
0 &\text{ if } t <0 \\
1 &\text{ if } t \geq 0
\end{cases}
\end{align*}
$$
This can be used to construct other piecewise functions by enabling them with $H(x-a)$ as a factor, where $a$ is the interval.
In a nutshell:
- $1-H(t-a)$ lets you "turn a function off" at at $t=a$
- $H(t-a)$ lets you "turn a function on at $t=a$
- $H(t-a) - H(t-b)$ leaves a function on in the interval $(a, b)$
!!! example
TODO: example for converting piecewise to heaviside via collecting heavisides
and vice versa
## Periodicity
The function $f(t)$ is periodic only if there is a repeating pattern, i.e. such that for every $x$, there is an $f(x) = f(x + nT)$, where $T$ is the period and $n$ is any integer.
### Circular motion
Please see [SL Physics 1#6.1 - Circular motion](/g11/sph3u7/#61-circular-motion) and its subcategory "Angular thingies" for more information.
Because extending the domain does not pass the horizontal line test, for engineering purposes, inverse sine is only the inverse of sine so long as the angle is within $[-\frac{\pi}{2}, \frac{\pi}{2}]$. Otherwise, it is equal to that version mod 2 pi.
$$y=\sin^{-1}x \iff x=\sin y, y\in [-\frac{\pi}{2}, \frac{\pi}{2}]$$
This means that $x\in[-1, 1]$.
$$
\sin(\sin^{-1}x) = x \\
\sin^{-1}(\sin x) = x \text{ only if } x\in[-\frac{\pi}{2}, \frac{\pi}{2}]
$$
Similarly, inverse **cosine** only returns values within $[0,\pi]$.
Similarly, inverse **tangent** only returns values within $(-\frac{\pi}{2}, \frac{\pi}{2})$. However, $\tan^{-1}$ is defined for all $x\in\mathbb R$.
Although most of the reciprocal function rules can be derived, secant is only valid in the odd range $[-\pi, -\frac{\pi}{2})\cup [0, \frac{\pi}{2})$, and returns values $(-\infty, -1]\cup [1, \infty)$.
### Electrical signals
Waves are commonly presented in the following format, where $A$ is a **positive** amplitude:
$$g(t)=A\sin(\omega t + \alpha)$$
In general, if given a sum of a sine and cosine:
$$a\sin\omega t + b\cos\omega t = \sqrt{a^2 + b^2}\sin(\omega t + \alpha)$$
The sign of $\alpha$ should be determined via its quadrant via the signs of $a$ (sine) and $b$ (cosine) via the CAST rule.