函数、定义域与值域
了解函数、其定义域、陪域及其值域。
\begin{align*} A &= {1,2,3,4,5}\ B&={a,b,c,d,e,g} \end{align*}
f_1 = {(1,c),(2,c),(3,g),(4,g),(5,g)}
\begin{align*} f_2 &= {(1,b),(2,c),(3,d),(4,e),(5,g)} \ f_3 &={(1,a),(2,b),(3,c),(4,d),(5,e)} \ f_4 &= {(1,a),(2,b),(3,b),(4,d),(5,e)} \end{align*}
g_1 = {(1,a),(2,c),(3,d),(5,e)}
\begin{align*} g_2 &= {(1,a),(2,b),(3,b),(3,c),(4,d),(5,e)} \ g_3 &= {(1,a),(1,c),(3,d),(3,e),(3,g)} \ g_4 &= {(1,a),(2,b),(3,b),(4,d),(5,e),(5,g)} \end{align*}
f_5 = {(a, 1),(b, 1),(c, 2),(d, 2),(e, 3),(g, 3)}
\begin{align*} f_6 &= {(a,1),(b,2),(c,3),(d,4),(e,5),(g,3)} \ f_7 &= {(a, 2),(b, 3),(c, 4),(d, 5),(e, 2),(g, 1)}\ f_8 &= {(a, 4),(b, 1),(c, 5),(d, 2),(e, 4),(g, 3)} \end{align*}
\begin{align*} f_9 &= {(g,h),(h,k),(k,m),(m,p),(p,g)} \ f_{10} &= {(g,p),(h,m),(k,k),(m,h),(p,g)} \ f_{11} &= {(g,h),(h,m),(k,h),(m,h),(p,m)} \ f_{12} &= {(g,p),(h,p),(k,g),(m,g),(p,h)} \end{align*}
1def is_function(domain, codomain, function): 2 # Check that the image of every element in the domain is defined 3 for element in domain: 4 # Check if there exists an image of the element 5 if not any(pair[0] == element for pair in function): 6 # If image of element does not exist, return False 7 return False 8 9 # Check if each element of the domain has only one image 10 preimages = set() 11 for pair in function: 12 if pair[0] in preimages: 13 return False 14 preimages.add(pair[0]) 15 16 # Check that the range is a subset of the codomain 17 for pair in function: # Pair = (element, image) 18 # Check if every element has an image in the codomain 19 if pair[1] not in codomain: 20 # If image of any element is not in the codomain, return False 21 return False 22 return True 23 24# Create a domain set 25domain = {1, 2, 3} 26# Create a codomain set 27codomain = {4, 5, 6} 28# Creating a relation 29function = {(1, 4), (2, 4), (3, 6)} 30is_a_function = is_function(domain, codomain, function) 31# Relation is a function or not 32if is_a_function: 33 print("It is a function.") 34else: 35 print("It is not a function.")
Quiz
考虑两个集合 和 。关于下面给出的任意函数,以下哪个陈述是 错误 的?