SA8: Odd and Even

This Scripting Algebra (SA) activity uses even and odd polynomials to create generative art in p5.js.

This activity assumes that the skills from SA1-SA7 were introduced (if-else, logical operators, random(), text(), rect(), variables, loop, pow, for, functions, translate etc.). This activity will introduce modulo.

In this activity, learners can either create their own project for even and odd functions, or they can modify and learn with code examples below.

Save work often and have fun (or just start over if you break it).

Odd Picture

  • Analyze the code below by changing one value at a time.
  • This example is y = ax3, what is another example of an odd function?
    • Can it be implemented?
  • Can some of this code be randomized?
  • Play with the coefficient code to create new animations and art.
  • Example Code at p5.js.

See the Pen OddPicture by Sophia (@fractalkitty) on CodePen.

Get Even

  • This example is similar to the odd function above, but what had to change?
  • What are other even functions?
    • Can they be implemented?
  • One polynomial is calculated and then 4 different ones are plotted by modifying the x value.
    • What would this look like algebraically?
  • Example Code at p5.js.

See the Pen GetEven by Sophia (@fractalkitty) on CodePen.

Mixed Rotate

  • Draw random even and odd functions.
  • Change color based on even/odd:
    • Modulo (remainders can be used for this).
  • Rotate the canvas.
  • Example Code at p5.js.

See the Pen abNJOKK by Sophia (@fractalkitty) on CodePen.

Example Concepts: even/odd functions, function operations, translation, variables, coordinate planes, ordered pairs, conditions, loops, random numbers, functions, etc..

Like what you see?

Buy Me A Coffee Become a Patron!

Leave a Reply

%d bloggers like this: