Most of these examples use Catacomb's Numerics object which uses four numerical methods to solve a linear second order differential equation A d2y / dx2 + Bdy/dx + Cy + D = 0.
The methods are the forward and backward Euler methods, fourth order Runge Kutta, and the implicit midpoint method. The last is just a combination of the two Euler methods, taking the gradient for a step as the average of the gradient at the start and end.
The graphs can be rescaled with the mouse: a brief summary is given above the graph, but see the table in the user interface documentation for details.
 
numerics1 |
Numerical solution of a second order linear differential
equation.
A d^2y/dx^2 + Bdy/dx +Cy +D = 0
The initial conditions on y and its gradient are y0 and
dydx0. The integration is run for a total length xmax
in steps of dx.
Three integration schemes are shown, as in the Y menu:
forward Euler (blue), backward Euler (green),
and 4th order Runge Kutta (yellow).
For small steplength, dx they all agree, but as the
step length is increased the different schemes diverge, with
the forward Euler going unstable first.
To manipulate the graph, click with the left mouse button to zoom in, keeping the point under the mouse fixed. To zoom out use the right button, or the left with the ALT or CTRL key. Clicking to the left of the x axis will scale only that axis. Dragging with the right button moves the whole graph. Alternatively, the scrollbars show the fraction of the data visible in the current window: they may be stretched to see more, or squashed to show less (in more detail). Another way of setting the range is to use the edit config option under the data menu. This provides a window of sliders for the limits, among other properties. Typing with the mouse on a slider lets you enter a number from the keyboard - hit return for it to take effect. To reset the model to the initial values, use the reset button at the top left.
| |
|   | ||
numerics2 |
Here the coefficients have been adjusted to give a slowly
decaying oscillation and the step length is rather large.
Decrease the step length to see how the various schemes
approximate the true solution. Note that as the step length
decreases from 0.3 to 0.1, the Euler (blue)
solution has approximately the right amplitude, but
the wrong frequency. It converges towards the RK (yellow)
method which is good on frequency, but underestimates the
amplitude. The correct solution can be found by decreasing the
step size dx until all the solutions agree and further decrease
makes no difference to the result.
For moderate step lengths, where the Euler and RK solutions are quite close, the backward Euler (green) is still way off. This is a common feature of implicit methods: they gain stability at the cost of accuracy. The backward Euler method (green) misses most of the oscillations for all but the shortest steps. Instead it converges to the equilibrium solution whatever the step length. Increase dx to see that the implicit method is the only one never to blow up. Now reduce B to about -1 to give a growing oscillation. As a short cut for rescaling the graph, the find button will set the range to frame the current data. A fourth method is included in the calculation but not shown by default. From the Y menu select implicit midpoint to show that method in red. Like the Euler method it is implicit, but the gradient over a step is the average of the gradient at the start and end points. It is less stable than the backward Euler method but follows the oscillations rather better. Increase the step length and note how the Euler and midpoint methods fail catastrophically, whereas the Runge Kutta method goes flat, and the implicit Euler does nothing.
| |
|   | ||
numerics3 |
The same form of equation can also show unbounded growth.
Change D or the starting conditions y0 and dydx0
to change the rate and sign. In the calculation, values are
capped at plus or minus 1000 to keep the graph within reasonable
ranges. The backward Euler always overestimates the
growth whereas the midpoint and Runge Kutta methods remain
reliable even for fairly large steps.
Reducing the stepsize dx brings all the lines into agreement,
but as the step is decreased,
the two first order methods (forward and backward Euler)
agree closely with each other on the wrong solution well before
they come into line with the midpoint and Runge Kutta methods.
| |
|   | ||
hhspikes |
The model is a simple spiking cell (HHCell)
with two types of channels based loosely
on Hodgkin-Huxleykinetics.
The behavior of the cell is shown at the bottom. Only the membrane potential is shown, but the currents are also available under the Y menu. The graph with a green background shows the rms difference between the original voltage trace and the current one. It starts at zero because they are the same and each time you change a parameter another point is added showing that difference. The scale is normalized to the number of points, so in this case for example a difference of 10 means that on average the lines are 10 mV apart. A small change in frequency leads to large point-to-point differences because the spikes no longer line up so even very small parameter changes from the original ones make the error almost as large as if there were no spikes at all. The get data from calc resets the comparison data to the results of the current model, so the error for the corresponding parameters is zero.
Note that you can achieve finer control of a parameter
by clicking on the slider knob and then dragging
the mouse up or down away from the slider
before moving left and right.
| |
|   |