(My) Basic Rules of Good CAS Coding (in Geogebra)

When solving textbook examples often many styles of coding are possible. As everywhere some principles which are useful when programming have been proven very useful as best practice:

  • Never copy results manually to progress with the calculation. Never. Don’t even think about it. Use variables for results and use them.
  • Never use line numbers as reference like $5. This is as bad as naming a variable with one letter without a concise meaning. Use some letters reminding you of its meaning.
  • Never mix  given values or parameters somewhere into the code. Name them and define them at the beginning. This sometimes is somewhat tedious but the rewards are overwhelming.

The result of these simple principles are worksheets which are more comprehensive, easier to understand, and, best of all, easily adaptable to different parameters. This is important for Geogebra itself which does exactly this at its core: allowing dynamic geometry or in this case “dynamic algebra”.

A simple example shows this: find the polynomial f of grade 3 which has a turning point at (0,-1) and a maximum at (2,1). Coding with these principles yields a dynamic curve fitting example – try to move the given points!

Leave a Reply