函數基本概念¶

Function basics

Creative Commons License
This work by Jephian Lin is licensed under a Creative Commons Attribution 4.0 International License.

$\newcommand{\trans}{^\top} \newcommand{\adj}{^{\rm adj}} \newcommand{\cof}{^{\rm cof}} \newcommand{\inp}[2]{\left\langle#1,#2\right\rangle} \newcommand{\dunion}{\mathbin{\dot\cup}} \newcommand{\bzero}{\mathbf{0}} \newcommand{\bone}{\mathbf{1}} \newcommand{\ba}{\mathbf{a}} \newcommand{\bb}{\mathbf{b}} \newcommand{\bc}{\mathbf{c}} \newcommand{\bd}{\mathbf{d}} \newcommand{\be}{\mathbf{e}} \newcommand{\bh}{\mathbf{h}} \newcommand{\bp}{\mathbf{p}} \newcommand{\bq}{\mathbf{q}} \newcommand{\br}{\mathbf{r}} \newcommand{\bx}{\mathbf{x}} \newcommand{\by}{\mathbf{y}} \newcommand{\bz}{\mathbf{z}} \newcommand{\bu}{\mathbf{u}} \newcommand{\bv}{\mathbf{v}} \newcommand{\bw}{\mathbf{w}} \newcommand{\tr}{\operatorname{tr}} \newcommand{\nul}{\operatorname{null}} \newcommand{\rank}{\operatorname{rank}} %\newcommand{\ker}{\operatorname{ker}} \newcommand{\range}{\operatorname{range}} \newcommand{\Col}{\operatorname{Col}} \newcommand{\Row}{\operatorname{Row}} \newcommand{\spec}{\operatorname{spec}} \newcommand{\vspan}{\operatorname{span}} \newcommand{\Vol}{\operatorname{Vol}} \newcommand{\sgn}{\operatorname{sgn}} \newcommand{\idmap}{\operatorname{id}} \newcommand{\am}{\operatorname{am}} \newcommand{\gm}{\operatorname{gm}} \newcommand{\mult}{\operatorname{mult}} \newcommand{\iner}{\operatorname{iner}}$

Main idea¶

Let $S$ and $T$ be two sets.
A function $f$ from $S$ to $T$ is an assignment of each element $s\in S$ with an element $f(s)\in T$.
We usually write

$$ \begin{aligned} f : S &\rightarrow T \\ s &\mapsto f(s) \end{aligned} $$

to describe a function.
We call $S$ and $T$ the domain and the codomain of $f$.

A function $f:S\rightarrow T$ is injective if

  • for any distinct elements $s_1,s_2\in S$, i.e., $s_1\neq s_2$, their values under the function $f(s_1), f(s_1)$ are also distinct, i.e., $f(s_1)\neq f(s_2)$.

Equivalently, $f$ is injective if $f(s_1) = f(s_2)$ implies $s_1 = s_2$.
The term "injective" is also known as "one-to-one".
An injection is an injective function.

A function $f : S \rightarrow T$ is surjective if

  • for any element $t\in T$, there is an element $s\in S$ such that $f(s) = t$.

The range of a function $f$ is

$$ \range(f) = \{f(s) : s\in S\}. $$

Therefore, $f$ is surjective if and only if $\range(f) = T$.
The term "surjective" is also known as "onto".
A surjection is a surjective function.

If a function $f$ is both injective and surjective, then it is bijective.
A bijection is a bijective function.

If $f$ is a bijection, then one may define its inverse as

$$ \begin{aligned} f^{-1} : T &\rightarrow S \\ t &\mapsto f^{-1}(t), \end{aligned} $$

where $f^{-1}(t)$ is defined as the unique element $s\in S$ such that $f(s) = t$.
(Here the existence of $s$ is because $f$ is surjective, and the uniqueness of $s$ is because $f$ is injective.)

The function

$$ \begin{aligned} \idmap_S : S &\rightarrow S \\ s &\mapsto s \end{aligned} $$

is called the identity map on $S$, denoted as $\idmap_S$.

Let $f : S \rightarrow T$ be a function.
If $S'\subseteq S$, then the image of $S'$ is

$$ f(S') = \{ f(s) : s\in S'\}. $$

If $T'\subseteq T$, then the preimage of $T'$ is

$$ f^{-1}(T') = \{ s\in S : f(s) \in T'\}. $$

Therefore, $\range(f) = f(S)$.

Note that although both the inverse and the preimage use the notation $f^{-1}$, the inverse is a function of elements in $T$ while the preimage is a function of subsets in $T$, so they should be distinguishable.

When the domain $S$, the codomain $T$, and a formula $f$ are given, we say $f$ is well-defined if $f$ is indeed a function.
Here are some examples.

  1. The value $f(s)$ should exist in $T$: Let $S = T = \mathbb{R}$ and $f(x) = \frac{1}{x}$. Then $f$ is not well-defined since $f(0)$ is not a real number.
  2. The value of an element under different representation should have the same value: This happens when an element has several equivalent representation, e.g., $\frac{1}{2} = \frac{2}{4}$. Let $S = \mathbb{Q} \times \mathbb{Q}$, $T = \mathbb{Q}$, and $f(\frac{a}{b}, \frac{c}{d}) = \frac{a+c}{b+d}$. Thus, we have $(\frac{1}{2}, \frac{3}{3}) = (\frac{2}{4}, \frac{3}{3})$ but $f(\frac{1}{2}, \frac{3}{3}) = \frac{4}{5} \neq f(\frac{2}{4}, \frac{3}{3}) = \frac{5}{8}$.

Side stories¶

  • countable

Experiments¶

Exercise 1¶

執行以下程式碼。

Run the code below.
In [ ]:
### code
set_random_seed(0)
print_ans = False
inj = choice([True, False])
sur = choice([True, False])
S = list(range(1,5))
if inj and sur:
    T = list(range(1,5))
if inj and not sur:
    T = list(range(1,6))
if not inj and sur:
    T = list(range(1,4))
if not inj and not sur:
    T = list(range(1,5))
while True:
    f = {s: choice(T) for s in S}
    ran = list(set(f.values()))
    if inj == (len(ran) == len(S)) and sur == (len(ran) == len(T)):
        break
    
print("S =", S)
print("T =", T)
print("f : S --> T")
for s in S:
    print("f(%s) ="%s, f[s])


if print_ans:
    print("Injective?", inj)
    print("Surjective?", sur)
    print("range(f) =", ran)
Exercise 1(a)¶

判斷 $f$ 是否為嵌射函數。

Is $f$ injective?
Exercise 1(b)¶

判斷 $f$ 是否為映射函數。

Is $f$ surjective?
Exercise 1(c)¶

寫出 $f$ 的值域。

Find the range of $f$.

Exercises¶

Exercise 2¶

找出符合各條件的函數。

Find examples of functions satisfying the following conditions.
Exercise 2(a)¶

給兩個函數的例子﹐一個是嵌射、一個不是。

Give an example of an injective function and an example of a non-injective function.
Exercise 2(b)¶

給兩個函數的例子﹐一個是映射、一個不是。

Give an example of a surjective function and an example of a non-surjective function.
Exercise 3¶

令 $S = \{1,2,3,4\}$、
$T = \{1,2,3,4\}$、且

$$ \begin{aligned} f : S &\rightarrow T \\ f(1) &= 2 \\ f(2) &= 3 \\ f(3) &= 4 \\ f(4) &= 1 \end{aligned}. $$ Let $S = \{1,2,3,4\}$, $T = \{1,2,3,4\}$, and $$ \begin{aligned} f : S &\rightarrow T \\ f(1) &= 2 \\ f(2) &= 3 \\ f(3) &= 4 \\ f(4) &= 1 \end{aligned}. $$
Exercise 3(a)¶

求 $f(\{1,3\})$。

Find $f(\{1,3\})$.
Exercise 3(b)¶

求 $f^{-1}(\{1,3\})$。

Find $f^{-1}(\{1,3\})$.
Exercise 3(c)¶

寫出 $f$ 的反函數。

Find the inverse function of $f$.
Exercise 3(d)¶

求 $f^{-1}(\{1\})$。

Find $f^{-1}(\{1\})$.
Exercise 3(e)¶

求 $f^{-1}(1)$。

Find $f^{-1}(1)$.
Exercise 4¶

令 $f:S\rightarrow T$ 為一函數。
證明以下關於投影區和送影區的性質。

Let $f: S\rightarrow T$ be a function. Prove the following properties about the domain and the codomain.
Exercise 4(a)¶

證明對任何子集 $S'\subseteq S$ 都有 $S'\subseteq f^{-1}(f(S'))$。
找一個例子讓 $S'\subsetneq f^{-1}(f(S'))$。

Prove that $S'\subseteq f^{-1}(f(S'))$ for any $S'\subseteq S$. Find an example where $S'\subsetneq f^{-1}(f(S'))$.
Exercise 4(b)¶

證明對任何子集 $T'\subseteq T$ 都有 $T'\supseteq f(f^{-1}(T'))$。
找一個例子讓 $T'\supsetneq f(f^{-1}(T'))$。

Prove that $T'\supseteq f(f^{-1}(T'))$ for any $T'\subseteq T$. Find an example where $T'\supsetneq f(f^{-1}(T'))$.
Exercise 4(c)¶

證明若 $f$ 是嵌射﹐
則對任何子集 $S'\subseteq S$ 都有 $S'= f^{-1}(f(S'))$。

Suppose $f$ is injective. Prove that $S'= f^{-1}(f(S'))$ for any $S'\subseteq S$.
Exercise 4(d)¶

證明若 $f$ 是映射﹐
則對任何子集 $T'\subseteq T$ 都有 $T'= f(f^{-1}(T'))$。

Suppose $f$ is surjective. Prove that $T'= f(f^{-1}(T'))$ for any $T'\subseteq T$.
Exercise 5¶

在以下集合中找到一個對射。
(兩個集合間如果存在一個對射﹐則它們的 數量級 就被視為是一樣的。
這個現象在個數有限的時候很自然﹐
但當個數無限多的時候會出現一個集合和它的子集個數一樣多的狀況﹐有些違反直覺﹐
但其實這現象就類似於 $\infty + 1 = \infty$ 這種概念﹐在無限大的時候是可接受的。
所有和自然數同樣數量級的集合﹐我們就說這樣的集合大小是 無窮可數 多個。
所以在當代的數學定義裡 $|\mathbb{N}| = |\mathbb{Z}| = |\mathbb{Q}|$﹐
但 $|\mathbb{R}| \neq |\mathbb{N}|$。)

For the following pairs of sets, find a bijection between them. When there is a bijection between two sets, then we believe the two sets have the same **cardinality** . This is natural for finite sets. However, it could be counter-intuitive for infinite sets since sometimes a infinite set has the same cardinality with its proper subset. Indeed, this is similar to the idea of $\infty + 1 = \infty$, which is acceptable. A set that has the same cardinality with the set of natural numbers is called **countable** , or **countably infinite** . Therefore, in modern mathematics, we have $|\mathbb{N}| = |\mathbb{Z}| = |\mathbb{Q}|$, but $|\mathbb{R}| \neq |\mathbb{N}|$.
Exercise 5(a)¶

令 $S = \{1,2,3\}$ 且 $T = \{x,y,z\}$。
找一個 $S$ 到 $T$ 的對射。

Let $S = \{1,2,3\}$ and $T = \{x,y,z\}$. Find a bijection between $S$ and $T$.
Exercise 5(b)¶

令 $S = \mathbb{Z}$ 且 $T = 2\mathbb{Z} = \{2z: z\in\mathbb{Z}\}$。
找一個 $S$ 到 $T$ 的對射。

Let $S = \mathbb{Z}$ and $T = 2\mathbb{Z} = \{2z: z\in\mathbb{Z}\}$. Find a bijection between $S$ and $T$.
Exercise 5(c)¶

令 $S = 2\mathbb{Z} = \{2z : z\in\mathbb{Z}\}$ 且 $T = 2\mathbb{Z} + 1 = \{2z+1 : z\in\mathbb{Z}\}$。
找一個 $S$ 到 $T$ 的對射。

Let $S = 2\mathbb{Z} = \{2z : z\in\mathbb{Z}\}$ and $T = 2\mathbb{Z} + 1 = \{2z+1 : z\in\mathbb{Z}\}$. Find a bijection between $S$ and $T$.
Exercise 5(d)¶

令 $S = \mathbb{N} = \{1,2,3,\ldots\}$ 且 $T = \mathbb{Z}$。
找一個 $S$ 到 $T$ 的對射。

Let $S = \mathbb{N} = \{1,2,3,\ldots\}$ and $T = \mathbb{Z}$. Find a bijection between $S$ and $T$.