Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: more about "generators" (math learning tool)
Replies: 3   Last Post: Apr 22, 2013 3:09 PM

 Messages: [ Previous | Next ]
 kirby urner Posts: 3,690 Registered: 11/29/05
more about "generators" (math learning tool)
Posted: Apr 19, 2013 3:24 PM

I've been a voice here for using the free and open source tool kit a
lot more in math class, not because I want vocational IT topics to
swarm over a defeated math corpse, but because math is alive and well
in silicon and the civilization our students inherit needs fluency /
literacy in this area i.e. "maths" has become this new thing as well.
Or call it STEM.

Many of the new math languages come with a "chat window" where
interaction with the interpreter means a kind of dialog, with one side
played by "the machine" (i.e. the logic) and the other by the human,
perhaps the designer of the language (e.g. Iverson of APL), or a
contributor (e.g. Tim Peters to Python), or more likely as an average
user of tools (like me). We have hardware tools, and we have software
tools.

At the Python chat window prompt, you may define a generator, which is
like a function except instead of returning and forgetting everything,
it "yields", meaning you start with an object that you nudge. I like
to call it the can you kick down the road, calling up pictures of
Ernest Hemingway.

>>> thegen = Bernoulli( ) # start with an object...
>>> next(thegen) # that you nudge...

Fraction(1, 2)
>>> next(thegen) # and nudge again...
Fraction(1, 6)
>>> next(thegen)
Fraction(0, 1)
>>> next(thegen) # ... like kicking a can down the road
Fraction(-1, 30)

Yes, there's lots more to say about Bernoulli numbers, and we wouldn't
get to that just as the generator was being introduced. In a well
designed learning program, you would have a long on ramp through
functions first, in parallel with like-a-Dolciani treatment (of sets,
functions, relations, composition of functions, inverse functions, in-
/ sur- / bijective), then get to generators. The first ones would be
simple "gnomon like" figurate and polyhedron growth sequences, like
square and triangular numbers, like cubic numbers, like cuboctahedral
numbers 1, 12, 42, 92, 162...

I've been recently reminded to promote generators by my colleague
Raymond Hettinger, likewise with the Python community and presenter of
one of our keynotes at this year's US Pycon in Santa Clara. In the
endnotes, I give a link to a blog through a faculty page that links to
Raymond's talk. I also give a pointer into the Chipy mail list where
generators of Bernoulli, Gregory numbers, and digits of pi are given.

The last is of murky (to me) origin and I've only personally verified it
against published sources to 1000 digits.

Kirby

Endnotes:

Python Generators (Wikieducator):
http://wikieducator.org/PYTHON_TUTORIALS#Generators

Recap of Pycon 2013:
http://blog.oreillyschool.com/2013/04/the-kirbster-reports-back-from-pycon-2013-not-all-scripting-languages-are-equal.html

Chipy Archives:
http://mail.python.org/pipermail/chicago/2013-April/011003.html

re Hemingway: