← Back
CSNotes

FUNCTION:

Let AA and BB be nonempty sets. A function ff from AA to BB (denoted: f:A→Bf: A\rightarrow B) is an assignment of EXACTLY ONE element of BB to each element of AA.

If bb is the unique element of BB assigned by the function to the element a∈Aa\in A, we write f(a)=bf(a)=b

Functions are also maps

From each element in AA, one element maps to at LEAST one element in BB basically

RELATIONS:

A relation from AA to BB is just a subset of A×BA\times B. A function can also be defined in terms of a relation from AA to BB. A relation from AA to BB that contains one, and ONLY ONE, ordered pair (a,b)(a,b) for every element a∈Aa\in A, defines a function ff from AA to BB.

This function is defined by the assignment f(a)=bf(a)=b, where (a,b)(a,b) is the unique ordered pair in the relation that has aa as its first element

If ∣A∣=n|A|=n and ∣B∣=m|B|=m, how many relations do we have from A→BA\rightarrow B?

  • The total number of ordered pairs we can have from their product is going to be m×nm\times n. So, we then have ∣A×B∣=m×n|A\times B|=m\times n
  • A relation is simply a subset of this product, and for each pair (a,b)∈A×B(a,b)\in A\times B, you have two choices:
    • Either the pair (a,b)(a,b) is in the relation
    • It is NOT in the relation
  • Thus, for each of the mnmn pairs, there are two choices: it is either in the relation or not. This leads to a total number of possible relations being: 2mn2^{mn}

Examples:

If you are given two sets A={1,2,3}A = \lbrace 1,2,3 \rbrace and B={5,6,7}B = \lbrace 5,6,7 \rbrace and the relation R={(1,5),(1,7),(2,6)}R = \lbrace (1,5),(1,7),(2,6) \rbrace, is this a function? NO, because 1 maps to 5 and 7, when we said a function should make AA map to EXACTLY one element of BB

If you are given the relation R={(1,5),(2,5)}R = \lbrace (1,5),(2,5) \rbrace, is this a function? YES, although you might be saying “but but but 5 is mapped to twice” that does not matter. It matters that the first element is not mapped to two different numbers in BB. If the numbers in BB are mapped two by TWO DIFFERENT ELEMENTS FROM AA, then that’s fine

DOMAIN:

If ff is a function from AA to BB, we say that AA is the domain of ff and BB is the codomain of ff.

If f(a)=bf(a)=b, we say that bb is the image of aa and aa is the preimage of bb.

The range, or image, of ff is the set of all images of elements of AA. This is best explained with an example

Example:

If we are given this relation R={(1,5),(2,5)}R = \lbrace (1,5), (2,5) \rbrace, answer the following questions:

  1. Is this relation a function?
  2. What is the domain of this relation?
  3. What is the image/range of this relation?
  • This relation IS a function, since 5 is mapped to by two different elements of AA. The elements of AA are unique and are not mapped twice.
  • The domain of this relation: DR={1,2}D_R = \lbrace 1,2 \rbrace. Remember, the domain is the first element is each ordered pair
  • The image of this relation: Range=Im(f)={5}Range = Im(f) = \lbrace 5 \rbrace

If you are given this relation: R={(1,2),(1,4),(2,2),(2,5)}R = \lbrace (1,2),(1,4),(2,2),(2,5) \rbrace, answer the same questions above

  • This is NOT a function, since 1 is mapped to two elements and 2 is mapped to two elements
  • The domain of this relation: DR={1,2}D_R = \lbrace 1,2 \rbrace
  • The image of this relation: Range=I(R)={2,4,5}Range = I(R) = \lbrace 2,4,5 \rbrace

Two functions are considered equal when they have:

  • The same domain
  • The same codomain
  • Map each element of the domain to the same element in the codomain

Another way to describe range:

  • The range of a function, denoted as Range(f)Range(f) or f(A)f(A), is the set of ALL values that ff maps to in the codomain BB. In other words, it is the set of OUTPUT values of the function
  • f(A)={f(a) ∣ a∈A}f(A) = \lbrace f(a) \ | \ a \in A \rbrace
  • The range f(A)f(A) is ALWAYS a subset of the codomain BB, because ff maps elements from A→BA\rightarrow B

Is this a function?

  • Yes, each element in AA is not mapped to two different elements in BB. Although dd is never mapped to anything, that’s fine. It doesn’t HAVE to be mapped.
  • f={(a,0),(b,1),(c,1)}f=\{(a,0),(b,1),(c,1)\}
  • The domain of this function: Df={a,b,c}D_f=\{a,b,c\}
  • The codomain of this function: Codomain={0,1,2,3,4}Codomain=\{0,1,2,3,4\}
  • The range/image of this function: Im(f)=Range={0,1}Im(f)=Range=\{0,1\}

We don’t include dd in the domain of ff since dd is never mapped to anything. Although some elements in BB are not mapped to anything, it is still considered the codomain since the codomain is ALL elements of BB

If we have A=N−{0}A=N-\{0\} and B=N−{0}B=N-\{0\}, and we have the relation defined as:

R={(x,x2) ∣ x∈A}R=\{(x,x^2)\ | \ x\in A\}

  • Is this relation a function
  • What is the domain and codomain of this relation
  • What is the range/image of this relation
  1. This relation IS a function, this is because for every x∈Ax\in A, there will always be ONE x2∈Bx^2\in B that xx will map to. Meaning if x=1x=1, 1 ONLY gets mapped to (1)2=1(1)^2=1. If x=2x=2, 2 ONLY gets mapped to (2)2=4(2)^2=4, and so on
  2. The domain of this function is Df=AD_f=A and the codomain of this function: Codomain=BCodomain=B
  3. The range/image of this function: Range=Im(f)={x2 ∣ x∈A}Range=Im(f)=\{x^2\ | \ x\in A\}, it is all perfect squares

If we have A=ZA=Z , which is just (−∞,+∞)(-\infty,+\infty), and B=ZB=Z, and we are given the relation:

R={(x2,x) ∣ x∈A}R=\{(x^2,x)\ | \ x\in A\}

  • Is this relation a function
  1. This is NOT a function, because for x2x^2, you can have xx be either the + or - value of its square root. So, if we had x2=1x^2=1, this means either x=1x=1 or x=−1x=-1, 1 maps to two values, so this is not a function

We have different types of functions that we will talk about…yay!

  1. Injective functions
  2. Surjective functions
  3. Bijective functions
  4. Inverse functions

INJECTIVE FUNCTIONS:

A function is said to be injective, or one-to-one, IF AND ONLY IF distinct elements of the domain ff have distinct images in the range of ff

Examples:

If we had the function {(1,1),(2,1)}\{(1,1),(2,1)\}, this is NOT an injective function, because 1 in the codomain is mapped to twice by two distinct elements in the domain.

If we had something like {(1,2),(3,4)}\{(1,2),(3,4)\}, this IS an injective function

SURJECTIVE FUNCTION:

A function ff is said to be surjective, or onto, IF AND ONLY IF every element of the codomain is in the range of ff.

Examples:

If we are given A={1,2,3}A=\{1,2,3\} and B={4,5,6}B=\{4,5,6\} and we are given this function: f={(1,4),(2,5),(3,5)}f=\{(1,4),(2,5),(3,5)\}, then this is not surjective. Because, in our function, the range would be Range=Im(f)={4,5}Range=Im(f)=\{4,5\}, which is NOT equal to the codomain {4,5,6}\{4,5,6\}.

If we are given A={1,2,3}A=\{1,2,3\} and B={4,5}B=\{4,5\} and the function f={(1,4),(2,5),(3,5)}f=\{(1,4),(2,5),(3,5)\}, then this IS considered surjective

BIJECTIVE FUNCTIONS:

A function is said to be bijective IF AND ONLY IF it is BOTH injective and surjective

Example:

If we are given A={1,2,3}A=\{1,2,3\} and B={4,5,6}B=\{4,5,6\} and we are given this function: f={(1,4),(2,5),(3,6)}f=\{(1,4),(2,5),(3,6)\}, this function is both surjective AND injective, making it a bijective function

INVERSE FUNCTION:

If f:A→Bf:A\rightarrow B is a bijective function, then its inverse relation f−1:B→Af^{-1}:B\rightarrow A is also a function

In this case, we say that ff is invertible

The surjectivity of ff guarantees that f−1f^{-1} is defined al ALL elements of BB; the injectivity of ff guarantees that f−1f^{-1} maps each element of BB to a unique element of AA

f(a)=b→f(b)=af(a)=b\rightarrow f(b)=a

Example: If we are given f={(1,2),(2,5),(4,−1)}f=\{(1,2),(2,5),(4,-1)\}, we have an inverse function

f−1={(2,1),(5,2),(−1,4)}f^{-1}=\{(2,1),(5,2),(-1,4)\}

If a function is not bijective, it can still have an inverse relation, mind you, i’m not saying FUNCTON, it can have an inverse RELATION:

Let f:{1,2,3}→{a,b}f:\{1,2,3\}\rightarrow \{a,b\} be:

f={(1,a),(2,b),(3,b)}f=\{(1,a),(2,b),(3,b)\}

Obviously this function is not injective, since f(2)=f(3)=bf(2)=f(3)=b, but this doesn’t mean it doesn’t have an inverse RELATION. An inverse relation is defined as:

f−1={(b,a) ∣ (a,b)∈f}f^{-1}=\{(b,a)\ | \ (a,b)\in f\}

This relation becomes a function IF AND ONLY IF it is bijective

So, for the above example, we can still have an inverse relation f−1={(a,1),(b,2),(b,3)}f^{-1}=\{(a,1),(b,2),(b,3)\}

🤓 It is important to note that:

  • All functions are relations
  • Not all relations are functions

this is common sense if you think about it

COMPOSITION OF FUNCTIONS:

If f:A→Bf:A\rightarrow B and g:B→Cg:B\rightarrow C are functions, then the composition g∘f:A→Cg\circ f:A\rightarrow C (which is always defined as a relation) is a function.

g∘f:A→C,g∘f=g(f(x))g\circ f:A\rightarrow C,g\circ f=g(f(x))

So, if we had a function h=g∘fh=g\circ f, and we wanted to find the value of h(1)h(1), this would be:

h(1)=g∘f=g(f(x))=g(f(1))=g(4)=7h(1)=g\circ f=g(f(x))=g(f(1))=g(4)=7. This makes sense when you trace it with the image above