0% found this document useful (0 votes)
88 views2 pages

MATH3062 S12023 Lab 1 New

This document provides instructions for Lab 1 of MATH 3062/6116. Students are asked to modify a partial Python program to produce iterates converging to the Sierpinski triangle. The document explains how to download and install Python, describes the goals of modifying the code to render the fractal, and provides tips on for loops, commenting out code, and indentation. Students are instructed to submit their final code, 3 output images, and the affine mappings used to generate the Sierpinski triangle.

Uploaded by

alfalfa man
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views2 pages

MATH3062 S12023 Lab 1 New

This document provides instructions for Lab 1 of MATH 3062/6116. Students are asked to modify a partial Python program to produce iterates converging to the Sierpinski triangle. The document explains how to download and install Python, describes the goals of modifying the code to render the fractal, and provides tips on for loops, commenting out code, and indentation. Students are instructed to submit their final code, 3 output images, and the affine mappings used to generate the Sierpinski triangle.

Uploaded by

alfalfa man
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

LAB 1 MATH 3062 / 6116, SEMESTER 1 2023

To be handed in, via Wattle by midnight on Friday 10th of March.

The purpose of this lab is to get practice with Python and to implement a simple
Python program to produce iterates converging to the Sierpinski Triangle.

Python is an open source programming language and there are various different
ways to run it. Most computers now have Python interpreters in-built, but they
may be older versions, so make sure you have version 3.6 or above to avoid strange
problems.
The ANU computers have various environments and versions of Python installed
but the one we recommend is called Spyder. You can download a version on your
own computer here: https://www.spyder-ide.org/.

Instructions:
(1) Download and install a Python environment on your computer. Spyder /
Anaconda is recommended. If you need assistance with this please ask your
demonstrator. Paste lab1_partial.py, into your Python environment (see
page 3 of the lab in edX).
(2) Follow the outline and and tips below to complete the code to render your
first fractal!

Goals: To modify the original program so that it can produce a sequence of iterates
converging to the Sierpinski triangle. Please note that the program will require
substantial editing.

Understanding the code. The best way to understand some code is to do some
experiments. Consider this “experimental mathematics” through code.

You will see in the code that the variables image and next_image are 512 × 512
arrays. They represent grayscale images, where a value of 0 gives a black pixel, and
the value 255 gives a white pixel. Any integer between 0 and 255 gives a gray pixel
in between black and white.
As we are plotting the image of a set A under repeated applications of the Hutchin-
son operator F , we only want to plot a black and white image. So the values of our
array will be either 0 for black (the background) or 255 for white (which means that
the pixel is in F ◦n (A)).
1
2 LAB 1 MATH 3062 / 6116, SEMESTER 1 2023

To submit:
(1) (7 points)
a) Submit your final code (preferably in pdf format).
b) Submit 3 output images, corresponding to 3, 4 and 5 iterations of the
IFS F = (f1 , f2 , f3 ).
(2) (7 points) Write down the three affine contraction mappings f1 , f2 , f3 you
use in your code in projective notation
    
x a b e x
f( y ) = c d g
     y
1 0 0 1 1
Most programming languages including python use non standard coordinate sys-
tem, where x is the vertical axis and y is the horizontal axis, and the origin is in
the top left corner. Trying to use standard Sierpinski triangle coefficients in your
program will result in triangle, that is lying on its side (see image on the next page).
However your output should be standard oriented Sierpinski triangle.

Some tips and hints:


• A for loop will loop through all the items in a collection. For example,
range(n) is the ordered collection of integers 0, . . . , n−1. Hence the following
code:
for i in range(4):
print(i)
will have the output
0
1
2
3
• Place a # in front of a line of code to “comment it out”. The line is still
there if you want to reinstate it but for now the program will ignore it.
• Indenting in the python program is very important so only change it once
you know what you are doing.
• The first few lines are setting up which python functions are available in the
program. Leave these following lines in place.
from numpy as np
import matplotlib.pyplot as plt

You might also like