Tuesday, June 10, 2014

Teaching math through Coding

I recently started teaching Computer Science 10 and 20 and I use the program Processing.  It is a free program and entirely based in a geometric space.  The cross curricular links in this program are amazing!  I want to share how my Grade 10 students were introduced to higher level math concepts while working with this program.

First, here is a program Sean wrote:
int[] numb = new int[5];
void setup() {
  size(800, 800);   background(255);   numb[0]=0;  numb[1]=200;  numb[2]=400;   numb[3]=600;  numb[4]=800;
void draw() {
  line(numb[int( random(0, 5))], numb[int( random(0, 5))], numb[int( random(0, 5))], numb[int( random(0, 5))]);
The picture it creates is:

Now in case you don't understand processing what is drawing does is takes the numbers 0, 200, 400, 600, and 800 and creates a line from all possible co-ordinates created from these numbers to all other possible co-oridinates.  For example a line from (200, 600) to (800, 800).  It does it in a random pattern, but after running for some time all possible lines are drawn. 

After Sean drew this I asked him "How many lines have been drawn?"  This is a typical Math 30-1 question, a course in which Sean has never been in yet.

After some thought he asked if it would be "5 times 5 times 5 times 5 times 5?"  or 3125.  This is of course, a great way to start the problem but is too high as you can't have a line from (0,0) to (0,0).  Also he didn't account that the line from (0, 400) to (600, 800) is the same as the line from (600, 800) to (0, 400).  At this point the bell rang and we will finish the conversation tomorrow.  However in Grade 10 Computer Science he was introduced to a Gr 12 Math concept called "Fundamental Counting Principle" and "Permutations and Combinations".

Next was Ex who wanted to create a scene where a sun rises and sets. His original project had the sun follow a straight line to the top of the screen and then follow a straight line back down to the horizon.  Following a "^" shape in the sky.  This of course is not how the sun moves, as it would move more in a parabolic shape. 

Unfortunatly, Ex has only taken Math 10 and not have heard of a "Parabola".  Consequently, I sat with him and we played with his code.   Instead of it following "y=-x+10" I asked him to put in "x^2" and to watch what will happen.  Instantly he was surprised to see his sun move in a different fashion than before.

He asked how do we move the sun right in the sky, as he wanted the sun to be at the highest point in the middle of the screen.  What he was asking was "How do we horizontally move the parabola?".  Again this is Math 30 concept.  Through some guided discovery, Ex realized that by replacing x with x-h we move the parabola left and right.  

 Here is his final code.
int xPos=0; float xPos2=260; int positionX =50; int positionY = 100; int Switch = 0;
void setup() {
  size(500, 500);  smooth();
void draw() {
  background(130, 200, 255);  fill(255, 238, 21);  ellipse(xPos, xPos2, 100, 100);  xPos=xPos+1;
    background (0);
  noStroke();  fill(15, 80, 0);  rect(0, 300, 500, 400);  fill(40, 40, 40);  rect(200, 230, 100, 70);
  fill(65, 65, 65);  rect(235, 250, 30, 50);  triangle(300, 190, 300, 230, 202, 230);  ellipse(240, 280, 5, 5);
  fill(53, 43, 32);  rect(140, 230, 20, 70);  fill(6, 62, 0);  ellipse(150, 220, 60, 60);  fill(112, 112, 112);
  rect(0, 355, 500, 100);  fill(191, 191, 9);  rect(0, 400, 50, 10);  rect(75, 400, 50, 10);  rect(150, 400, 50, 10);
  rect(225, 400, 50, 10);  rect(300, 400, 50, 10);  rect(375, 400, 50, 10);  rect(450, 400, 50, 10);

1 comment:

  1. I am a student research assistant at Montana Tech of the University of Montana. Technology has created exciting ways to connect with others and form professional learning networks. As a part of an active member of a social media community made up of teachers, I wanted to contact you to ask you to participate in a study our research group is conducting.

    Research shows that face-to-face professional networks provide much needed professional and personal support to teachers. You and the community you belong to are providing these types of support using social media. We are interested in learning more about your experiences using social media to connect with other teachers and your opinions about online professional networks.

    The purpose of our study is to learn how professional learning networks created through social media are similar or different than face-to-face networks and what you feel are advantages of using social media to connect with other teachers. Our hope is that the results of this study will inform how professional networks for teachers are designed in the future. If you are interested in participating, please send an email to me at teacherblogPLN@gmail.com. I will send you a link to a short online survey and will set up time for a short skype interview.

    If you have any questions you would like to ask about the study, please do not hesitate to contact me.


    Kaitlyn Rudy
    Research Assistant
    Department of Mathematical Sciences
    Montana Tech of the University of Montana