Part 1. Multiple executions (15 points)

One of the most common tasks when working with computers is running a program multiple times with different inputs. (As just a single example, in the final project for CSCI 210, you first write a program to simulate how a part of the processor operates. You will then run this program with different options on different inputs. This is an error-prone operation. Instead, you could write a simple shell script to run the program all of the different ways you need.)

In this part, you will be writing a shell script to run a program (that is provided to you)

Clone the jfrac repository outside of your assignment repository. Do not commit the jfrac code to your assignment repository! The jfrac repository holds the source code for a simple program, written in the Rust programming language, that generates images of the Julia set fractal.

Inside the jfrac directory, run the following command.

$ cargo run -- default.png

The cargo tool is used to building (and in this case running) software written in Rust. This will produce an image file that is 800 pixels wide and 800 pixels high named default.png. It looks like this.

Julia set fractal.

The mathematics behind the Julia set are explained on the Wikipedia page, but are not important for us here. What is important is that by changing the complex number in the equation , we can drastically change the output fractal. The number is specified by passing the --constant option to the program. For example, the default constant is so running

$ cargo run -- --constant="-0.4 + 0.6i" explicit.png

will produce the file explicit.png which is identical to default.png shown above. The strange -- by itself is required here. Everything before the -- is an option or argument for cargo. Everything after the -- is an option or argument for the jfrac binary itself.

There’s no man page for jfrac, but it comes with a short help. Run

$ cargo run -- --help

to see the options.

Your task

First, play around with the --constant option to jfrac to produce images with different constants. Look at the examples given in the quadratic polynomials section of Wikipedia for inspiration. You’ll likely want to select values of such that and .

Find 5 values of that you like.

Your task is to write a Bash script named genfrac which will run the jfrac command several times (by using cargo run as shown above) using two nested for loops.

Your script (which can assume that the jfrac directory is in your current directory) must generate each of the 5 fractals at 3 different sizes, 200 × 200, 400 × 400, and 800 × 800.

Each file should be named Julia set (constant) size.png. For example, using the default constant and default size, you would produce the file named Julia set (-0.4 + 0.6i) 800x800.png.

You should have 15 generated images in total. Add those images to your repository in an images directory.