@DrBennison has recently written an excellent blog post, Python and Further Maths 1. He makes the excellent points that (a) numerical methods are taught without any reference to a computer and, more generally, (b) coding a particular procedure can greatly develop your understanding of it.
I too am fortunate to have picked up coding skills throughout the course of my life. Showing my age, I remember first learning to write short programs on BBC computers in school. One even involved learning binary to create the image of a space-invaders style icon. Later in the school we also learned how to control Lego devices from our programs – incredibly engaging.
I really learned to program properly in sixth form when one of my maths teachers recommended Pascal as a language that I might like to learn. I found a compiler for my Amiga 1200 and was away. (Also in the sixth form, a few of us had Casio graphics calculators and getting one of those to draw the Mandelbrot set was amazing!)
[Image from this website]
Skills Programming Develops
Learning ‘to code’ is about much more than learning the keywords and syntax of a programming language. It concentrates you into the strictest form of logical thought and procedure; you learn about conditional statements and loops; and even with simple programs, begin to grasp the ideas of program specification and getting the computer to do precisely what is required.
However, with the more primitive languages such as BASIC and Pascal, there are more fundamental mathematical skills that get challenged. If you want a picture of the Mandelbrot set, you need to separate all the calculations for real and imaginary parts. These languages can’t deal with complex numbers. (This can lead you to learn about object-oriented programming, but that’s another story.) More fundamentally still, if you want any kind of graph on the screen you need to figure out how to scale a (0,0)-(600,600) TL to BR rectangle to a (-2.25,-1.5)-(0.75,1.5) BL to TR rectangle, and vice versa.
Of course, higher level languages exist today to increase productivity: if you want to plot a graph of y=sin(x) in Python, you just call upon one of the graphics libraries such as matplotlib or pyx. If the graph is the aim then, really, a programming language isn’t needed at all – even Google will do it for you these days!
Mind Your Language
As is always the nature with software (and more generally with teaching) we must choose the tool most appropriate to the job. Here are a few examples of languages I’ve used and why:
|Yabasic||Introduce young students (age 11-13) to simple programming constructs: variables, arrays, IF..THEN, FOR..NEXT etc. They could write programs generating the Fibonacci sequence, for example. (See the challenge sheet I created.) Simple graphics were also possible and they learned about specifying coordinates, dimensions and RGB colour values.|
|Basic4GL||I used this with Further Maths students a few years ago as it easily handles 3D coordinates and matrix transformations. It’s unbelievably satisfying just to create a rotating cube, for example!|
|Excel||Ok, this isn’t really a programming language as such, but I always get AS Maths students to do some coordinate geometry work in Excel so they become familiar with formulae and cells. Given two coordinates (which take up 4 cells) they must create a spreadsheet that calculates distance, gradient, midpoint etc.|
|PHP||Not a likely candidate for beginning programmers, but for another extra-curricular club I worked with a group of students to develop a website functioning along the lines of a blog. We were able to run PHP, MYSQL and Apache from USB sticks.|
|Python||I’m quite a new-comer to Python but have used it fairly successfully in another extra-curricular club. Last autumn I had a group of students tackling the National Cipher Challenge and, with help from the example programs in this guide, we simultaneously learned some Python along the way. Next autumn, I’m teaming up with a colleague from Physics to base a club around the Raspberry Pi, Python programming and controlling electronic components.|
Now let’s take a topic such as the Newton-Raphson method. Students learn this in FP1 (at least with Edexcel they do). Is this something that I would like them to be able to code? And to what end… so that they learn about coding? So they can see a computer follow the algorithm? So they can visualise the output? To be honest, right now I can’t see much value in asking them to program this algorithm – please convince me I’m wrong! What I do love to talk them about, however, is the fractals that arise from applying Newton’s method to find, for example, the cube roots of unity:
[Image from Wikipedia]
Think, Pair, Share
- I’m being devil’s advocate here: I think coding is an immensely important skill for students to learn, not least because of the ways of thinking it develops. When teaching maths students to code, are we doing it so they learn programming or are we doing it so they better understand the mathematics?
- Is it better to start with a higher or lower level language? BASIC strips away all the niceties so that the focus is on the bare bones of a programming language. Python allows for very quick programs to perform say a Caesar shift or to plot calculated data.
- Which topics on the maths curriculum lend themselves most meaningfully to worthwhile programming activities?