CSCE 235
Light
Bulb 4
February 16, 2004
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. 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.
4. In a kitchen, there are many appliances with many functions: an oven, a fridge, a dishwasher, a microwave, a rice cooker, a coffee maker, and so on. So, we say that a kitchen has many functions. Now, for each appliance, there are several possible functions. A microwave can cook, warm, thaw, and so on. An oven can bake, broil, warm, and so on. A rice cooker can cook rice, steam vegetables, etc. A fridge can freeze meat products, keep vegetables fresh, keep drinks cold, etc. How do you define, then, a kitchen with all these functions? One way is to build a hierarchy—a kitchen has a number of appliances. And then from there, we list the set of functions for each appliance. Then, to derive the functions of a kitchen, we traverse the hierarchy. By going through these exercises, one will be able to define the domain and the target. Once we can define the domain and the target, we then can actually treat the kitchen as a blackbox to simplify our computation and reasoning. That actually is very helpful in large project design (software or hardware or both).