## Christmas greetings – SAGE style

David Joyner of the SAGE development team has come up with a couple of very nice mathematical Christmas greetings using a combination of SAGE (For the mathematics used to generate the images) and GIMP and Inkscape (for the text). The first one is based on a Barnsley Fractal and the sage source code is available here.

David’s other creation is a Sierpinski gasket that has been coloured such that it resembles a Christmas tree. The SAGE source code is given below.

def sierpinski_seasons_greetings():

"""

Code by Marshall Hampton.

Colors by David Joyner.

General depth by Rob Beezer.

Copyright Marshall Hampton 2008, licensed

creative commons, attribution share-alike.

"""

depth = 7

nsq = RR(3^(1/2))/2.0

tlist_old = [[[-1/2.0,0.0],[1/2.0,0.0],[0.0,nsq]]]

tlist_new = [x for x in tlist_old]

for ind in range(depth):

for tri in tlist_old:

for p in tri:

new_tri = [[(p[0]+x[0])/2.0, (p[1]+x[1])/2.0] for x in tri]

tlist_new.append(new_tri)

tlist_old = [x for x in tlist_new]

T = tlist_old

N = 4^depth

N1 = N - 3^depth

q1 = sum([line(T[i]+[T[i][0]], rgbcolor = (0,1,0)) for i in range(N1)])

q2 = sum([line(T[i]+[T[i][0]], rgbcolor = (1,0,0)) for i in range(N1,N)])

show(q2+q1, figsize = [6,6*nsq], axes = False)

It just goes to show that advanced mathematical software such as SAGE doesn’t just have to be used for teaching and research – it can be used for making mathematical Christmas cards too! SAGE is completely free and is available from the SAGE math website. Thanks to David for his work on this one.