Lecture 6 - Functions and Onto

Lecture 6 - Functions and Onto - Functions and Onto...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Functions and Onto (Computer Science Notes) Functions We’ll be using a broader range of functions, whose input and/or output values may be integers, strings, characters, and the like. Suppose that A and B are sets, then a function f from A to B (shorthand: f : A → B) is an assignment of exactly one element of B (i.e. the output value) to each element of A (i.e. the input value) A is called the domain of f and B is called the co-domain If x is an element of A, then the value f(x) is also known as the image of x, output is an image We can write out the elements of A as x1, x2, . . . , xn. When constructing a function f : A → B, we have p ways to choose the output value for x1 The choice of f(x1) doesn’t affect our possible choices for f(x2): we also have p choices for that value we have p^n possible ways to construct our function f For any set A, the identity function idA maps each value in A to itself. That is, idA : A → A and idA(x) = x When Are Functions Equal? To be equal, two functions must have the same domain, the same co-domain, and assign the same output value to each input value • f: N → N such that f(x) = 2x. • f: R → R such that f(x) = 2x Describe quite different functions, even though they are based on the same equation What Isn’t A Function? For each input value, a function must provide one and only one output value, so if there exist an input with no output it’s not a function or if one input has two outputs it’s not a function Images and Onto The image of the function f: A → B is the set of values produced when f is applied to all elements of A. That is, the image is f(A) = {f(x) : x A} For example, suppose M = {a, b, c, d}, N = {1, 2, 3, 4}, and our function g: M → N is as in the following diagram. Then g(A) = {1, 3, 4} A 1 B 1 2 C 3 D 4 A function f : A → B is onto (or subjective) if its image is its whole co-domain y B, x A, f(x) = y Whether a function is onto critically depends on what sets we’ve picked for its domain
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/16/2011 for the course CS 173 taught by Professor Erickson during the Spring '08 term at University of Illinois, Urbana Champaign.

Page1 / 3

Lecture 6 - Functions and Onto - Functions and Onto...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online