Sunday, December 29, 2013

Hacking Math Class with Python

I posted my Elliptical Orbits video to a math teachers' Google group and it got around to somebody in the Bay Area Python Interest Group. They invited me to LinkedIn headquarters in Mountain View, CA to talk about using technology and Python programming to help teach and learn difficult concepts in math and science.



I definitely wasn't there to teach anybody anything, but just to share my experiences combining math and computers. As you can see in the video, people were making great suggestions, so I learned a lot, too!

Sunday, December 15, 2013

Let it Snow (flake)

If you're interested at all in learning or teaching math, you either have already read or you should probably read Don Cohen's mind-blowing Calculus By and For Young People, a tiny book that packs a huge wallop. In it, "The Mathman" busts the myth that you need 11 years of school math to even approach the ideas in Calculus by showing the work his students (children as young as 7) have done on infinite series, fractals, derivatives and integrals, pi, e and of course the Fibonacci Numbers. And continued fractions. And nested square roots.

Recently Don sent me some work a student did on converting repeating decimals to fractions. It reminded me of how long I studied Chapter 1 of his book a decade ago. Every math student I taught after that got to play around with infinite series until they discovered the deceptively simple formula Cohen reveals on page 9.

The book bounces around playfully until returning to the topic with Chapter 4: The Snowflake Curve, the greatest eight pages of any math book ever written. The aforementioned formula is used to calculate the area inside the Koch Snowflake fractal. The power and simplicity of the ideas in this tiny book still make me shake my head in disbelief. Buy it and do the math.

Drawing the Koch Snowflake was one of the programming projects I did recently with the students I teach at the Summit Charter schools in the SF Bay Area.

The challenge is to start with a triangle (level 0) and add little angles to the middle of every segment. Repeat for higher levels. 



The graphics above were made using the NetLogo application of the Logo programming language. But how do you get a turtle to stop in the middle of a segment? The answer is recursion. 

All the code necessary was found in Turtle Geometry by Ableson and diSessa, another brilliant book, which I found at a not-nearby library and bought shortly thereafter. I only had to modify the code a little to work in NetLogo, and surprisingly, the program is short and simple:


The "snowflake" procedure simply draws a triangle with three sides. It's the "sideprocedure where the magic happens. I had to tell the turtle how to make the little bend in the side. But notice that the "side" procedure contains the command "side"! It's like a recipe for baking a loaf of bread including the step "bake a loaf of bread." That's recursion. We humans would stop in our tracks at such a command but I guess computers have no problem with it. Anyway, you can have fun making a computer draw a curve with an infinite perimeter and a finite area or you can sharpen your pencil and prove it yourself!

Wednesday, December 4, 2013

3D Harmonographs

Success! I looked through this guy's site and found the equations for the x-y motion of the "pen" drawing a harmonograph. He shows a Mathematica program that uses sliders to dynamically change the frequencies, phase shifts and decay constants and immediately see the finished harmonograph.

When I wrote those equations in a Python program it came out perfect. It takes my program a while to draw the image, but then so do real harmonographs.

I had other ideas, though: moving the sliders, I couldn't help but feel like the images were a 3D object being rotated. Then it hit me: I could draw harmonographs using a Visual Python program where one sphere (the "pen") goes back and forth in all 3 planes! I think it worked pretty well. Check it out:


Monday, December 2, 2013

Harmonographs

For years I've been fascinated with harmonographs, even before seeing one at the SF Exploratorium. Of course it made me want to create a virtual one on the computer, but the equations modeling the movement of the x- and y-coordinates of the drawing point were kind of confusing.

Visual Python makes it easy to draw in 3-D, but for some reason the paths, even once drawn, start to glitch.

This guy did a great harmonograph in Javascript. Maybe it's time to break out some more JS on Glowscript.org.

I'll keep you posted.


Wednesday, March 13, 2013

Math Through Technology Every Week!

Due to interest from some students of mine and their parents, I'll be holding Math Through Technology meetings at the Learning Studios in Burlingame on Thursday evenings on an ongoing, informal, drop-in basis. It'll be an introduction to computer programming in the context of learning math. Participants can come in and learn how to write some programs in Logo and Python to help visualize geometry and graphics or to aid in the complicated computations involved in higher math.

More information on my website at http://farrellpolymath.com/services/math-through-technology-every-thursday-at-7-pm/

Hope to see you there!

Visual Proofiness

Everybody knows the earth orbits the sun and not the other way around, right? Can you prove it? That's the problem Newton had. How could he prove that all that was needed to create Kepler's elliptical orbits was a force of attraction between the Earth and the Sun and for the Earth to be moving a little? Like a good mathematician he proved it algebraically. You can see a "proof" of this anywhere, but I doubt algebra is enough to convince anybody.

I don't know why Newton didn't just use Visual Python. With surprisingly little coding you can create a 3D world full of balls and boxes and arrows and make them do whatever you like. Now we can create an Earth and a Sun, code in a force of attraction and an initial velocity using vectors (and that's the reason to learn to use vectors!), set the world in motion and see what happens.

Here's how I proved it. (I ain't Vi Hart, so you don't need to hear me narrate.)