Difference between revisions of "SP18:Lecture 5 Functions"

From CS2800 wiki
Line 4: Line 4:
 
* This material was covered in lectures [http://www.cs.cornell.edu/courses/cs2800/2017sp/lectures/lec02-sudoku.html 2 (modeling problems)] and [http://www.cs.cornell.edu/courses/cs2800/2017sp/lectures/lec04-functions.html 4 (functions)] in 2017sp.
 
* This material was covered in lectures [http://www.cs.cornell.edu/courses/cs2800/2017sp/lectures/lec02-sudoku.html 2 (modeling problems)] and [http://www.cs.cornell.edu/courses/cs2800/2017sp/lectures/lec04-functions.html 4 (functions)] in 2017sp.
 
* [[File:lec05-board.pdf]]
 
* [[File:lec05-board.pdf]]
 +
 +
= Proof techniques continues =
 +
 +
= Functions =
 +
 +
{{:Function definition}}
 +
 +
{{:Image definition}}
 +
 +
== Function examples ==
 +
 +
* let <math>f(x) : [[ℝ]] [[→]] [[ℝ]]</math> be given by <math>f(x) := x^2</math>.  The [[domain]] and [[codomain]] of <math>f</math> are both <math>[[ℝ]]</math>; the [[image]] is <math>\{y ∈ [[ℝ]] [[\mid]] y ≥ 0\}</math>.
 +
 +
* we often draw functions:
 +
[[Image:fun-a2b1c3.svg]]
 +
The [[domain]] of <math>f</math> is <math>[[Enumerated set|\{a,b,c\}]]</math>, and the [[codomain]] of <math>f</math> is <math>[[Enumerated set|\{1,2,3\}]]</math>.
 +
 +
* another way to draw a function is with a table:
 +
{|
 +
| x || <math>f(x)</math>
 +
|-
 +
| a || 1
 +
|-
 +
| b || 1
 +
|-
 +
| c || 1
 +
|}
 +
This almost describes a [[function]]; the [[domain]] is clearly <math>\{a,b,c\}</math> (because if there were any other [[domain]] [[element]]s, <math>f</math> would not be a function); and the rule is clear.  However, the [[codomain]] is not clear: is it <math>[[Enumerated Set|\{1\}]]</math>?  Or <math>[[Enumerated Set|\{1,2,3\}</math>?  Or <math>[[ℕ]]</math>, or <math>[[ℝ]]</math>?  When describing a function with a table, the codomain should be specified somewhere.

Revision as of 10:44, 10 February 2018

We finished our list of proof techniques, adding implication ([math]\href{/cs2800/wiki/index.php?title=%5CRightarrow&action=edit&redlink=1}{\Rightarrow} [/math]) and existentials ([math]\href{/cs2800/wiki/index.php/%5Cexists}{\exists} [/math]). We then defined functions and discussed some examples.

Proof techniques continues

Functions

Function definition

Definition: Image
If [math]f : A \href{/cs2800/wiki/index.php/%E2%86%92}{→} B [/math], then the image of [math]f [/math] (written [math]\href{/cs2800/wiki/index.php?title=Im&action=edit&redlink=1}{im}(f) [/math]) is the set of values that are output by [math]f [/math]. Formally, [math]\href{/cs2800/wiki/index.php?title=Im&action=edit&redlink=1}{im}(f) \href{/cs2800/wiki/index.php/Definition}{:=} \href{/cs2800/wiki/index.php/Set_comprehension}{\{y ∈ B \mid} \href{/cs2800/wiki/index.php/%E2%88%83}{∃x} \href{/cs2800/wiki/index.php/%E2%88%88}{∈} A\text{ such that }y=f(x)\} [/math] or more succinctly, [math]\href{/cs2800/wiki/index.php?title=Im&action=edit&redlink=1}{im}(f) := \href{/cs2800/wiki/index.php/Set_comprehension}{\{f(x) \mid x ∈ A\}} [/math].

Function examples

  • let [math]f(x) : \href{/cs2800/wiki/index.php?title=%E2%84%9D&action=edit&redlink=1}{ℝ} \href{/cs2800/wiki/index.php/%E2%86%92}{→} \href{/cs2800/wiki/index.php?title=%E2%84%9D&action=edit&redlink=1}{ℝ} [/math] be given by [math]f(x) := x^2 [/math]. The domain and codomain of [math]f [/math] are both [math]\href{/cs2800/wiki/index.php?title=%E2%84%9D&action=edit&redlink=1}{ℝ} [/math]; the image is [math]\{y ∈ \href{/cs2800/wiki/index.php?title=%E2%84%9D&action=edit&redlink=1}{ℝ} \href{/cs2800/wiki/index.php/%5Cmid}{\mid} y ≥ 0\} [/math].
  • we often draw functions:

Fun-a2b1c3.svg The domain of [math]f [/math] is [math]\href{/cs2800/wiki/index.php/Enumerated_set}{\{a,b,c\}} [/math], and the codomain of [math]f [/math] is [math]\href{/cs2800/wiki/index.php/Enumerated_set}{\{1,2,3\}} [/math].

  • another way to draw a function is with a table:
x [math]f(x) [/math]
a 1
b 1
c 1

This almost describes a function; the domain is clearly [math]\{a,b,c\} [/math] (because if there were any other domain elements, [math]f [/math] would not be a function); and the rule is clear. However, the codomain is not clear: is it [math]\href{/cs2800/wiki/index.php?title=Enumerated_Set&action=edit&redlink=1}{\{1\}} [/math]? Or [math][[Enumerated Set|\{1,2,3\} [/math]? Or [math]\href{/cs2800/wiki/index.php/%E2%84%95}{ℕ} [/math], or [math]\href{/cs2800/wiki/index.php?title=%E2%84%9D&action=edit&redlink=1}{ℝ} [/math]? When describing a function with a table, the codomain should be specified somewhere.