310 likes | 462 Vues
ฟังก์ชัน (Function). บทนำ. ในแคลคูลัส เราคุ้นเคยกันดีกับฟังก์ชัน f ที่มีค่าเป็นจำนวนจริง ซึ่งกำหนดด้วยตัวแปรอิสระ x ℝ และมีตัวแปรตาม y = f ( x ), โดยที่ y ℝ .
E N D
บทนำ • ในแคลคูลัส เราคุ้นเคยกันดีกับฟังก์ชัน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 • • • • y • • • • • x Bipartite Graph Plot ภาพประกอบการแทนฟังก์ชัน ฟังก์ชันสามารถที่จะแทนด้วยรูปภาพในแบบต่างๆ ได้หลายลักษณะดังนี้ f f • • a b A B Like Venn diagrams
ฟังก์ชันกับตรรก • หมายเหตุประพจน์ใดๆ สามารถพิจารณาเป็นฟังก์ชันจาก “สถานการณ์” ที่ทอดค่าไปยังค่าความจริง {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}
ศัพท์เฉพาะที่ใช้ในฟังก์ชันศัพท์เฉพาะที่ใช้ในฟังก์ชัน นิยาม Letf:AB, and f(a)=b (where aA & bB).Then A 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 rangeRBof f is R={b | af(a)=b }. We also saythe signatureof f is A→B.
เรนจ์เปรียบเทียบกับโคโดเมนเรนจ์เปรียบเทียบกับโคโดเมน หมายเหตุ • เรนจ์หรือพิสัยของฟังก์ชันไม่จำเป็นต้องเท่ากับสมาชิกในโคโดเมนทุกตัว • โคโดเมนคือเซตของฟังก์ชันที่ถูกทอดค่าจากสมาชิกแต่ละตัวในโดเมน • เรนจ์เป็นเซตเฉพาะและเป็นเซตย่อยในโคโดเมนที่ถูกทอดค่าจากเซตโดเมน นั่นคือR={b | af(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 C . a . g(a) . f(g(a))
อิมเมจของเซตที่อยู่ภายใต้ฟังก์ชันอิมเมจของเซตที่อยู่ภายใต้ฟังก์ชัน Def. Letf: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-one Def.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-one Bipartite (2-part) graph representations of functions that are (or not) one-to-one: a• •1 • • • • b• •2 • • • c• • • •3 • • d • • • • • •4 • • •5 • Not even a function! Not one-to-one One-to-one
Sufficient Conditions for 1-1ness For 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 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 Aonto (over, covering) the entirety of the set B, not just over a piece of it. Ex.Let f:ℝ ℝ. f(x) = x3is onto, f(x) =x2isnot 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 isboth one-to-one and onto. • Def.For bijections f:AB, there exists an inverseof f, writtenf 1:BA, which is the unique function such that • (where IA is the identity function on A)
The Identity Function • Def.For any domain A, the identity functionI: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 Illustrations The identity function: y y = I(x) = x x Domain and range
กราฟของฟังก์ชัน 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 Functions In 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. 3 . 1.6=2 2 . 1.6 . 1 1.6=1 0 . 1.4= 1 1 . 1.4 . 2 1.4= 2 . . . 3 3 3=3= 3
Plots 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: f(x) Set of points (x, f(x)) +2 3 x +3 2
ทบทวนเรื่องฟังก์ชัน • 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