explaining functions [Possibly OT]
Hi all, This might be a bit tangential to the topic; if so, my apologies. (I've been reading this list for a while, but have never posted before.) I'm a Python hobbyist, and am not involved in CS education, except peripherally. I am also a grad student in Philosophy who has, for a few years now, been teaching Introduction to Formal Logic to audiences largely composed of Philosophy and Linguistics undergrads with a small contingent of Computer Science undergraduates, too. I have found it difficult to get some of the humanities undergraduates to see the understand the general mathematical concept of a function. Occasionally, even some of the CS students (who, when I see them, have just begun) stumble with the concept, too. The best I have managed to come up with is to tell them that a function is like a 'black box' to which you feed some ordered input of the appropriate sort, and it gives you an output determined entirely by that input. I have found that, at least for the humanities students, getting them to understand some of the material is largely a matter of finding a useful metaphor (and, convincing them that the metaphor is an aid, not the thing in itself). That's been the only way to get the ones bothered by the mathematician's use of "if ... then ..." to accept it. (They don't like that "If 2 + 2 = 97 then I am King of the moon" and "If grass is green then sky is blue" are taken to be true.) So, I am wondering if others on the list have had difficulty getting students (particularly students not primarily studying Math or CS) to get the idea of a function? If so, I'd be very interested in what techniques were of use. Thanks, and I do apologize if this query is received as too peripherally related to the topic of the list. Best to all, Brian vdB
Michael Dawson's "Python Programming for the absolute beginner" has a cute analogy. He say, a function is like a pizza joint. You call it and give it your parameters (what kind of pizza you want) and it returns a pizza. :) Kent Brian van den Broek wrote:
Hi all,
This might be a bit tangential to the topic; if so, my apologies. (I've been reading this list for a while, but have never posted before.)
I'm a Python hobbyist, and am not involved in CS education, except peripherally. I am also a grad student in Philosophy who has, for a few years now, been teaching Introduction to Formal Logic to audiences largely composed of Philosophy and Linguistics undergrads with a small contingent of Computer Science undergraduates, too.
I have found it difficult to get some of the humanities undergraduates to see the understand the general mathematical concept of a function. Occasionally, even some of the CS students (who, when I see them, have just begun) stumble with the concept, too.
The best I have managed to come up with is to tell them that a function is like a 'black box' to which you feed some ordered input of the appropriate sort, and it gives you an output determined entirely by that input.
I have found that, at least for the humanities students, getting them to understand some of the material is largely a matter of finding a useful metaphor (and, convincing them that the metaphor is an aid, not the thing in itself). That's been the only way to get the ones bothered by the mathematician's use of "if ... then ..." to accept it. (They don't like that "If 2 + 2 = 97 then I am King of the moon" and "If grass is green then sky is blue" are taken to be true.)
So, I am wondering if others on the list have had difficulty getting students (particularly students not primarily studying Math or CS) to get the idea of a function? If so, I'd be very interested in what techniques were of use.
Thanks, and I do apologize if this query is received as too peripherally related to the topic of the list. Best to all,
Brian vdB
_______________________________________________ Edusig mailing list Edusig@python.org http://mail.python.org/mailman/listinfo/edusig
Isn't a math function the same as a computerscience function? You give the math function an x, and it returns a y. ie: f(x) = 2*(4x)^x or def f(x): print 2*((4*x)**x). Most people should be able to grasp that, if they've been through highschool algebra. On Sun, 05 Dec 2004 12:52:00 0500, Kent Johnson <kent37@tds.net> wrote:
Michael Dawson's "Python Programming for the absolute beginner" has a cute analogy. He say, a function is like a pizza joint. You call it and give it your parameters (what kind of pizza you want) and it returns a pizza.
:) Kent
Brian van den Broek wrote:
Hi all,
This might be a bit tangential to the topic; if so, my apologies. (I've been reading this list for a while, but have never posted before.)
I'm a Python hobbyist, and am not involved in CS education, except peripherally. I am also a grad student in Philosophy who has, for a few years now, been teaching Introduction to Formal Logic to audiences largely composed of Philosophy and Linguistics undergrads with a small contingent of Computer Science undergraduates, too.
I have found it difficult to get some of the humanities undergraduates to see the understand the general mathematical concept of a function. Occasionally, even some of the CS students (who, when I see them, have just begun) stumble with the concept, too.
The best I have managed to come up with is to tell them that a function is like a 'black box' to which you feed some ordered input of the appropriate sort, and it gives you an output determined entirely by that input.
I have found that, at least for the humanities students, getting them to understand some of the material is largely a matter of finding a useful metaphor (and, convincing them that the metaphor is an aid, not the thing in itself). That's been the only way to get the ones bothered by the mathematician's use of "if ... then ..." to accept it. (They don't like that "If 2 + 2 = 97 then I am King of the moon" and "If grass is green then sky is blue" are taken to be true.)
So, I am wondering if others on the list have had difficulty getting students (particularly students not primarily studying Math or CS) to get the idea of a function? If so, I'd be very interested in what techniques were of use.
Thanks, and I do apologize if this query is received as too peripherally related to the topic of the list. Best to all,
Brian vdB
_______________________________________________ Edusig mailing list Edusig@python.org http://mail.python.org/mailman/listinfo/edusig
_______________________________________________ Edusig mailing list Edusig@python.org http://mail.python.org/mailman/listinfo/edusig
 Nicholas Wheeler Systems Administrator Development InfoStructure
Kent:
Isn't a math function the same as a computerscience function? You give the math function an x, and it returns a y. ie: f(x) = 2*(4x)^x or def f(x): print 2*((4*x)**x). Most people should be able to grasp that, if they've been through highschool algebra.
Computer science functions tend to have richer syntax, plus don't always spit out their results through the 'return' at the end. In C/C++/C# you'll typically pass in an argument that gets worked on by the function, and is thereby changed, with nothing explicitly returned (return type could be void). In Python, as everything is referential, this is easy to do as well:
mylist = range(3) def additem(somelist): somelist.append(100)
additem(mylist) mylist [0, 1, 2, 100]
Note the absence of any 'return' key word. In mathematics, the formal idea of a function is probably best represented by a simple Python dictionary, which is a 'mapping'  and a 'mapping' is what a function is. You'll always see these 'cloud' diagrams, showing a cloud on the left (domain) and a cloud on the right (image), with arrows going in between. I like the map representation in that it doesn't presume there has to be a rule. Most functions we encounter in algebra books *do* have a rule, such that we're able to compute outputs by applying an algorithm. But the idea of a function doesn't require such. {(1,3),(2,18),(3,7),(8, 9.1)} is a perfectly good example of a mapping with no apparent rhyme or reason. The important thing about a function is the same inputs always map to the same outputs. There's no "fork in the road" where it could go one way or the other  any such fork would have to pair with some additional input variable. This, too, corresponds with the dictionary idea, in that the same key can't map to more than one value (sure, that value might be a list, but the same key won't point to a different list elsewhere in the dictionary  indeed, keys must be unique). I think the black box idea is just fine. I like to think of functions as verbs. They "do stuff" to inputs. I think of factories with bottles zooming by on a conveyor belt, and a machine screwing a lid onto each. Every bottle maps to itself with a lid on it. The machine is the function doing the mapping. More generically, I like to think of the present moment as a domain, and the very next moment as its image, and so on. The 'verb' is simply change, in all its bandwidth and glory. Our experience is just one long 'function' (events going to more events). We don't really know all the rules at work, but certainly there's a strong sense of rules working. Kirby
Nicholas Wheeler said unto the world upon 20041205 18:28:
Isn't a math function the same as a computerscience function? You give the math function an x, and it returns a y. ie: f(x) = 2*(4x)^x or def f(x): print 2*((4*x)**x). Most people should be able to grasp that, if they've been through highschool algebra.
Hi Nicholas, and all, I'd agree with you if experience hadn't taught me otherwise. I do see the CS and math notions of functions are tightly related (with the difference that math functions don't have side effects). But the idea that those with highschool algebra should be just fine has proven incorrect. Many Linguistics and Philosophy students in these classes "hate math" and have worked out that writing things like: (A > (B & C)) v (B <> C) looks suspiciously like math. They seem to have a mindset that "they cannot do it". Which is a shame, and I try like the dickens to make them understand the mathematical induction proof of the completeness of the deductive system for predicate logic by the time we are done. (I don't think they like me much ;) My own inclination is to say something like "a function is a set of pairs, where the first member of each pair is an ntuple of inputs, and the second member is the mtuple that is output, and for each input ntuple, there is a exactly one output mtuple to which it is mapped." And, right after that, they'd all drop the class ;) I think I like the pizza analogy (thanks Kent). My first impulse is to say "that isn't mathematical enough!" But, when I consider the difficulty that some students have had, and the obvious unhelpfulness to the target audience of my above quoted inclination, I think that means it might just be perfect ;) I'll try it out on Tuesday  I'm not teaching the course this semester, but I do have 12 hours of tutoring lined up before the course final on Wed. We will see if it works. Thanks to all who've responded. Brian vdB <SNIP>
Brian van den Broek wrote:
Hi all,
<SNIP>
I have found it difficult to get some of the humanities undergraduates to see the understand the general mathematical concept of a function. Occasionally, even some of the CS students (who, when I see them, have just begun) stumble with the concept, too.
<SNIP>
So, I am wondering if others on the list have had difficulty getting students (particularly students not primarily studying Math or CS) to get the idea of a function? If so, I'd be very interested in what techniques were of use.
Thanks, and I do apologize if this query is received as too peripherally related to the topic of the list. Best to all,
Brian vdB
When I teach functions to 68th graders in a math class I often use the example of a soda/vending machine. I first saw this worked through in the CPM math textbooks, which have a very conversational tone and strong constructivist leanings. This has the benefit also having simple examples that explain the difference between functions and non functions (consistent sodas/output form a particular button/input), injective, and surjective functions. And I made a neat poster of it, which is probably more important for the 12 year old then it is for your students. Andrew Carle MS Technology The Hamlin School
Brian van den Broek:
I'd agree with you if experience hadn't taught me otherwise. I do see the CS and math notions of functions are tightly related (with the difference that math functions don't have side effects).
However, I think mathematicians should accept the CS "side effects" as just more of the function's result, wherever and however it shows up. One thing I like about computer programming is it quickly gets you into operating with inputs/outputs other than numbers, strings for example. The early math exposure kids get is too exclusively numberfocused IMO. Books like 'Godel Escher Bach' are a good antidote. My suggestion that a factory machine which twists lids onto milk bottles or the like, is a good model of a function, would be designed to break this fixation on numbers, always numbers. In a hybrid techiemath class, we'd wire sensors to chips, so that inputs were things like temperature, outputs various GUI gizmos  more like the cockpit of an airplane (instrumentation readings = output, environmental conditions, like altitude, wind speed = input). The mathematicians' *notation* 'f : x > y' or whatever they use, may well be about turtles moving, toasters popping, cranes swiveling, cells dividing. The abstraction is about taking inputs to outputs, stimuli to responses, causes to effects or whatever. In the case of random.randint(5), it needs to be explained that just as outputs may be other than what's explicitly returned (socalled sideeffects), inputs may be coming from places other than the argument list  in this case, there's a sequence of pseudorandom numbers being computed algorithmically, with state saved between calls (like in a generator). I think lots of examples of simple causes > effects drawn from ordinary life helps phase in the new function semantics in a way that's very glued to everyday experience. In the case of propositional calculus in particular, I favor using logic gates at some point in the discussion. Little diagrams of AND OR NAND NOR XOR. http://encyclozine.com/Connective You can use these to assemble the behavior of p>q i.e. p,q are inputs to a logic gate setup, and the value of p>q is the output. p q p>q T T T T F F F T T F F T In Python, you can use Booleans, e.g. the above is equivalent to
def ifthen(p,q): return (not p) or q
i.e. (~p  q) <> (p > q)
combos = ((True,True),(True,False),(False,True),(False,False))
for p,q in combos: print "Inputs: %s\t%s\tOutput: %s" % (p, q, ifthen(p,q) )
Inputs: True True Output: True Inputs: True False Output: False Inputs: False True Output: True Inputs: False False Output: True Kirby
participants (5)

Andrew Carle

Brian van den Broek

Kent Johnson

Kirby Urner

Nicholas Wheeler