Notes/UNB/Year 4/Semester 2/CS2333/2024-01-17.md
2024-01-22 10:12:48 -04:00

52 lines
2.0 KiB
Markdown

Lecture Topic: Functions
For every input element $a \in A$ there is exactly one output element $b \in B$
Jargon:
- f maps a to b
- the image of a under f is b
functions are one-to-one (or injective):
$\forall x,y \in A, x \neq y \rightarrow f(x) \neq f(y)$
or in other terms
$\forall x,y \in A, x = y \rightarrow f(x) = f(y)$
Example:
$f(x) = x^2$ is not one to one
Proof by counter example:
$x = -1$ and $y = 1$ are two integers in the domain that $x=y$ but $f(-1)$ and $f(1)$ are both equal to 1, so it is not one to one
To prove a function is one to one, it is a little more tricky, and needs to be general, for example:
Let x and y be any arbitrary elements of the domain where f(x) = f(y)
So it follows that x and y are equal (x = y)
Example for a real function: $g(x) = 3x - 11$
Real Numbers
Let x and y be any real number such that $g(x) = g(y)$. We will show that $x = y$
Since we know that g(x) = g(y), it means that $3x - 11 = 3y - 11$
Add 11 to both sides: $\therefore 3x = 3y$
Divide both sides by 3: $\therefore x = y$
Important to note: The definition (domain and co-domain) can change if a function is one to one, for example the square function on all integers vs all positive integers
To prove that a function A -> B is onto:
- Let be represent and arbitrary element in the co-domain B
- We want to find an element a in the domain and show that f(a) = b
Example:
Real Numbers, $f(x) = 5x + 2$ is onto
Proof: Let b be any arbitrary real number (we want to find a real number a and show that f(a) = b)
A through process might follow that, I want a value a such that f(a) = b, I want $5a + 2 = b$, then $5a = b - 2$, then $a = \frac{b - 2}{5}$
So, let $a = \frac{b - 2}{5}$ , which is a real number. Then plug this back into the function
$f(a) = f(\frac{b - 2}{5}$) (Substitution)
$= 5\frac{b-2}{5}+2$ (Definition of f)
$= (b-2) +2)$ (Algebra)
$=b$ (Algebra)
Beginning of proving a function is not onto:
Find some specific co-domain element b and show that there is no domain element that could map to b