lect_14 - Functions Margaret M. Fleck 19 February 2010 This...

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: Functions Margaret M. Fleck 19 February 2010 This lecture starts the material in section 2.3 of Rosen. It discusses functions and introduces the concepts of one-to-one and onto. 1 Announcements Another reminder of the upcoming midterm. Remember to bring your ID. (But we do have a backup plan if one or two of you forget.) This lecture is brought to you by the number 65535. (This is 2 16 1, i.e. the largest number you can store in a 16-bit unsigned integer variable.) Another useful fact is that 1000 is approximately equal to 2 10 . This is helpful when determining how large a number you will get when trying to access locations in computer memory, especially for big memory sizes. 2 Functions We all know roughly what functions are, from high school and (if youve taken it) calculus. Youve mostly seen functions whose inputs and outputs are numbers, defined by an algebraic formula such as f ( x ) = 2 x + 3. Were going to generalize and formalize this idea, so we can talk about functions with other sorts of input and output values. 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 . For example, lets define g : Z Z by the formula g ( x ) = 2 x . The domain and co-domain of this function are both Z . 1 Notice that the domain and co-domain are part of the definition of the function, just like the input/output type declarations for a function in a programming language. Suppose we define h : N N such that h ( x ) = 2 x . This is a different function from g because the declared domain and co- domain are different. Two functions are equal if they have the same domain, the same co- domain, and assign the same output value to each input value. The inputs and outputs to functions dont have to be numbers and a function doesnt have to be defined by an algebraic formula. Its sufficient to describe a clear, explicit procedure for finding the output value, given the...
View Full Document

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

Page1 / 6

lect_14 - Functions Margaret M. Fleck 19 February 2010 This...

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

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