The Future of Math Education: Teaching Math Through Code

Hi Processing community :wave:

TLDR: We teach maths to primary and high school students in Singapore using p5js and are looking to collaborate with teachers to create novel and exciting math content. If you are a teacher interested in what we are doing, please reach out!

I have recently started with the vision of redefining maths education globally. Math education has not adapted much for the past 100 years; we still teach kids how to manually calculate things that are trivial for computers compute. In the process, we fail to teach creativity and problem-solving. We focus on formulas and rote learning instead of deep understanding, and there exists a vast chasm between the math taught in the classroom and the way math is done in the real world.

I believe the solution to this problem is by teaching math how it is done in the real world: using code and computers. Using code, we can not only make the math more applicable to the real world, but we can enable students to play and discover math for themselves instead of having it dictated to them from a whiteboard. To see what this looks like what this video

p5js is the perfect tool to make this vision a reality. It is easy to understand, powerful and can run all in a browser.

However, our biggest challenge is creating content to create exceptional content using p5js. The author needs an in-depth understanding of teaching, the math topic, and the code required all which make for a very challenging intersection.

We are looking to collaborate with teachers to create math content aligned with school curriculum using p5js. If you teach using p5js, have created math content before or are interested in what we are doing, please reach out!


This resonates a lot with me. I was lucky to get an intuition for math because I had an 8 bit computer which I enjoyed programming. My teacher didn’t like that I “had an intuition”, she wanted me to know the formulas and their names, not to actually be able to figure out the solutions with my own methods.

I believe that for most people the point of math is to pass an exam and nothing else. It doesn’t make much sense. But if they could learn math by making images, animation, games, music, poems it would appeal to more people. Learning math wouldn’t be an end in itself, but a creative tool.

Good luck in your project :slight_smile:

ps. Recommended book: Are there more recent interesting books in that topic?

ps2. Looking at your website it seems to be for parents who can afford it. That aspect I don’t like (if I got it right). It would be nicer if schools or governments would finance such a project.


Is this going to be a commercial enterprise like

Hey Hamoid could not agree more, the whole academic world is so focused on marks and assessments it leaves little room for actually creating something. I am well aware it is a rather pricey service targeted to parents, we needed to start somewhere and the easiest is one to one and one to many live classes with a tutor. (We’ve only been around for 2 months or so)

Our goal is to eventually develop a self-serve platform like or to write an interactive textbook which would be widely affordable/accessible.

PS another great textbook is: but there does not seem to be much processing/p5js focused.

@quark yes it will be, see my response to @hamoid to learn more. Our goal though is to make this content freely available and empower other teachers to do the same down the line.

Me, as a high schooler am forced to learn all the formulas and not to think of ways to make it more efficient. It encourages to follow them without using my brain and thinking. It is hard for me to remember all the random phrases the teacher wants me to know. Math (or at least high school math) requires you to know a formula that you most likely don’t understand. We never “dissected” a formula and look at how and why it works. However in coding, functions are made of small but “simple” blocks easy to understand. You only need to think for a while before you understand why something works and is made the way it is.

In coding you can solve a problem in almost infinite ways. Like drawing a cardioid (one of my favourite shapes). You can do it by drawing lines in a circle and connecting points with 2x higher value. Or you can create two circles which work like gears with both having the same radius and tracing a point on them. There is also a function that draws it. In real life you can find it in the bottom of a mug with cylindrical shape. This you can explore various ways to solve the same problem. (and I am aware that coding is based on math and calculations)

I like the approach of learning math and problem solving through coding.

Thank you for doing that : )

Edit: part of the reason why coding is so fun is because you don’t have to calculate things yourself. You only press a button which displays the result to you within the second. It is completely different to normal math on paper, where the slightest change in parameters forces you to recalculate the whole thing


Neat @StriveMath! My high school students and I are also working on this problem. They’re helping me to design curriculum and a teaching platform.

I’ve taught computational thinking in Algebra 2 and Precalculus for a few years using p5.js, and I’m distilling the lessons learned into a textbook, Computiful. Just finished editing Chapter 2 with a friend and will post it later today.

The Computiful Editor is a “light” version of the p5.js Web Editor that uses Python instead of JavaScript. I’m tailoring the platform based on student feedback and my own teaching experience. The Terms of Service and Privacy Policy are next on the roadmap. I’ll configure social login soonish.


here is another collection

for images see

@mcintyre this is so great to see! Chapter 1 is simply awesome, love the visualisations and way it is scaffolded. What age group is this content targeted at? I would imagine younger kids would find the set notation quite intimidating…

Also can see how it’s been inspired by Nature of Code, I’ve always thought there should be a similar project targeted more towards math.

Last question: why did you opt to use Python over JS I would imagine setting up your custom P5Py web editor was somewhat technically challenging?

Wow! I really was expecting a place to host Processing sketches using Python syntax! :snake:

But I wonder if it’s gonna be a “light” version forever? :pleading_face:

I’ve immediately missed seeing & editing the contents of the “index.html” file. :file_folder:

This idea in my opinion is good. I used to like math, but in the higher grades, the fun slowly fades away. They don’t teach you how to solve problems, skills that are essential for the real world. I would love for this to become a reality.

1 Like

@mcintyre wow! this is cool! i am curious: did you use brython as a layer on top of p5js?

Thanks so much!! Critiques are always welcome, too. Just posted Chapter 2.

If the book gets read :slightly_smiling_face: I imagine the audience will primarily be teachers and lifelong learners. For better or worse, I seldom assign reading in my own math classes outside of research. We do cover set notation at about the level presented.

Switching to Python is a recent development. My school district is standardizing on Python for our introductory CS courses, and pyp5js now runs entirely in the browser. I had a little time over the holiday break to tinker with the p5.js Web Editor and first managed to convert it to Python in this fork. I’ll open source the Computiful Editor as soon as the dust has settled.

In my wildest dreams, I would love to teach a version of the class to 8th graders so that they can take Calculus straight away in high school.

@GoToLoop not necessarily! :wink: But I’m starting out with a very specific use case in mind and thought I’d start with the bare minimum of features.

@wavesmith thanks! Yep, I used Brython as you can see in my forks of pyp5js and the p5.js Web Editor. Those development teams did all the hard work.


The main pyp5js’ compiler is Transcrypt, and Brython is the alternative.

AFAIK Brython is slower than Transcrypt but can run more Python stuff.

On one hand I really like this, because I have to visualize things to learn them. If I cannot connect a picture with a formula, or I can plug in some numbers to see what it does, it is hard for me to understand and use it correctly.

On the other hand I am very well aware that this is also limiting. There are problems in math you cannot visualize but you can apply the formulas correctly to get the solution.

I think the analysis/dissection of a formula, as mentioned above, is important to teach. People get scared to quickly by complex formulas, when in reality they are just plugged together like a computer program. You have to work through them step by step.
Especially in physics and chemistry a lot of “noise” in a formula is created through constants, normalizations and approximations, which makes it hard to understand the essence of the formula. Being able to identify these tools to fully understand, what the formula wants to tell us about “how nature works”, is, where there is often a gap.
Not sure, if one can teach these tools just by visualization, there is some formula craft to it, which has to be applied.

Hope that makes sense.
I know these things might come later in the process of math teaching, then where you are working right now.


I’m also fully supporting using coding to present / visualize Math concepts.
You can plot function graphs, you can display prime numbers, display Fibonacci numbers, etc.

Below are a few examples from Math section:

Plot a function

Navigate prime numbers:

Navigate Fibonacci numbers: