What is Euler integration?

The simplest numerical method for stepping a simulation forward: the next value equals the current value plus the time step times the current rate.

Euler integration diagram example

Public diagram from the Machinations Community. Open it on its own page

Euler integration is the simplest way to calculate how a quantity changes over time in a simulation. It takes the current rate of change, assumes it stays constant for one time step, and adds the result to the current value. It matters because most simulation tools use it by default, and its errors grow when the step is large.

How it works

The rule is next value = current value + DT × rate. The rate is worked out once at the start of the step, from the current state. Because real rates keep changing during the step, the method is always slightly wrong, and the error shows up as drift. For a growing quantity, Euler gives values that are too low, and for a decaying one it can undershoot or even swing negative when the time step is large.

The error shrinks in proportion to DT, so halving the step roughly halves the error. When that is too slow or too costly, the Runge-Kutta method samples the rate several times per step and is far more accurate for the same step size. Euler is still the usual choice for system dynamics work, because the models have small steps and clear interpretations: each step is simply inflow minus outflow.

Example

Say a population of 100 grows at 10 percent per unit of time, so the rate is 0.1 times the population. With DT of 1, step one adds 10 and gives 110. Step two adds 11 and gives 121. Step three adds 12.1 and gives 133.1. The exact curve gives about 110.5, 122.1, and 135.0. After 10 steps Euler reaches 259.4 while the exact value is 271.8, so the gap widens. With DT of 0.1 the error drops sharply. This is an illustration with round numbers.

How to model it in Machinations

Build the population as a Pool with a Source whose rate is 10 percent of the Pool, and a Register for the step size. Put the exact result, computed from a formula, into a second Register and chart both next to each other. Play it and move the step-size Lever to watch the gap open and close.

See Euler integration in a system you can Play

Build the rules in a Machinations diagram, change a value and Play it to watch how the system responds.