[Edu-sig] quantum instance

Kirby Urner urnerk at qwest.net
Tue Sep 13 04:54:16 CEST 2005

I pretty much agree with Arthur that CS needs grist for its mill, and
geometry and mathematics are good suppliers.  

I would also turn that around and go with Scott's point that CS is not alone
in needing grist:  geometry and mathematics benefit by having CS supply
context and applications.

For example, a purist mathematician might scorn an approach to the concept
of vectors that uses Python code as a means to communicate just what a
vector *is* i.e. uses a computer language to help anchor a mathematical

However, not being a purist, I think such cross-breeding begets many
positive synergies.  We get to use string substitution to generate scene
description language, directly from our Python vector class, as food for

Python and POV-ray are wonderful and powerful tools.  It hardly makes sense
to teach mathematics/geometry without these tools, or tools like them, if
the requisite tech is available.  They're free, after all.

In sum, it makes plenty of sense to teach CS while importing from other
fields (I'd argue that Knuth makes extensive use of pre-CS mathematics), and
it makes just as much sense teach math and geometry while importing from CS.

The advantages of a cultivating a math/CS hybrid for use in present and
future curricula are just too great to ignore.  Why rip ourselves off
unnecessarily?  We should continue this lineage, which is already a
tradition, stretching back to before Python was born.


Related thread @ Math Forum (math-teach list):


 >>> reload(satacad)
 <module 'satacad' from 'D:\Python24\lib\site-packages\satacad.py'>
 >>> from satacad import Vector, Edge
 >>> v0 = Vector((1,1,1))
 >>> v1 = Vector((1,2,-3))
 >>> v2 = v0 + v1
 >>> e = Edge(v2,v0)
 >>> e
 Edge <2, 3, -2>, <1, 1, 1>
 >>> e.write()
 'cylinder <2, 3, -2>, <1, 1, 1>, 0.1 pigment { color Red }'
 >>> v0
 Vector <1, 1, 1>
 >>> v2*3
 Vector <6, 9, -6>

class Vector(object):

    color = 'Red'
    def __init__(self, xyz):
        self.xyz = xyz

    def write(self):
        basic = "cylinder <0,0,0>, <%s,%s,%s>, 0.1" % self.xyz
        return "%s %s" % (basic, "pigment { color %s }" % self.color)
    def __repr__(self):
        return "Vector <%s, %s, %s>" % self.xyz
    def __mul__(self, scalar):
        xyz = tuple([scalar * i for i in self.xyz])
        return Vector(xyz)

    def __add__(self, other):
        xyz = tuple([ i+j for i,j in zip(self.xyz, other.xyz)])
        return Vector(xyz)

    def _get_xyz(self):
        return '<%s, %s, %s>' % self.xyz
    coords = property(_get_xyz)

class Edge(object):

    color = 'Red'

    def __init__(self, v0, v1):
        self.v0 = v0
        self.v1 = v1

    def __repr__(self):
        return "Edge %s, %s" % (self.v0.coords, self.v1.coords)

    def write(self):
        basic = "cylinder %s, %s, 0.1" % (self.v0.coords, self.v1.coords)
        return "%s %s" % (basic, "pigment { color %s }" % self.color)


More information about the Edu-sig mailing list