[Edu-sig] Using the Decimal type in Martian Math

kirby urner kirby.urner at gmail.com
Sun Nov 29 19:58:20 CET 2009


I'm including the script below, using Python as a calculator, showing
off the relatively new Decimal type, mainly to solicit feedback as to
whether I'm doing anything really dorky (or that could easily be
improved dramatically if I just knew what I was doing more).

I don't use this type every day.

In lobbying to displace calculators in at least some high school math
courses, I need to make it evident to teachers that the bigger more
colorful displays are well worth it, even though an advanced TI will
do extended precision they tell me.

It's still not so easy to take screen prints or to compare (as strings
perhaps) with published digit sets (e.g. for pi, e, phi, sqrt(2) --
numbers we care about).[1]

However, many math teachers are already converts to the bigger
screens, i.e. once they have them, would never go back.  Even just
having the one up front, thanks to the computer projector, is enough
in some classrooms (the 1:1 ratio may be what homework is all about,
even in OLPC-ville).

So if we're this far along the decision tree (in a computerized math
lab, say a TuxLab, running free/libre stuff on commodity hardware)
then the next challenge is to tout Python, a scripting language, over
say Excel or OpenOffice or that IronPython spreadsheet with Python for
cell coding.

In Windows world, where Python also runs (on Tk in IDLE if you want
the GUI, or on ActiveState's or Wing's for scholars...), Excel is a
gravity well for many math teachers, or should I say black hole (they
never re-emerge)?  Does Excel harness IEEE extended precision?  I know
Mathematica does.

For context:

The appended script is a fragment of Martian Math where we take a
tetrahedral pizza slice out of a spherical pizza (messy analogy) and
weigh it (compute its volume).  The 120 slices have identical angles,
so all have the same volume for a given h (height), the scale factor
built in to all the six linear dimensions (the six edges of each pizza
slice).

I'm changing the value of h from phi/root2 -- where the pizza weighs
in at 7.5 -- to a different value (or vice versa), where the pizza
weighs in at volume 5.

Given this is Martian Math, there's the little matter of needing a
conversion factor (syn3) to escape the Earthlings' worshipful fixation
on unit-volume cubes (what keeps 'em retarded -- Martian Math is
somewhat counter-culture (= counter-intelligence)).

Our canonical Martian Math rhombic dodecahedron has a volume of six
and has radius 1 i.e. inscribes each ball in a CCP ball packing (same
as FCC, the ~0.74 maximum density possible in ordinary space).

The volume 5 rhombic triacontahedron (investigated below) is a
different animal (different zonohedron) but there's a bridge in that
our T, A and B modules all have the same easy volume of 1/24.

The latter two (A&B) build the primitive space-filler (i.e. the Mite,
pg. 71 Regular Polytopes by Coxeter)) as well as said rhombic
dodecahedron (also canonical cube (vol 3), octahedron (vol 4),
tetrahedron (vol 1), cuboctahedron (vol 20) etc.).

Probably more than you wanted to know, the kind of stuff I've encoded
in my rbf.py for those wishing to explore our digital math track in
more depth.[2]

Kirby Urner
Oregon Curriculum Network
4dsolutions.net

isepp.org (board)
python.org (voting member)
wikieducator (wikibuddy)

[1] http://mail.geneseo.edu/pipermail/math-thinking-l/2009-November/001329.html
(suggesting high precision explorations, ala fractals, as integral to
digital math track (DM))

[2] http://www.4dsolutions.net/ocn/cp4e.html

-- 
>>> from mars import math
http://www.wikieducator.org/Martian_Math

=== Python v. 2.6 ===

from decimal import Decimal, getcontext
getcontext().prec = 31

# whole numbers
d1,d2,d3,d4,d5,d6 = [Decimal(i) for i in range(1,7)]

# fractions
dthird = d1/d3
dhalf = d1/d2

# surds
droot2 = d2.sqrt()
droot5 = d5.sqrt()

# constants
# http://www.rwgrayprojects.com/synergetics/s09/figs/f86210.html
syn3 = d3/pow(droot2, d3)  # tetravolume:cubevolume

phi = (d1 + droot5)/d2  # golden ratio

def tvolume(h):
    # http://www.rwgrayprojects.com/synergetics/s09/figs/f86411a.html
    # http://www.rwgrayprojects.com/synergetics/s09/figs/f86411b.html
    AC, BC, OC = ((h/d2) * (droot5 - d1), (h/d2) * (d3 - droot5), h)
    base = dhalf * (AC * OC)
    return dthird * base * BC

# T module (1/120th of volume 5 rhombic triacontahedron)
h = (phi/droot2) * pow(d2/d3, d1/d3)
tvol = tvolume(h)

print "T Module"
print "T in tetravolumes: ", tvol * syn3
print "Rh Triacontrahedron: ", 120 * tvol * syn3

# E module (1/120th of rhombic triacontahedron with radius 1)
h = d1
evol = tvolume(h)

print "E Module"
print "E in tetravolumes: ", evol * syn3
print "Rh Triacontrahedron: ", 120 * evol * syn3

# K module (1/120th of volume 7.5 rhombic triacontahedron)
h = phi/droot2
kvol = tvolume(h)

print "K Module"
print "K in tetravolumes: ", kvol * syn3
print "Rh Triacontrahedron: ", 120 * kvol * syn3


More information about the Edu-sig mailing list