 # Numerical simulation

Comparing the graph of the Vensim-model to what can be generated using the exponential function (i.e. the Euler-number $$e$$), might give the impression that the curves are identical. This is not the case. Since in most practical cases solutions for differential equations are not or not easily to be found, numerical simulation methods as deployed in Vensim and other System Dynamics-platforms resort to methods based on difference or recursive equations. This means that dynamics are calculated with discrete time steps, which makes the result dependent on the size of the time step. The smaller the steps, the closer the results resemble the output of the explicit solutions for the exponential growth equations.

Vensim allows for calculations with different time steps (see: Model > Settings > TIME STEP). The left graph below shows different outputs of these calculations. (In order to make the differences more distinct, different parameters were used, in particular: $$\gamma = 0.2$$, $$N_0= 1$$ and a shorter interval of 10 time steps). The right plot shows a comparison of a recursive calculation with $$time step = 1$$ (blue) and the exact solution using $$N_0*e^{γt}$$(red), for $$\gamma = 0.2$$ and $$N_0 = 1$$.  ## Integration types

Additionally, Vensim-PLE allows for calculations with two different integration types, called Euler and Runga-Kutta-4 (or RK4) (see: Model > Settings > Integration type)

Basically, integration types are methods to solve the initial value problem which arises in numerical calculation of a differential equation. In short, the integration type called Euler (after the mathematician Leonhard Euler) finds the initial value of each calculation step by moving one time step along a line tangent to the curve. It considers just the current computed value and therefore is not overly accurate.

The family of integration types called Runga-Kutta (after the mathematicians Carl Runge and Martin Wilhelm Kutta) considers more than one previously computed value in order to approximate the next step’s initial value. RK4 – or “classical Runga-Kutta” - considers the current value plus the weighted average of four increments resulting from estimations of the slope in the interval to the next step. It is a popular compromise between accuracy and need for computational power. The following figure shows a comparison of graphs resulting from these two integration types. As can be seen, differences can be quite severe. In practical modeling, the reasonability for using smaller time steps or more accurate integration types depends on the needed accuracy and the quality of available data.