Skip to content

Instantly share code, notes, and snippets.

@ixxra
Created June 17, 2013 19:41
Show Gist options
  • Save ixxra/5799678 to your computer and use it in GitHub Desktop.
Save ixxra/5799678 to your computer and use it in GitHub Desktop.
Fractal from pascal triangle writen in python (sage mathematics)
def pascal_matrix(size=500, zp=3):
'''
Creates a matrix of size x size, whose entries are numbers in zp, such that
entry M_{ij} is obtained recursively as in pascal triangle. Each diagonal on
the matrix corresponds to a row in Pascal's triangle.
'''
M = ones_matrix(size,size)
for i in range(1, size):
for j in range(1, size):
M[i, j] = M[i - 1, j] + M[i, j - 1]
for i in range(1, size):
for j in range(1, size):
M[i, j] = mod(M[i, j], p)
return M
M = pascal_matrix()
matrix_plot(M)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment