Based on Taylor approximations, finite difference approximations to the derivatives of a function defined on a uniform grid (xi), xi = xo + h, h > 0 can be given using arbitrarily sized kernels. For second order kernels, we obtain the following ’forward difference’ approximation to the first derivative:
and a ’center difference’ approximation to the second derivative:
Note that these are not the only difference formulas that can be defined as computational molecules on the mesh; others
such as backward or centered difference or the Crank-Nicolson molecule have various computational advantages related to
ensuring stability while using differently spaced meshes.
The cable equation describes the passive spread of voltage in one dimension along a cable with an inner (’axial’) conductor
and outer (’membrane’) resistive covering. The cable equation in a second order parabolic PDE, similar in form to the heat
equation that describes the distribution of thermal energy along a uniform bar as a function of time and distance
from the origin. The voltage in a cable as a function of time t and distance along the cable x can be given
by
where Cm is the membrane capacitance; Ri is the longitudinal (internal) resistance; Gm is the membrane conductance
(Gm = , where Rm is the membrane resitance); and J is the injected current.
If we let vjn = V (xj,tn), and partition time in steps Δt and space in steps Δx, we can use the second order difference
approximations above to write the cable equation as
Rearranging terms so that the current terms at any grid step (vjn) can be expressed in terms of past values (vj-jmn-nm)
we obtain
Now we let K = and we let B = . Then we can write vin+1as:
We can write this in vector form if we take
vn = (vin) = t[..., vi-1n , vin , vi+1n , ...] and
vn+1 = (vin+1) = t[..., vi-1n+1 , vin+1 , vi+1n+1 , ...] and
jn = (Jin) = t[..., Ji-1n , Jin , Ji+1n , ...]
Then we have
where A is defined as
Thus, given a vector v0 specifying the intial condition, you can simply iterate forward in time, repeatedly applying the matrix A to the output of each previous step. Note that the top and bottom rows are set to 1 (identity) to preserve the boundary condition. In the simulations below, Dirichlet (fixed) boundary conditions are used, with the voltage fixed are resting potential (analagous to a sealed, but not killed, axon ending). A simple MATLAB function implementing this entire method is given in the file Cab7.m.
For fourth order kernels, following the conventions above we obtain the following finite difference approximations:
Note that the fourth order kernels are not symmetrical about xi, which would lead to a linear decrease in the error (but
not change its order), but the asymmetrical kernel is used to simplify the programming. Here we let K = and
B = (-30 - 30K -) to yield the following matrix:
A =
Then we can calculate the voltage vectors at each time step (as defined above) by:
The requisite density of the mesh spacing is highly sensitive to the parameters K and B, particularly for the fourth order difference method. In practice, the mesh size required to ensure a stable solution to the cable equation with realistic biological parameters using the fourth order method is too fine to allow for simulation on a standard desktop computer due to memory restrictions. Thus, to approximate higher order differences, more efficient computational algorithms such as Crank-Nicolson or Runge-Kutta should be employed.
The following figure shows the voltage trace at the current injection site computed using the parameters:
Running the simulation in the NEURON environment (see http://www.neuron.yale.edu/) with the same parameters yields the following voltage trace:
The similarity in shape (it is seen on further inspection that there are slight differences in amplitude) serves to validate the general approach outline above. However, the simulation of realistic biological parameters (similar to the default parameters given in NEURON) is computationally difficult for the reasons outlined above.
The solution to the cable equation was computed using the second order difference method with the following parameters:
A current injection of -0.01μA with a duration of 1 second was applied to the cable at a single location. The resulting voltage is shown below (Fig. 3) as a function of space and time.
Using the same parameters as section 4.2 the voltage response to the input of a sine wave current amplitude was calculated. The results are shown in Fig. 4, which uses the same conventions as the figures above.
The comparison of the numerical solution presented above with a model run in NEURON reveals that our method yields very reasonable results when run with parameters that fulfill criteria for stability. The dynamics of the voltage change in repose to current inputs match quite well. The figures also show a pattern of voltage spread that matches expectation based on experiment. Nevertheless, because differential equations are inherently functions of both the independent variables and the discrete step size in those variables (e.g. Δx), the computation of the solution using this method has some key limitations:
There are a number of other options for computing the difference approximations. One simple change that would improve the stability of the solution without changing the computational load would be to replace the forward difference approximation to the first derivative with a centered difference approximation, as in f′(x) ≃ + O(Δx2). In this case the error would only be proportional to the square of the time step (and thus would be reduced, since Δt < 1). Finally, as mentioned above, in many situations the use of more efficient and more stable algorithms (Runge-Kutta, Crank-Nicolson), which are in packages already widely available, would remedy the problems described here.