[Edu-sig] Math in a Browser

kirby urner kirby.urner at gmail.com
Wed Apr 8 17:55:55 CEST 2009


On Wed, Apr 8, 2009 at 8:20 AM, michel paul <mpaul213 at gmail.com> wrote:
> SAGE is awesome.  I highly recommend it.  Recently I've been looking at it
> more intently with the idea of using in math classes.
>

We've been hoping to get the Sage folks from Seattle to present at
PPUG Portland.

One reason I encourage core Python for more elementary courses is I'm
wanting to open a window into the language itself, not an application
written in that language.  "Staying close to the metal" sounds funny
in this context, given it's a VHLL.

That being said, Sage encourages writing in core Python, then working
the API for graphics.  I recommend creating a free user account and
testing it over the web by pulling up some already published
activities e.g.:

v2 of three famous plots of chaos
http://www.sagenb.org/home/pub/20/

In terms of selling your department on the relevance of Python to math
learning, I think Sage is a significant asset, something to show and
tell about.

Here's all you need to plot a Mandelbrot set:

#Mandelbrot set: the final plot is a subset of the complex plane;
#the color at point c is porportional to the number of iterations that
#the discrete dynamical system z->z^2+c takes to leave a circle around
#the origin when z0=0

N=int(200)        #resolution of the plot
L=int(50)        #limits the number of iterations
x0=float(-2); x1=float(1); y0=float(-1.5); y1=float(1.5)  #boundary of
the region plotted
R=float(3)        #stop after leaving the circle of radius R
zero = int(0)
m=matrix(N,N)
for i in range(N):
   for k in range(N):
       c=complex(x0+i*(x1-x0)/N, y0+k*(y1-y0)/N)
       z=zero
       h=zero
       while (h<L) and (abs(z)<R):
           z=z*z+c
           h+=1
       m[i,k]=h
matrix_plot(m, cmap='hsv')

That's a lot shorter than my implementation with PIL:

http://www.4dsolutions.net/ocn/fractals.html
http://www.4dsolutions.net/ocn/lorentz.html

There's also Lorentz Attractor and Feigenbaum diagram, woo hoo!

Kirby


More information about the Edu-sig mailing list