Programming in math classes

Leave a comment

Starting next year, the new Swedish course plan will require the inclusion of programming in math classes. I know not all math teachers, especially for younger years, have a lot of experience with this and so I thought I would blog about three good tools.

All the tools I will talk about share two important features:

  1. They are free to use
  2. They can be used directly in any web browser


  • Recommended uses in Sweden: lågstadiet and mellanstadiet
  • Available in Swedish and other languages

The first, and probably the most important, is Scratch, a tool developed at MIT and the best introduction to programming out there.

Instead of writing code, students drag and drop ready commands. It is incredibly easy to use and get started with. They recommend a starting age of 8, but younger kids have used it as well (with more guidance). It is also available in Swedish (as well as something like 40 other languages).

Even if it is easy to get start with, Scratch is quite versatile and it is possible to do quit complicated programs.

I recommend moving away from Scratch in högstadiet, since it will be easier to integrate into your math teaching. However, I did want to give a good example of how it is possible to use Scratch even in 9th grade.

The following is an example of a possible assignment. A 9th grade student was asked to create a Scratch project that showed found the equation of a line from two points. This is what he came up with.

Note that this is also an excellent way to assess math skills outside of standard testing. This project required good knowledge of linear equations, basic algebra, fractions, scaling and Euclid’s algorithm for reducing fractions.

However, this would have been much easier using something like JavaScript instead (e.g. using jsFiddle).

Khan Academy Programming Course

  • Recommended uses in Sweden: högstadiet and gymnasiet
  • English only

Khan Academy has their own online programming course. They have created their own language that seems to be roughly based on JavaScript, but is optimized for graphics.

The advantage here is that they have ready made videos and instructions for students, so even inexperienced teachers can let the students work through the material at their own pace. The focus on graphics and animation tends to make it more fun for students to learn, however it can make some math class applications more annoying to implement. Likely easiest (at least initially) for geometry projects.

A nice feature of their online programming editor is that the code is run as you type it. This gives instant feedback on any changes, which can be helpful for students. Another nice feature is that a teacher can create a sample or template program in the editor and then give a link to it to the students. This can be really nice for specific programming/math projects you want them to work with.


  • Recommended uses in Sweden: högstadiet and gymnasiet
  • English only (as much as JavaScript and HTML are based on English)

jsFiddle is an online JavaScript editor. This allows you to create JavaScript programs without needing a website to host them on. Instructions in JavaScript (and basic HTML) will need to come from elsewhere. But this is a great site for trying out programs.

Another nice feature is that, like with Khan Academy, the teacher can create sample or template programs for the students to study or modify.

Once students have some proficiency in JavaScript, this is likely the most versatile for using in math related programming assignments.

Here is a simple example of using the Newton-Raphon method to find the square root of a number.




New idea for teaching exponents: the invisible 1

1 Comment

I had a flash of insight yesterday while teaching exponents to my 8th graders.

As any math teachers are probably aware, it is difficult to get students to really understand why

I usually go through the process of showing them what happens every time you lower the exponent by 1, and show the pattern, which is also a nice way to motivate negative exponents. For example:



Here the explanation is that when the exponent goes down by 1, the value is divided by 2. The same pattern continues to 0 and negative exponents.

They are usually able to guess the negative values from the pattern (when encouraged to “follow the same pattern”). But in general they REALLY want the value to be zero when the exponent is zero. “You have zero 2’s, so it should be zero!”
So I started talking about the invisible 1 that is always there in multiplication and causes so many problems to students by being invisible all the time (I am finding more and more places as a teacher that it is useful to make this invisible 1 visible).


So I came up with this great idea (yeah, I know, not very modest, but it was just sooo effective) for explaining the zero exponent which got a full class of “oh, I see”. I now explain that exponents really work like this instead:



Now the zero exponent follow exactly the same rule and the answer follows completely naturally. This will also help them with cancelling later (ever tried to teach canceling as a shortcut and have students put a zero instead of a 1 when they cancel everything on the top or bottom of a fraction?).

Example vs Proof

Leave a comment

I recently read an old blog post by Kate Nowak.

She discussed a problem I have quite often with my students – getting them to understand the value of math proofs. In particular, I have trouble getting them to understand the difference between an example and a proof.

In the past I have used a silly “false pattern” to make my point. I start the class by writing the following conjecture on the board:

If I double any number, the result will always be less than 100

I then give a lot of examples. This generally gets a number of laughs, and they say it is silly. I then ask them why they do the same thing all the time in class if it is so silly. We discuss how it is actually possible to find infinite examples to support this conjecture, and yet it still isn’t true.

I like the example in Kate’s blog with the circles. However, I feel it is too complicated to really get the point across, just as I feel my example is too simple to really get the point across.

So, what I want to ask anyone who reads this is are there any good examples of the “right” level for 8th or 9th graders?

I want a false pattern where the result is not what it seems, where the first few examples you might try seem to support the idea, but at some point the pattern fails. More importantly, the “correct” pattern should be something accessible to good students with a strong grasp of basic algebra (but preferably not requiring quadratics).

I think these would be good examples to help students understand the value of a proof.

By the way, here is a related fun exercise. What is the next number in this sequence: 1, 2, 3, 4, 5, 6 ?

You can make it whatever you want, but here is a simple option to make it 8 (can you figure out how to make your own function like this? There is an easy trick):

Geogebra image