Journée francophone du 25 février 2018 – Programmation et équations différentielles

Programmation et équations différentielles

Journée francophone, dimanche 25 février 2018

1) Pour commencer:

Dans le navigateur internet, aller sur

2) Dans la documentation, trouver comment dessiner un rectangle

En dessiner trois. Ou autre chose, comme on veut :)

3) Animer un des objets dessinés

Créer une variable, par exemple

var x = 0;

Créer une fonction

draw = function() {

background(255, 255, 255);

rect(x, 100, 100, 100);

x = x + 1;


4) Faire rebondir l’objet sur les rebords:

En début de programme, faire une variable v (pour vitesse):

var v = 1;

Dans la fonction draw, ajouter:

if (x < 0) {

v = 1;


if (x > 400) {

v = -1;


changer x = x + 1 en x = x + v

5) Au choix

  • ajouter une variable y (position verticale) et une vitesse verticale

  • ajouter une accélération


Exemple de résultat final.


On how we construct trust

Baby taking a nap outside while mom is shopping.


“Can most people be trusted?”. If you ask the Danes, they will answer yes 8.3 times out of 10, on average. This makes them the most trusting population in the world according to the OECD 2017 “How’s life” annual survey.

The probably complex historical and social context that has led to this state of affairs, the question whether the population’s homogeneity is a factor, or whether the Danes are simply too lazy to mistrust other people… will not be the subject of this article.

Nor will we address the question of whether the record high tax pressure is a prerequisite for the welfare society and a high trust score. Nor, conversely, whether the high trust level simply makes society so extraordinarily efficient that it can accommodate a large and inefficient public sector as well as a largely sub-optimal allocation of resources to tasks on a societal level, in part compensated for by undeclared work (which 40% of Danes make use of), not to mention widespread crab mentality.

This article is specifically about how – and why – we construct trust at The Danish-French School of Copenhagen.

First we will consider the importance of the main tool that we are using – relationships and the approx. 17 practical principles we use to build them. They are summarized later in the next section, but might be worthwhile a read to better understand the article.

Then we will apply an information-theoretic perspective to each of the principles in order to illustrate how the process of reducing the amount of information addresses a fundamental need, in turn strengthening relations and trust.

Finally we present a simple model that illustrates why trust deserves a very particular focus as a value in society.

Relationships and information condensation

Trust is about relations between people, hence the most important of our 17 principles, “Establish relationships”.

An important aspect that has turned out to be recurring in many of the 17 principles is the overarching idea of information reduction, or rather information condensation. The brain continuously processes enormous amounts of information and the task it accomplishes when distinguishing relevant from irrelevant – condensing the information – is a truly formidable effort. We see it as a sort of extra layer at the bottom of Maslow’s hierarchy of needs: the ability to give oneself a direction in the super-high-dimensional space of potentialities conveyed by our senses, but in essence akin to what the simplest organisms must be experiencing when following say a nutrient gradient.

From a didactical and a relationship-building perspective this also means that whenever one can help the child “find the gradient”, it is a fundamental need that is being addressed, resulting in a significant strengthening of the relationship and the trust.

This information-theoretic perspective sheds a new light on each of the 17 principles:

Principle How the principle acts as information condensing
1 Establish relationships
  1. When you have a relation, you know what to expect from each other, allowing to disregard an infinity of other options that one then doesn’t need to spend attention on.
  2. Relations create psychological safety that allows you to relax and focus on moving forward.
  3. Self-esteem results from the fact that the relation conveys recognition and reflection.
2 Agreements A clear and condensed formulation of what to expect.
3 Rules, recognizing justice and co-ownership Like in principle no. 2 but even more condensed. Also, fairness and justice imply a high degree of predictability.
4 Noise and quiet Clearly distinguish the information-carrying signals from the noise.
5 Simple explanations Information-dense nuggets.
6 High expectations A clear gradient to follow- which probably explains why they are so efficient.
7 Help others – social capital Supports in building relations, see principle no. 1.
8 Keep track of what the individual is doing / finishing things Staying focused on a gradient.
9 Children need to test Clarifying the limits of the playing field.
10 Repetition makes master Repetition is probably the most common information-condensing mechanism.
11 Set limits to the tasks, not the time spent Staying focused on a gradient.
12 Give options Reducing the high-dimensional space of possibilities to a few options.
13 Correct mistakes as early as possible – give and demand feedback Feedback condenses the vast “what-I-might-have-been-perceived-like” to the simple “what-actually-was”.
14 Do not steal the children’s play Favors relations, see principle 1.
15 Avoid “Shh!” and instead give specific messages Specific messages are obviously much more information-dense and actionable.
16 Only one adult at a time One responsible adult creates a simpler field of expectations than multiple persons.
17 Clear communication and honesty Should be self-explanatory.


And so it appears that information condensation is indeed a governing trait of our pedagogy.

A few aspects that are not covered by the 17 principles, but are relevant in a trust-building context:

Long-lasting relations

The multi-aged structure of the school favors long-lasting relationships. Our teachers typically follow the children for many years – potentially from when they are 2 to 15. This means that teachers and children can get to know each other very well, simply due to the sheer time they spend together. But it also means that all the group members are in it for the long run, further strengthening the incentives to construct strong relations.

Impediments to trust

A direct impediment to trust typically occurs when the members of the group need to compete for a scarce resource, be it two children wanting the same toy, or two employees wanting the same job, etc. The guiding principles we have successfully applied in those cases were:

  1. share the resource, for instance taking turns. Very often it will from a global perspective be a better solution that the two members each get ~50% of the resource, rather than splitting 0% – 100%.
  2. in case the resource is not shareable, allocate the resource according to what is most aligned with the group’s mission. Discuss what best serves the greater purpose and apply that. Sometimes you just need to take one for the team.
  3. in either case, be conscious of and open about the conflict. When the solution is fair, it is much easier to accept it even if it is not at one’s own advantage.

Another impediment to trust stems from the average human being’s relative perception of success. When you sit in a train and the train next to you starts moving, you can get the impression that you are moving backwards. That is similar to when your friend has success and you feel it as your failure. Both impressions are factually wrong, resulting from a flaw in how our perception works. Suffice to imagine that you are seeing the situations from an absolute observer position and it becomes clear that your friend’s success is in part your success, and that the winning strategy is to help your friends, to energize your network. We teach that from an early age.

The why

We have covered the question of how we construct trust at the school. The reason why should become very clear when considering the following model:

Given some relatively obvious assumptions of a somewhat mathematical nature, we will conclude that it is worthwhile to act honestly and trustingly in the sense that the growth you can expect to experience in return depends exponentially on it.

The simulation works in the following way: a population consisting of a number of individuals undergo a number of transactions (iterations). Each individual is described by its capital, its honesty and its trust in each of the other individuals. Each transaction occurs between two randomly picked individuals A and B in the following way:

  1. A invests a value in B, where value = capital of A x trust between A and B.
  2. B generates some added value from the investment.
  3. a die is rolled and is compared to the honesty of B: B either returns the investment (successful transaction) or keeps the full investment (unsuccessful transaction).
  4. in case of a successful transaction, the trust between A and B is increased. Conversely it is decreased in case of an unsuccessful transaction.
  5. pick two new individuals A and B and go to 1 (unless the intended number of iterations has been reached)

The resulting simulated relations of trust in a sample of four different populations look like this after 200 iterations (The thickness of the line expresses the trust score, between 0 and 1):

The corresponding simulated total value of the population looks like this:

That… is a semilog plot.

It turned out that the y-axis had to be logarithmic to properly express how much of a winning strategy it is for a group of individuals to adopt an honest and trustful culture.


We have described that constructing trust amounts to building relations and how we do it. We emphasized the information-theoretic perspective, as we are uncovering that helping the children to condense the information, or understand, is a fantastic catalyst for trust.

We then saw that, perhaps surprisingly, growth depends exponentially on trust. Few other factors, if any, have that type of positive impact on society, suggesting that trust be the dearest treasure of any nation.

The Loop

In my previous article I described how one can use a differential equation to calculate the trajectory of the Earth around the Sun. But at the end it was quite tedious so I decided to use a computer instead. Because they are good at repeating things. One way to make a computer do the same things again and again is to use a loop. In the program below we will show how a for loop works:

var x = 100;
var y = 0;
var xp = 0;
var yp = 30;
var G = 1;
var m = 100000;

for (var i = 0; i < 18; i+=1) { var d = Math.sqrt(xx + yy); var a = Gm/(dd); var xpp = -x/da; var ypp = -y/da; xp = xp + xpp; yp = yp + ypp; y = y + yp; x = x + xp;

fill(72, 54, 214);
ellipse(x + 200, - y + 200, 10, 10);

} fill(255, 234, 0); ellipse(200,200,20,20);

What the program does is to draw a planet 18 times using a for loop.

In each iteration of the loop first of all you calculate the distance from the sun to the planet, after you need to calculate the acceleration then you should find the speed of the planet at the end you can find the position of the planet.


This video explains about the code above:

The Structure

In a not too distant future, humankind has started constructing a gigantic platform orbiting {the Moon, Earth, the Sun…}.

Building blocks are mined on the Moon and sent into space using an electromagnetic railgun.

On Earth, gravity effectively limits the size of anything we want to build.

In space however, there are no such limitations.

Over the years the construction has grown into the largest thing ever built by mankind: The Structure.



  • What does The Structure look like?
  • What materials is it built of?
  • What is it used for?

You can use either text (novel, report, …), pictures/drawings, build a model…

Imagine limitlessly!

Blender project (License: CC0)


Vi fik den ind med modersmælken – “Otte-og-tyve skal der stå, på din mo-ars storetå!”. Otteogtyve? Det gav aldrig rigtig mening efterfølgende. Der er 26 bogstaver i det engelske (og franske) alfabet. Og var der ikke tre bogstavers forskel (æ, ø, å)?

26 + 3 ≠ 28

En lettere irriterende, uidentificeret splint i hjernen – og den sad der i mange år.

Problem solved!

Lige indtil det  ved en nærmere analyse af alfabetsangen viste sig, at man simpelthen har fjernet W. Hvorfor? Måske har nogen syntes at W i højere grad end f.eks. X eller Z er et fremmedbogstav (for ikke at nævne Q!). Men “xylofon” er vel næppe mere dansk end “wienerbrød”. De kalder det sågar “a danish (pastry)” på udenlandsk.

Og slår man op i ordbogen, er den god nok. W fremgår. Ligesom de andre bogstaver har W simpelthen et helt kapitel for sig selv (mellem V og X). Et af de kortere kapitler vel at mærke, men det er der.

Næ, forklaringen er nok ganske enkelt, at “dob-belt-V” rim- og stavelsesmæssigt ikke passede ind i sangen. Og så har man simpelthen bare fjernet det. Et grimt hack, men… Problem solved!

Eller måske er det fordi, at man med 28 bogstaver kan lave en fin 7 x 4 tabel. Eller 4 x 7. (Det kan man ikke med primtallet 29.) Der kan være mange gode grunde.

Men summa summarum: den første boglige læring de fleste danske børn modtager er… helt faktuelt forkert.



“Det er også de pædagoger, der ikke kan tælle”, tænker lærerne måske, for de er jo lidt finere end pædagogerne (ifølge lærerne), men dog ikke helt så fine som kandidaterne (ifølge kandidaterne).

Lærerne har nemlig læst Hiim og Hippe. De kan skabe læring for børnene takket være den didaktiskte relationsmodel. Bibelen. Den udenforstående kunne måske forledes til at tro, at “relation” i den sammenhæng refererer til relationen til barnet, eller mere generelt til den lærende. Den gode relation, forudsætningen for den gode undervisning…

Men nej. “Relation” hentyder her til, at der er en sammenhæng – en relation – mellem seks ligeværdige faktorer, som tegnes i en fin sekskant, hvor alt er forbundet til alt.


Men… hvis alt er forbundet til alt, er det jo bare en liste med seks ord.

Det er der ikke meget model over.

Derudover er faktorerne ikke ligeværdige. F.eks. vil man typisk i et projekt starte med at definere nogle mål. Disse vil være ret konstante gennem hele læreprocessen og i praksis være uafhængige af ændringer i f.eks. rammefaktorerne.

Det er hele idéen med mål.

Med det udgangspunkt kan man måske godt forstå, at klasseledelse pludselig bliver en svær kunst.

Det kan være svært at holde en kurs.



Ineffektiv løsning på et problem, man ikke har opdaget er vendt på hovedet.

Lærerne har også læst Bourdieu. Bourdieu var en fransk sociolog, uddannet på den fine École Normale Supérieure og som bl.a. gjorde et forsøg på give sociologien et videnskabeligt anstrøg ved at indføre matematik-inspirerede begreber såsom rum og felter. Men er Bourdieus beskrivelse af verdens magtdynamikker fra forrige århundrede overhovedet relevant post 2000, efter at IT-knejterne vendte det hele på hovedet?

Bourdieusianerne lader – ironisk nok – til at sidde fast i en magtdiskurs. De går op i arkaiske begreber som f.eks.  klassekamp og opererer i et politisk polariseret rum, som ikke leder til andet end indbyrdes småstridigheder i samfundet, altimens de nye (foreløbigt venligtsindede) teknologi-overlords click efter click, download efter download, akkumulerer klodens kapitaler.

Hvor det tidligere var tilstrækkeligt at kunne læse og skrive, er barren for reelt at kunne agere i den nye verdensorden hævet en smule – den nye alfabetisering hedder “programmering”.

I denne fagre nye teknologiverden er det nye regler, der gælder:

  • Man deler information: Viden er stadig magt, men informationen er blevet let tilgængelig og dette til overflod. Akkumuleret viden – og andre kapitaler – er blevet kraftigt devaluerede. Den afgørende færdighed er nu at mestre kunsten at adskille væsentligt fra uvæsentligt.
  • Dygtighed belønnes: I et miljø, hvor idéer og fortællinger har mulighed for at udbrede sig med eksponentiel fart, har det enkelte individ mulighed for at gøre en forskel – det afhænger udelukkende af kompetencer. I et erhvervsliv, hvor disruption er hverdagskost, er det ikke længere den store fisk, der spiser den lille, men den hurtige, der spiser den langsomme.
  • Sjovt skal det være: inden for softwareverdenen har det vist sig, at de teknologier, der i sidste ende vinder udbredelse er dem, udviklerne kan lide. Enkelthed, overholdelse af standarter, kritisk masse i community’et er her afgørende.
  • Der kan bygges i en uendelighed: mængden af systemer der kan bygges, opdagelser der kan gøres, ting der kan opfindes, universer der kan udforskes ser ud til at være uendelig. Der er arbejde i overflod til alle.

Vi må nok se i øjnene, at det ligger et par dekader ude i fremtiden, at vi får tilpasset undervisningssystemet til disse nye realiteter og dermed giver børnene de bedste muligheder for at begå sig i dagens videnssamfund.

Dekaders sludderkultur at få ryddet op i.

Man kunne starte i det små – og blive enige om, at “niogtyve skal der stå”.





Det handler om at udregne svære problemer ved at tage det i små bidder ad gangen. Lad mig illustrere det med et eksempel. Forestil dig, at du gerne vil udregne jordens bane rundt om solen. Den her tegning den viser hvordan jorden roterer rundt om solen. Nu vil jeg gerne forklare hvordan det virker. Afstanden fra solen til jorden kalder man “d”, så når man har ganget “d” med sig selv bliver det til “d2“, så skal man dividere 100000 med “d2” hvilket giver accelerationen “a”.

Så først skal man tegne solen midt i papiret. I dette eksempel tegner vi jorden d= 100 mm væk fra solen. Og derudover tegner du jordens hastighed, for eksempel med en blå pil. I dette eksempel er den 30 mm lang og er vinkelret på retningen ind mod solen. Så nu skal  du udregne “a” som beskrevet ovenfor. Her giver det for eksempel a = 100000 ÷ 10000 = 10 mm. Accelerationen tegnes med for eksempel en rød pil ind mod solen. Hvis man tegner den røde pil ude for enden af den blå pil får man jordens nye position og dens nye hastighed.

Jordens bane rundt om solen

Og dette skal man gentage nogle gange og til sidst får man jordens bane :D

I næste artikel vil vi se hvordan dette kan gøres meget lettere ved hjælp af for loops.


Alix, 11 år


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.


  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…

//Equation: f'' = - 500 * f / norm(f) / norm(f)^2
var x = 20; //initial position
var y = 20;
var xp = -5;//initial velocity
var yp = -1;
var dt = 0.1; //time difference between each update
draw = function() { //draw() - a built-in continuously looping function (ProcessingJS)
   var distance = Math.sqrt(x * x + y * y);
   var xpp = - 500 * x / distance / Math.pow(distance,2); //acceleration
   var ypp = - 500 * y / distance / Math.pow(distance,2);
   xp = xp + xpp * dt; //integrating the acceleration into the velocity
   yp = yp + ypp * dt;
   x = x + xp *dt; //integrating the velocity into the position
   y = y + yp *dt;

background(255, 0, 0); //redraw the new state line(200, 400, 200, 0); line(0, 200, 400, 200); ellipse(200 + x, 200 + y, 10, 10); };

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 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.

Hacking a ton

Within the hacker communities, a so-called hackathon (the contraction of hacking and marathon) is a well-known concept which consists of meeting up and getting some intensive programming done, typically during a day or so.

The hackaton or hackatonne (/hæk.ə.tʌn/) however is a less known concept (to be fair, a completely unknown concept at the time of writing). It consists of hacking an actual metric ton of devices.

While the hackathon is supposed to be a relatively short and intense event during which you are supposed to get something useful done, there are no such constraints on the hackaton. Reaching the full metric ton of hacks can take weeks, months or even years. Also, the definition of a hack is quite broad and diffuse, but can essentially be summarized to “any modification or use of an object that was not originally intended”, leaving a lot of freedom in the choice of activities.

So for our first hackaton session on May 22nd, we went to Guldminen to disassemble toys. Guldminen is physically a hangar situated in a recycling station, a sort of laboratory in which the Guldminers collect discarded materials in order to develop new ways to reuse, upcycle, repair, redesign and redistribute them.

Aha-experience as Supergirl sees through the appearances.

As a part of our STEM-for-girls experiment the location was perfect to train the children in disassembling devices, the objective being to strengthen the habit of investigating what lies behind the surface. Also, practicing simple motor skills such as screwing (clock-wise) and unscrewing (counter-clock-wise) is quite relevant for children of that age.

Guldminers Monica and Henrique took us for a walk around the recycling station and presented Guldminen’s facilities – a lot of machines including a lathe, a CNC milling machine / laser cutter a planer and more.

In preparation of the session, Guldminen had collected items for us during the week-end. These included a vinyl disk player, a large amount of plastic cars / cranes / tractors / bulldozers / trucks, an electrical trike, a cash register, kitchen toys, just to name some.

Frenetic unboxing of the week-end’s harvest of trashed toys.

The hacking took place around two tables that Monica had prepared for us, with groups forming dynamically depending on which objects the children found interesting. We had brought additional screwdrivers and pliers, batteries, a couple of microcontrollers and a glue gun. Eight volunteers, mainly parents, assisted the groups when necessary. The session turned out to be well suited for a multi-aged group, as the smaller children (3y) followed along and entertained themselves with all the “new” toys.

The purpose of the session was mainly disassembly, but on the reassembly side we did manage to activate a piezoelectric speaker from a walkie-talkie using the Arduino controller.

During the final evaluation, the children expressed that they had had a lot of fun and that we should definitely do similar sessions again.

Some of the learnings of the day are:

  • remember to bring a lot of screwdrivers, in particular with PH and PZ heads
  • in case you want to also do reassembly, have some projects ready beforehand
  • all disassemblable toys  have an interest, but electronic toys are easier to use in a STEM-teaching context

Some ideas for next steps:

  • organize a more repair- and reassembly-oriented workshop
  • set up a gaming arcade – would require monitors and game controllers, and preferably also some computers
  • give old computers new life by installing Linux on them
  • build a giant cinema-like screen by juxtaposing discarded monitors
Catch of the day: this fast little devil earned us 4.2 kg for the hackaton. Total session score: 8.1 kg.