Post on 12-Feb-2016
description
ฟงัก์ชนัฟงัก์ชนั(Functio(Function)n)
บทนำ�บทนำ�• ในแคลคลัูส เราคุ้นเคยกันดีกับฟงัก์ชนั f
ท่ีมค่ีาเป็นจำานวนจรงิ ซึ่งกำาหนดด้วยตัวแปรอิสระ xℝ และมตัีวแปรตาม y=f(x), โดยท่ี yℝ.
• ฟงัก์ชนัในรูปแบบทัว่ไป เป็นการกำาหนดสมาชกิของเซตใดๆ ซึ่งเป็นท่ีรูกั้นวา่เป็นการสง่ค่าหรอืทอดค่า (Mapping) จากเซตหน่ึงไปสูอี่กเซตหน่ึง
นิย�มแบบทั่วไปของฟงัก์ชนันิย�มแบบทั่วไปของฟงัก์ชนั• นิยาม สำาหรบัเซต A, B ใดๆ, สามารถกล่าวได้
วา่ฟงัก์ชนั f จาก (หรอื “mapping”) A ไป B (f:AB) เป็นการกำาหนดค่าแบบเจาะจงเมื่อ f(x)B โดยท่ี xA
• Some further generalizations of this idea:– A partial (non-total) function f assigns zero
or one elements of B to each element xA.– Functions of n arguments; relations.
ภ�พประกอบก�รแทนฟงัก์ชนัภ�พประกอบก�รแทนฟงัก์ชนัฟงัก์ชนัสามารถท่ีจะแทนด้วยรูปภาพในแบบ
ต่างๆ ได้หลายลักษณะดังนี้
• •
A B
a b
f
f
x
y
PlotLike Venn diagrams
••••
••
••
•Bipartite Graph
A B
ฟงัก์ชนักับตรรกฟงัก์ชนักับตรรก• หม�ยเหต ุประพจน์ใดๆ สามารถพจิารณาเป็นฟงัก์ชนั
จาก “สถานการณ์” ท่ีทอดค่าไปยงัค่าความจรงิ {T,F}ตรรกใดๆ จะถกูเรยีกวา่ “situation theory”
Ex. p=“ฝนกำาลังจะตก”; s=สภาพแวดล้อมในขณะนัน้, ดังนัน้
p(s){T,F}.• หม�ยเหต ุตัวดำาเนินการใดๆ ของประพจน์สามารถ
พจิารณาเป็นฟงัก์ชนัท่ีทอดค่าจากคู่อันดับของค่าความจรงิไปสูค่่าความจรงิ
Ex. ((F,T)) = T.→((T,F)) = F.
ฟงัก์ชนักับตรรกฟงัก์ชนักับตรรก............((ต่อต่อ))• หม�ยเหต ุพรดีิเคตใดๆ เป็นฟงัก์ชนัของวตัถุ
ต่างๆ ที่ทอดค่าไปยงัประพจน์ท่ีมค่ีาความจรงิEx.
P :≡ “is 7 feet tall”; P(Mike) = “Mike is 7 feet tall.” = False.
• หม�ยเหต ุสายของบติ B ท่ีมคีวามยาว n บติ สามารถพจิารณาเป็นฟงัก์ชนัชนิดหนึ่ง ท่ีทอดค่าจากตำาแหน่งของบติ {1,…,n} ไปสูค่่าของบติในตำาแหน่งนัน้ๆ {0,1}.
Ex.B=101 B(3)=1.
ฟงัก์ชนักับเซตฟงัก์ชนักับเซต• หม�ยเหต ุเซต S ใดๆ ท่ีอยูใ่นเซตเอกภพสมัพทัธ ์
U สามารถพจิารณาเป็นฟงัก์ชนัท่ีทอดค่าสมาชกิต่างๆใน U ไปสูค่่า {T, F}, หรอืกล่าวอีกอยา่งหน่ึงก็คือสมาชกิแต่ละตัวใน U อยูใ่นเซต S หรอืไม ่
ตัวอยา่ง: S={3} fS(0)=F, fS(3)=T.• หม�ยเหต ุตัวดำาเนินการของเซตใดๆ เชน่ ,,
เป็นฟงัก์ชนัท่ีทอดค่าจากคู่ต่างๆ ของเซตท่ีถกูดำาเนินการไปสูเ่ซตใหมท่ี่เป็นผลของจากการดำาเนินการ
ตัวอยา่ง: (({1,3},{3,4})) = {3}
ศัพท์เฉพ�ะท่ีใชใ้นฟงัก์ชนัศัพท์เฉพ�ะท่ีใชใ้นฟงัก์ชนันิย�ม Let f:AB, and f(a)=b (where
aA & bB). ThenA is the domain of f. B is the codomain of f.b is the image of a under f.a is a pre-image of b under f.
In general, b may have more than 1 pre-image.The range RB of f is R={b | a f(a)=b }.
We also saythe signatureof f is A→B.
เรนจเ์ปรยีบเทียบกับโคโดเมนเรนจเ์ปรยีบเทียบกับโคโดเมนหม�ยเหตุ• เรนจห์รอืพสิยัของฟงัก์ชนัไมจ่ำาเป็นต้อง
เท่ากับสมาชกิในโคโดเมนทกุตัว• โคโดเมนคือเซตของฟงัก์ชนัท่ีถกูทอดค่า
จากสมาชกิแต่ละตัวในโดเมน• เรนจเ์ป็นเซตเฉพาะและเป็นเซตยอ่ยในโค
โดเมนท่ีถกูทอดค่าจากเซตโดเมน นัน่คือ R={b | a f(a)=b }
ตัวอย�่งของเรนจเ์มื่อเทียบกับโคตัวอย�่งของเรนจเ์มื่อเทียบกับโคโดเมนโดเมน
ตัวอย�่ง สมมุติในการกำาหนดเกรดใหนั้กศึกษา: “f เป็นฟงัก์ชนัท่ีมกีารทอดค่าชื่อของนักศึกษาท่ีเรยีนวชิาน้ี โดยเกรดท่ีจะใหกั้บนักศึกษาคือ {A,B,C,D,F}”
• จากตัวอยา่งน้ี, เซตของโคโดเมนคือ: __________, และเซตของเรนจคื์อ ________.
• ถ้านักศึกษาทกุคนท่ีเรยีนวชิาน้ีได้เกรด A หรอืไมก็่ได้เกรด Bดังนัน้เรนจข์องฟงัก์ชนั f คือ _________, สว่นเซตของโคโดเมนคือ .
{A,B,C,D,F} unknown!
{A,B}still {A,B,C,D,F}!
นิย�มโดยท่ัวไปของตัวดำ�เนินก�รนิย�มโดยท่ัวไปของตัวดำ�เนินก�รในแง่ของฟงัก์ชนัในแง่ของฟงัก์ชนั
นิย�ม ตัวดำาเนินการ n-ary ใดๆ ที่กระทำาบนเซต S เป็นฟงัก์ชนัจากเซตอันดับ n-tuples ท่ีเป็นสมาชกิของ S ไปยงัตัวมนัเอง
Ex. ถ้า S={T,F}, can be seen as a unary operator, and, are binary operators on S.
Ex. and are binary operators on the set of all sets.
ก�รสร�้งตัวดำ�เนินก�รของก�รสร�้งตัวดำ�เนินก�รของฟงัก์ชนัฟงัก์ชนัถ้า (“dot”) เป็นตัวดำาเนินการใดๆ บนเซต
B ดังนัน้เราสามารถขยาย เพื่อใชแ้ทนตัวดำาเนินการของฟงัก์ชนั f:AB.
Ex. ตัวดำาเนินการไบนารใีดๆ :BBB, และฟงัก์ชนั f,g:AB, ท่ีกำาหนด
อยูใ่นรูป(f g):AB เพื่อกำาหนดเป็นฟงัก์ชนัท่ีนิยามโดยaA, (f g)(a) = f(a)g(a)
ตัวอย�่งของตัวดำ�เนินก�รตัวอย�่งของตัวดำ�เนินก�รฟงัก์ชนัฟงัก์ชนั
,× (“plus”,“times”) เป็นตัวดำาเนินการไบนารี่บนเซตจำานวนจรงิ ℝ. (Normal addition & multiplication.)
ทัง้สองตัวดำาเนินทำาใหเ้ราสามารถนำาฟงัก์ชนัมารวมและคณูเขา้ด้วยกันได้ดังน้ี
Def. Let f, g: ℝ ℝ.(f g): ℝ ℝ, where (f g)(x) = f(x) g(x)(f × g): ℝ ℝ, where (f × g)(x) = f(x) × g(x)
ตัวดำ�เนินก�รฟงัก์ชนัเชงิประกอบตัวดำ�เนินก�รฟงัก์ชนัเชงิประกอบนิยาม กำาหนดให ้g:AB และ f:BC. ฟงัก์ชนัเชงิ
ประกอบของ (composition function) f และ g, เขยีนแทนด้วย f○g, ซึ่งกำาหนดได้โดย (f○g)=f(g(a))
ขอ้สงัเกต ○ (like Cartesian , but unlike +,,) is non-commuting. (Generally, f○g g○f.)
A g B f CA g B f C
. . a a . . g(a) g(a) . . f(g(a))f(g(a))
อิมเมจของเซตท่ีอยูภ่�ยใต้อิมเมจของเซตท่ีอยูภ่�ยใต้ฟงัก์ชนัฟงัก์ชนั
Def. Let f:AB, and SA.The image of S under f is simply the set of all images (under f) of the elements of S.
f(S) : {f(s) | sS} : {b | sS: f(s)=b}.
Note the range of f can be defined as simply the image (under f) of f’s domain!
ฟงัก์ชนัแบบ ฟงัก์ชนัแบบ one-to-oneone-to-oneDef. A function is one-to-one (1-1), or injective, or
an injection, iff every element of its range has only 1 pre-image. Formally: given f:AB,
“f is injective” : xy{f(x) = f(y) x = y}.Only one element of the domain is mapped to any
given one element of the range.Domain & range have same cardinality. What about
codomain?Memory jogger: Each element of the domain is
injected into a different element of the range.Compare “each dose of vaccine is injected into a different
patient.”
ก�รทดค่�แบบ ก�รทดค่�แบบ one-to-oneone-to-oneBipartite (2-part) graph representations of
functions that are (or not) one-to-one:
d •c•b•a•
•3•4
•2•1
•5
One-to-one
••••
••
••
•Not one-to-one
••••
••
••
•Not even a function!
Sufficient Conditions for 1-1nessSufficient Conditions for 1-1nessFor functions f over numbers, we say:
f is strictly (or monotonically) increasing iff x>y f(x)>f(y) for all x,y in domain;
f is strictly (or monotonically) decreasing iff x>y f(x)<f(y) for all x,y in domain;
If f is either strictly increasing or strictly decreasing, then f is one-to-one.
Ex.f(x) = x3
f(x) = 1/x (Converse is not necessarily true)
ฟงัก์ชนัออนท ูฟงัก์ชนัออนท ู(Onto or (Onto or Surjective)Surjective)
Def. A function f:AB is onto or surjective or a surjection iff its range is equal to its codomain (bB, aA: f(a)=b).
Remark. An onto function maps the set A onto (over, covering) the entirety of the set B, not just over a piece of it.
Ex. Let f:ℝ ℝ.f(x) = x3 is onto, f(x) =x2 is not onto. (Why?)
ก�รทอดค่�บนฟงัก์ชนัออนทูก�รทอดค่�บนฟงัก์ชนัออนทูSome functions that are, or are not, onto
their codomains:
Onto(but not 1-1)
••••
•
•
••
•Not Onto(or 1-1)
••••
•
•
••
•
Both 1-1and onto
••••
•••
•1-1 butnot onto
••••
•••
•
•
Bijections• Def. A function f is said to be a bijection,
(or a one-to-one correspondence, or reversible, or invertible,) iff it is both one-to-one and onto.
• Def. For bijections f:AB, there exists an inverse of f, written f 1:BA, which is the unique function such that – (where IA is the identity function on A)
Inverse functions
a = f-1(b)
A
b = f(a)
B
f-1(b)
f(a)
f-1
f
a 1 1 a
b 2 2 b
c 3 3 c
d B B d
A A (ก) f: A B ไม่เป็น (ข) f-1:B A หน่ึงต่อหน่ึงแต่มีการแผ่ทัว่ถึง ไม่เป็นฟงัก์ชนั
The Identity FunctionThe Identity Function• Def. For any domain A, the identity function
I:AA (variously written, IA, 1, 1A) is the unique function such that aA, I(a)=a.
• Some identity functions you’ve seen: ing 0, ·ing by 1, ing with T, ing with F, ing with , ing with U.
• Remark. The identity function is always both one-to-one and onto (bijective).
Identity Function IllustrationsIdentity Function IllustrationsThe identity function:
••
••
••
••
•
Domain and range x
y y = I(x) = x
กร�ฟของฟงัก์ชนักร�ฟของฟงัก์ชนัWe can represent a function f:AB as a
set of ordered pairs {(a,f(a)) | aA}.Note that a, there is only 1 pair (a,b).
Later topic: relations loosen this restriction.
For functions over numbers, we can represent an ordered pair (x,y) as a point on a plane. A function is then drawn as a curve (set of
points), with only one y for each x.
A Couple of Key FunctionsIn discrete math, we will frequently use the following
two functions over real numbers:
Def. The floor function ·:ℝ→ℤ, where x (“floor of x”) means the largest (most positive) integer x. Formally, x :≡ max({iZ|i≤x}).
Def. The ceiling function ·:ℝ→ℤ, where x (“ceiling of x”) means the smallest (most negative) integer x. Formally, x :≡ min({iZ|i≥x})
Visualizing Floor & Ceiling
Real numbers “fall to their floor” or “rise to their ceiling.”
Note that if xZ,x x &x x
Note that if xZ, x = x = x.
01
123
23
...
...
. . .
1.6
1.6=2
1.4= 2
1.4
1.4= 1
1.6=1
33=3= 3
Plots with floor/ceilingPlots with floor/ceiling• Note that for f(x)=x, the graph of f includes the
point (a, 0) for all values of a such that a0 and a<1, but not for the value a=1.
• We say that the set of points (a,0) that is in f does not include its limit or boundary point (a,1). – Sets that do not include all of their limit points are
generally called open sets. • In a plot, we draw a limit point of a curve using an
open dot (circle) if the limit point is not on the curve, and with a closed (solid) dot if it is on the curve.
Plots with floor/ceiling: Example
Plot of graph of function f(x) = x/3:
x
f(x)
Set of points (x, f(x))
+3
2
+2
3
ทบทวนเรื่องฟงัก์ชนัทบทวนเรื่องฟงัก์ชนั• Function variables f, g, h, … • Notations: f:AB, f(a), f(A).• Terms: image, preimage, domain,
codomain, range, one-to-one, onto, strictly (in/de)creasing, bijective, inverse, composition.
• Function unary operator f 1, binary operators , , etc., and ○.
• The RZ functions x and x.
จงเขยีนหรอืยกตัวอยา่งฟงัก์ชนัต่อไปน้ี1 ฟงัก์ชนัแบบหน่ึงต่อหน่ึง (One-to-one) แต่ไมเ่ป็น
ฟงัก์ชนัแบบทัว่ถึง (Onto)2 ฟงัก์ชนัแบบทัว่ถึงแต่ไมเ่ป็นฟงัก์ชนัแบบหน่ึงต่อหน่ึง3 ฟงัก์ชนัท่ีเป็นทัง้แบบทัว่ถึงและแบบหน่ึงต่อหน่ึง4 ฟงัก์ชนัเชงิประกอบ (Composite function) เมื่อ g =
{(1, b), (2, c), (3, a)} โดยท่ี g เป็นฟงัก์ชนัจากเซต X = {1, 2, 3} ไปยงัเซต A = {a, b, c, d} สว่นฟงัก์ชนั f = {(a, x), (b, x), (c, z), (d, w)} โดยท่ี f เป็นฟงัก์ชนัจาก A ไปยงั B = {w, x, y, z}ใหห้า gf