CSCE 235

Light Bulb 4

February 17, 2002 

 

1.   Why do we need functions?  A function is basically a tool or mechanism that allows you “traverse” from one set of items to another set of items.  We have studied about sets and graphs as basic structures.  Now, we want to learn how to manipulate them.  Functions are one approach to manipulate them.  A function explicitly defines how to get from one set of items to another.  This explicit definition is very useful in many areas such as computer science, business, physics, chemistry, biology, mathematics, accounting, etc. It allows a formal representation of a system/algorithm/method, the design and implementation, and the analysis of such a system/algorithm/method.  Properties associated with various types of functions also allow us to predict the behavior of function in a particular domain, for a particular application, etc.  Functions are wonderful mechanisms for manipulating basic structures such as sets, and functions are everywhere.

 

2.   In Computer Science, we obtain talk about functions.  A function Foobar, given an argument Wombat, returns, say, a Boolean value.  So, we say that the function Foobar maps a value of Wombat to a Boolean value.  All possible values of Wombat are a set, and so are all the possible values of a Boolean variable.  So, functions are not new.  We have seen them, talked about them, designed them, and used them.  In Physics, we have functions to find out the velocity of an object given certain acceleration.  In Chemistry, we have functions to find out the atomic number of an element.  In Business, we have functions to compute the compound interests given a certain amount of money.  In Electrical Engineering, we have functions to find out the value of the voltage of a particular node given a circuit.

 

3.   An example.  Let us use the 12 men’s basketball teams in the Big 12 conference as the domain:  KU, NU, CU, ISU, OSU, OU, TT, UT, TAMU, BU, KSU, and MU.  Let us define two functions: currentNumberOfConferenceWins(x) and currentNumberOfConferenceLosses(x).  The domain set is { KU, NU, CU, ISU, OSU, OU, TT, UT, TAMU, BU, KSU, MU }, and what is the target set?  The target set is of course the set of positive integers.  What is the range of the two functions?  Since there are only 16 conference games per team in the regular season, the range of each function is from 0 to 16.  So, as of February 22, 2002, currentNumberOfConferenceWins(KU) = 13, and currentNumberOfConferenceLosses(KU) = 0; and currentNumberOfConferenceWins(NU) = 5, and currentNumberOfConferenceLosses(NU) = 8.  So, in this simple example, we are able to explicitly define the domain, the functions, the target, and the range.  This allows us to design and implement the functions without ambiguity.  It also allows other people to examine our design, to make our design accountable.

 

4.   In a car, there are many functions.  There are, for example, up to 4 functions that control the windshield wipers.  What is the domain?  What is the target?  Does the domain only consist of the windshield wipers?  Are there many functions, then?  There are several ways to look at this.  One way we can do is to define a function called “Perform(x)” where x is one of the options for controlling the windshield wipers.  Thus, the domain becomes { “clean windshield”, “periodically slow”, “periodically average”, “periodically fast”, “continuous”, “once” }.  The target becomes { “windshield wipers move 5 times and stop”, “windshield wipers move periodically slow but do not stop”, …., “windshield wipers move once and stop” }.  So we define the function, the domain, and the target.  When we examine a car, we can apply the function “Perform”, give it a different domain value each time, and try to observe the targeted outcome.  If the targeted outcome is not observed, then we know that the function “Perform” applied to a particular domain value no longer works.  This allows us to systematically analyze a system, a methodology, an approach, a design, an algorithm, and so on.