Differential Equations – A Child’s Play

Differential Equations – A Child’s Play

“Differential equations”… To most people who went to high-school, these words will bring back blurred memories of something complicated and tedious. Some will recall that they involved “functions” and “derivatives” and that they were solved using opaque techniques that one had to learn by heart. Most people have since then personally experienced that they never turned out to be useful anyways and happily forgotten all about them.

But:

  1. Differential equations are useful, and
  2. understanding them is, literally, a child’s play.

Here’s why.

Ever wondered how to make weather forecasts? Or how to design sky-scrapers that will last a century, or resist earthquakes? How to model the complex electronic circuits inside cell phones and computers? If you are considering buying a house, it might be relevant for you to know how the estate market will react to an increase in the interest rate… and so on.

As it happens, differential equations turn out to be key here. Let’s elaborate on the first example above, the weather forecast, to illustrate how they work in real life. Imagine that we start out with two satellite images, one taken a few seconds ago and one taken now. From the difference between the images, we can tell which way the winds are blowing. We can also see where the ground is being heated by the sun, where the clouds are being formed etc. Since meteorologists have a good understanding of how all these factors play together, they can now calculate how the weather system will change over the next few seconds. Adding this change to the current state tells what the weather will be like a few seconds from now, in turn allowing to calculate the next change and so on. Doing this over and over again will eventually give us a good estimate of the weather several minutes, hours and even days from now.

In the essence, we are solving a complex problem by engaging it from one end and working our way through it, integrating one small piece (difference) at the time into the eventually complete solution. And this reasoning, this practical necessity, is probably what led Newton, Leibniz and the like to invent differential calculus over 300 years ago.

The Equation Group on the July 2nd ’17 hackathon. Prototypical hacking and playing with differential equations.

But something they didn’t have back in the 17th century was… computers. The equations had to be solved using pen and paper, perseverance, skill and imagination – dark wizardry reserved for the select few.

That has changed. During the last decades, computers have grown in speed and power and what used to be a super-computer is now available to literally anyone. In the meantime, the level of entry into the world of programming has reduced drastically, and it is not uncommon to meet children proficient in half a dozen programming languages. What computers are good at is doing the same thing over and over again – exactly what is needed for solving the differential equations. So, with the advent of computers, it became much easier.

As an example, let’s consider a particularly captivating problem, that of gravity.

In less than 20 lines of simple code (see below), the programmer will get a hands-on experience of

  • what planetary trajectories look like (they’re elliptic)
  • what is meant by “sling shooting” satellites in the solar system
  • what the “escape velocity” is all about
  • and so on…

The result looks like this (the code can be copy+pasted into Khan Academy’s Javascript/ProcessingJS framework )

 

What the code expresses is:

  • line 2-5: set the initial position and velocity of the planet
  • line 6: set the time step for each iteration. The smaller the step, the more precise the calculation will be, and the longer it will take
  • line 7: the draw() function. In the framework we are using – called ProcessingJS – this function will be called over and over again.
  • lines 8-10: these lines are central to the program as they fully govern the behavior of the planetary motion. The variables xpp and ypp are the accelerations in the x- and y-directions respectively. According to Newton’s law of universal gravitation, the gravity-induced acceleration is directed towards the attracting body (in this example the origin), is proportional to the mass of the body and drops with the square of the distance to the body.
  • lines 11-14: given the newly updated acceleration, update the velocity and then the position.
  • lines 16-19: redraw the planet given its new position.

As we will see in a more detailed sequel to this article, a number of collateral learnings typically arise from this type of exercise, such as

  • learning about arrays, lists and objects,
  • refactoring code into functions,
  • experiencing the limitations of models and numerical instability,
  • Pythagoras’s theorem,
  • scientific notation…

From a didactical and pedagogical perspective this is quite interesting, as what we have here is a constructivist entry point to the full math curricula from primary to high school, and beyond. In other words, within inquiry-based approaches to teaching, the combination of differential equations and programming offers an engaging math environment to immerse the learners in, something that otherwise tends to be a challenge for these pedagogies.

On a side note and regarding the programming aspects, implementing simple “puzzles” such as the one described above is a low-barrier-of-entry way to get introduced to programming, or to explore new programming languages. They provide an advanced “hello world” program, allowing to rapidly assess the basic features of a new language.

Differential equations in themselves, as well as the techniques used for solving them are interesting per se, in the sense that they form the foundations of most scientific research.

What is of even more general interest, is the reasoning behind differential equations, the idea of decomposing a problem into manageable parts and working your way through.  They allow to reason about functions, these constructs that essentially associate an output with an input, the “Swiss army knife of abstract thinking”, providing a general scheme to improve one’s ability to understand.

And that is relevant for everyone.

Want to dig in further? – see our evolving collection of puzzles.

About the Author