[Edu-sig] using Python as a calculator

michel paul mpaul213 at gmail.com
Sat Apr 10 18:12:04 CEST 2010


The timing of this post was kind of one of those amazing cosmic
coincidences, for all kinds of reasons.  Thanks, Kirby.

I got kicked in the teeth again by an administrator putting the brakes on
starting a computational analysis course, the pseudo-arguments having to do
with budget constraints.  But the dream isn't dead ... I now have some
support at the site level from some administrators and from parents who see
that this really would be a good thing to do.  Letters are being written to
the board, lots of discussion fomenting.  Way better than when I was
completely alone.  But an amazing amount of time has been sucked into having
to constantly return to square one, or zero, in presenting the value of
having a designated computational Math Analysis course.

So .. in our regular Analysis class we were doing graphs of polar equations.


The kids were a little confused about why certain graphs turned out as they
did.  Like - in r = sin(x), why is the circle 'all positive'?  What happened
to the negative sine values?  They understood the basic meaning of (r, x),
but the behavior of the graphs was bewildering.

So I told them to think of a laser gun at the pole whose orientation was x
and that fired a beam whose length was r(x).  Then visualize the gun
rotating through x = [0 .. 2*pi] firing beams of length r(x).  (You also
have to allow the gun to fire either forwards or backwards.)

Then it hit me ... TURTLE!  Forward, backward, right, left, ...  polar
coordinates!

I wrote a little turtle module that drew segments from (0,0) to (r(x), x)
plotting a little circle at (r(x), x).  Very simple.  Just a loop setting
the turtle heading, calculating the distance, and then going forward (or
backward).  It beautifully illustrates the laser gun model, because you can
actually see it happening.  You don't just get a finished graph all at once.
 Rather, you can actually observe the process of little beams sequentially
emanating from the center.  I enhanced it by making each beam receive a
randomly chosen color.  The resulting graphs are really pretty - imagine a
polar graph generated by a dense cluster of multi-colored rays from the pole
- and the kids totally loved it.  There were all kinds of OOOH and AHHHH
around the lab the first time I said, "Ready?  OK ... run it!" and they got
a psychedelic Archimedean spiral.  They were then to experiment with
different functions for r(x) to create spirals, circles, rose curves,
limacons and whatever ... I wanted them to see how they could duplicate the
stuff in the text but also explore completely bizarre things on their own.
 Same loop, but different results depending on r(x).

The cool thing was ... this was totally easy.  I basically wrote the module
- all the kids had to do was experiment with different functions of r(x).
 But since they had the source code sitting in front of them, they were free
to experiment with it, and I encouraged them to do so.  So one kid changed
the radius of the little circles that were plotting the points.  He made it
REALLY BIG, and the resulting graphs were fantastic!  So all the other kids
wanted to do that too.

The reason Kirby's post was such a cosmic coincidence is that it appeared on
the VERY DAY that I decided to do this with my Analysis kids.  Not that I
was dealing with tables per se, but we were dealing with trig and with using
the Python shell *as a trig calculator*.

The timing of all of this was perfect, as the kids really did think this was
cool, and one of the kids happens to have a board member as a parent : ) .
I was able to say to the kids, you see, I wrote this module for you, but if
this was a class where you learned to program from the beginning, you could
create this kind of module yourself!

So, I really enjoy the way the universe unfolds.

- Michel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edu-sig/attachments/20100410/9a806977/attachment.html>


More information about the Edu-sig mailing list