=== Union of 2 sets
Def: Let A and B be sets. The Union of A and B, denoted by $A union B$, is the set that contains every element in either A or B or both.
$ A union B={x|x in A or x in B} $

The order of the operation doesn't matter

#image("union-of-a-and-b.png", width: 50%)
=== Intersections
Def: Let A and B be sets. The intersection of A and B, denoted by $A inter B$, is the set containing those elements, that are in both A and B.
$ A inter B = {x|x in A and x in B} $

The order of the operation doesn't matter
#image("intersection.png",width: 50%)

=== Disjoint
Def. A and B are disjoint if $A inter B =nothing$, aka they don't have any elements in common.

=== Size of elements in two sets
If A and B are finite sets, then: $ |A union B| = |A| + |B| - |A inter B| $
To get size of the elements in the sets, you need to add their size together, and then subtract all the elements they have in common.

=== Difference
Def: Let A and B be sets. The Difference of A and B, denoted $A-B$, is the set containing those elements of A that are not in B. $ A-B={x|x in A and x in.not B} $
Sometimes also denoted $A\\B$
#image("difference-a-b.png",width: 50%)
If $A-B=nothing$. Either $A=B$ or $A subset B$ (A is a subset of B).

=== Complement
Everything that is not in the set. But you need a universal set (in the pictures, the rectangle is the universal set).

Def: Let U be the universal set. The complement of the set A, denoted by $macron(A)$, is the containing all the elements of U that are not in A. $macron(A)=U-A$
#image("complement.png",width: 50%)
Example.
$
U=NN,space space space A&={1,3,5,7,...}\
dash(A)&={0,2,4,6,...}\
U=ZZ, space space space dash(A)&={...,-2,-1,0,2,4,...}
$
=== Set identities
#image("set-identities.png",width: 75%)
Prove: $dash(A union B) = dash(A) union dash(B)$

$ x in dash(A union B) <=>\
x in.not A union B <=> \
x in.not A and x in.not B <=>\
x in dash(A) and x in dash(B) <=> \
x in dash(A) union dash(B) $
If x is in the complement of the union of A and B, then it must not be in the union of A and B. In other words, it is not in either A or B. This can be written as x being in the complement of A and the complement of B. This can be then be written as x is in the union of the complement of A and the complement of B.

Prove: $dash(A union (B inter C))=(dash(C) union dash(B)) inter dash(A)$
$
dash(A union (B inter C)) <=>\
dash(A) inter (dash(B union C)) <=>\
dash(A) inter (dash(B) union dash(C))
$

== Unions and intersections of an arbitrary number of sets
$union_(i=1)^(arrow.ccw.half)A_i={x|exists space i in {1,dots,b} text("such that") x in A_i}$

$inter_(i=1)^(arrow.ccw.half)A_i={x|forall space i in {1,dots,n} text("such that") x in A_i}$

$union_(i=1)^(infinity)A_i={x|exists space i in ZZ^+ text("such that") x in A_i}$

$inter_(i=1)^(infinity)A_i={x|forall space i in ZZ^+ text("such that") x in A_i}$

Example:
$A_i={1,2,3,dots,i}, A_1={1}, A_2={1,2}$

$union^(infinity)_(i=1)A_i=ZZ^+, inter_(i=1)^(infinity)A_i={1}$


= Functions
Def: Let A and B be nonempty sets. A function _f_ from A to B is an assignment of exactly one element of B to each element of A. We write $f(a)=b$ if b is the element of B that _f_ assigns to _a_.

We write $f: A->B$ to denote that _f_ is a function from A to B.

$(a,f(a))in A times B$

Def: Let $f:A->B$

*Domain* of _f_ is A

*Codomain* of _f_ is B

If $f(a)=b$, then b is the *image* of _a_ under _f_, and _a_ is a *preimage* of _b_. For every _a_ it matches a single _b_.

*Range/Image* of _f_ the set of all images 

Example: $A={a,b,c,d}, space B={1,2,3,4}, space f:A->B$

$f(a)=1,space f(b)=2,space f(c)=3,space f(d)=4$

*Real-valued function* means that $text("codomain")=RR$ (real number)

*Integer-valued function* means that $text("codomain")=ZZ$ (integers)


== Sum
Def: let $f_1 text("and") f_2$ be realvalued functions from A, then $f_1+f_2 text("and") f_1f_2$ are functions from A to $RR$ defined as: $ (f_1+f_2)(x)=f_1(x)+f_2(x)\ f_1f_2(x)=f_1(x)f_2(x) $
*Example:*
$f_1,f_2:RR->RR space f_1(x)=x^2, space f_2(x)=x-x^2$

$ (f_1+f_2)(x)=x\ f_1f_2(x)=x^3-x^4 $


*Def:* Let $f:A->B$. IF $S subset.eq A$, then the image of S under f, denoted $f(S)$ is the set ${b in B|exists a in S text("such that") f(a)=b}$

Example: $f:RR->RR space f(x)=x^2$

$S={-1,0,1}\ f(S)={0,1}$

== Injectivity and Surjectivity
#image("Different correspondence.png")
=== Injectivity
Def: A function $f:A->B$ is one-to-one/injective/an injection if $f(x)=f(y)=>x=y, forall x,y in A$. Two elements in the domain, cannot match to the same element in the codomain.

$x!=y=>f(x)=>f(y)$.

*Example*

$f:ZZ->ZZ space f(x)=x^2$

This is not injective as for example both -1 and 1 give the same answer.

$f:NN->ZZ space f(x)=x^2$ would be injective as you now only have positive x.

~

*Def:* Let $f:A->B text("such that") A,B subset.eq RR$. Then _f_ is increasing if $x<=y=>f(x)<=f(y) space forall x,y in A$.

It would be strictly increasing if $x<y=>f(x)<f(y) space forall x,y in A$. And this would be the same for decreasing, only the opposite of course.

A strictly increasing function implies that the function is injective

=== Surjectivity
Def: A function $f:A->B$ is surjective/onto/a surjection if $forall b in B, exists a in A "such that" f(a)=b$. For every element in the codomain, there exists an element in the domain that matches to it.

Example: $f:ZZ->ZZ space f(x)=x-1$

Let $k in ZZ, "then" k+1 in ZZ "and" f(k+1)=k+1-1=k$.

$f:NN->NN space f(x)=2x$ would not be surjective because the uneven numbers in the codomain would not have an element in the domain matched to them. $f:ZZ->ZZ space f(x)=2x$ would be surjective because for every real number, half that number would still be a real number, so every element in the codomain would have an element in the domain that matches it.

=== Bijection
Def: A function is a bijection/one-to-one correspondence if it is both injective and surjective

Suppose $f:A->B$

To show that f is _injective_: show if $f(x)=f(y), "then" x=y space("for arbitrary" x,y in A)$

To show that it's not _injective_: Find a particular $x,y in A "such that" x!=y "and" f(x)=f(y)$

To show that f is _surjective_: Consider arbitrary $b in B, "and show" exists a in A "such that" f(a)=b$

To show that it's not _surjective_: Find a particular $b in B "such that" exists.not a in A "with" f(a)=b$

== Inverse
Def: Let $f:A->B$ be a bijection. The inverse function of _f_, denoted $f^(-1)$, is the function from B to A that assigns to $b in B$ the unique element $a in A "such that" f(a)=b$. Note: $f^(-1)!=1/f$.

== Composition
Let $f:A->B, space g:B->C$
$ g compose f: A->C\ f compose g(a)=g(f(a)) $


=== Floor function
Largest integer that is less than or equal to x

=== Ceiling function
Smallest integer that is greater than or equal to x