[Edu-sig] Pythonic Mathematics (session 2)

kirby urner kirby.urner at gmail.com
Sun Apr 30 17:55:13 CEST 2006

CLASS:  Saturday Academy: Pythonic Mathematics
LOCATION:  Portland State University, Neuberger Hall
TIME:  10 AM - 12:30 PM

While I'm at it, and while the memories are still fresh, I'll
chronicle what happened in class yesterday.

First, parking was difficult.  PSU has two parking structures but I
picked the wrong one, and wasted 15 minutes finding it was full, plus
got caught going the wrong way in a narrow driveway and so on. 
Finally found meter parking with but minutes to spare.  Broadway door
to Neuberger was locked, had to go around.  Elevator.  Math computer
lab.  On time, believe it or not.

Student peers, being dropped off by their parents, had similar
problems, but all arrived, to find fractals being projected out of
video.google.com, followed by a short explanation of same, with
emphasis on the simplicity of the rule behind Mandelbrot's set:  z =
z*z + c.  One of the fractal students took that on in IDLE later,
preassigning c, setting z at 0+0j, and running forward, time and
again, each time with a different c.

Then I showed Warriors of the Net, which got quite a few laughs, but
also respect for its close dissection of TCP/IP.  Router, router
switch, proxy server, firewall, ports... all in the form of an
easy-to-parse cartoon.  After it was over, I switched off the
projector (means house lights down, as the infrared remote can't cut
through flouresence), rolled up the screen, and discussed the
difference between two flavors of IP:  TCP versus UDP.  I also talked
about SMTP, FTP, NNTP and HTTP as examples of port-associated
services.  We dissected a packet, in theory at least.

Then I forget the exact transition, but my next topic involved my
longstanding augmentation of spatial geometry with a Fuller hierarchy
based, sphere packing approach.  That led us to Encyclopedia of
Integer Sequences, with the link being cuboctahedral numbers (this
probably makes little sense if you haven't gone through my
orientation, or one like it).

Then it was dive into IDLE, import sys and sys.path.append('long
string into My Documents') and a snack break.

The rest of the class was spent by Pythonic Maths students exploring
topics of their own choosing, picking from the list below (this is a
verbatim transcript of what I typed out in IDLE during the break, and

Kirby Urner


Number sequences:  triangular, square, cuboctahedral numbers
Write short functions (or generators to be fancy) that return
sequences, such as the triangular numbers: 0, 1, 3, 6, 10...

Rational Number class:  start work on a rational number with a
numerator and denominator, that will add and multipy fractions

>>> myrat = Rat(2,3)
>>> myrat
>>> myrat * myrat

Fractal Geometry.

Compile bookmarks for "Argand Diagram" and "multiplying complex numbers".
Figure out how to implement z = z**2 + c in Python, where z starts as (0,0)
and c can be any complex number.

Volunteer to help with someone with any of these.

Most of the peers chose the number sequences, as this was the easiest
on ramp to beginning Python (writing a few functions, getting the hang
of the editor versus shell experience, import and reload).  Here's
sort of what their polys.py would look like by the end of the day
(they just copied the generator, while a talked about what they were
good for, and tri was our first example, jumping off from the
aforementioned Encyclopedia).

def tri(n):
   return n * (n + 1) / 2

def square(n):
    pass  # most of 'em had a working version

def cubocta(n):
   if n == 0:
       return 1
       return 10 * n * n + 2

def fib(a,b):
   while True:
       yield a
       a,b = b,a+b

One advanced student started whipping out Rational Number code,
consulting the internet, fingers flying.  I showed him Guido's GCD
around the time he was wrestling the prime factors, trying to think
how to reduce after two rationals __add__. And one fractals-loving guy
dove into z = z*z + c, as recounted above (I drew and Argand Diagram
and suggested he develop a visual sense of how two complexes multiply
-- a self-study topic).

I'd do lower voiced lectures with a corner, rove between stations. 
But the main thing was to get students alone with the snake, working
their charms.  This is more likely to lead to home experimentation,
i.e. there's no sense that a teacher must be present.  Learn on your
own, teach yourself.  That's not a burden, but a freedom and a right.

Then parents started showing up, some clearly already pleased with the
results of session one.  One parent expressed gratitude that the high
tech sector is behind an education initiative for this age group. 
Twenty three years and counting.  I'm a latecomer of course, and a
proud standard bearer already.

Per thread here, I encouraged kids to email their .py files to
themselves over a web account, so even if the local hard drives got
wiped (as sometimes happens in computer labs), we'd be set to go

I told one parent my parking woes and she advised me of the two garage
situation, plus hoped I'd in future take full advantage of PSU faculty
parking privileges.


More information about the Edu-sig mailing list