Numerical Solutions to the Passive Cable Equation:
Using Finite Difference Approximations to Partial Derivatives

Marcello DiStasio
SUNY Downstate Medical Center & NYU-Poly

[MATLAB code]

February 6, 2010

1 Second Order Difference Kernels

1.1 Finite Difference Approximation

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:

       f (xi+1)- f(xi)
f′(x) ≃------Δx----- + O(Δx )

and a ’center difference’ approximation to the second derivative:

f′′(x) ≃ f-(xi-1)--2f(xi)+-f(xi+1) +O (Δx2)
                 Δx2

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.

1.2 Application to Cable Equation

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

   ∂V     1 ∂2V
Cm ∂t-=  4R--∂x2-- GmV  - RmJ
           i



where Cm is the membrane capacitance; Ri is the longitudinal (internal) resistance; Gm is the membrane conductance (Gm = R1-
 m, 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

   [         ]      [               ]
    vni+1-- vni   --d- vni-1 --2vni-+vni+1      n    n
Cm     Δt     = 4Ri        Δx2        - Gmv i - Jj




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

vni+1= vni + ---dΔt--2(vni-1 - 2vni + vni+1)- ΔtGm-vin- Jni
           4RiCm Δx                     Cm



Now we let K = --dΔt---
4RiCm Δx2 and we let B = -Δx24RiGm--
    d. Then we can write vin+1as:

vn+1 = Kvn  + (1- 2K - BK )vn + Kvn
 i       i-1                i     i+1



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

 n+1    n   n
v   = Av  - j



where A is defined as

    ⌊                                                                   ⌋
       1         0            0            0        ...       0       0
    ||  K    1- K (2 + B)       K            0                            ||
    ||                                                        ..       ..  ||
A = ||  0        K        1- K (2+ B )      K                 .       .  ||
    ||  0         0            K       1 - K (2+ B )         K        0  ||
    ⌈  0         0            0            K        ...  1- K (2 + B)  K  ⌉
       0         0            0            0       ...      K        1


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.

2 Fourth Order Difference Kernels

For fourth order kernels, following the conventions above we obtain the following finite difference approximations:

f ′(x) ≃ --f(xi--3)-+-6f-(xi-2)--18f(xi--1)+-10f(xi)+-3f(xi+1)+ O(Δx4 )
                            12Δx

 ′′     - f(xi-2)+-16f(xi-1)--30f(xi)+-16f(xi+1)--f(xi+2)      4
f (x) ≃                     12Δx2                     + O (Δx  )

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 = --dΔt--
CmRiΔx2 and B = (-30 - 30K -4ΔCtmGm-) to yield the following matrix:

A = ⌊| 161K    0B    - 100K   -0 K      00     ⋅⋅⋅⋅⋅⋅                      0   ⌋|
||                                                             .  ||
||  - K  16K    B     - 10K   - K                              ..  ||
||                                         ...                     ||
||   0   - K   16K     B     - 10K                                ||
||                    16K            ...                       0   ||
||   ..                                                            ||
|⌈   .                                    16K    B   - 10K   - K  |⌉
                                    0    - K   16K    B    - 10K
    0          ⋅⋅⋅                  ⋅⋅⋅   0     0     0      1

Then we can calculate the voltage vectors at each time step (as defined above) by:

vn+1 = Avn + 54vn-1 - 18vn-2 + 3vn-3 - jn

3 Computational Issues

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.

4 Results

4.1 Comparison with results from NEURON

The following figure shows the voltage trace at the current injection site computed using the parameters:


PIC
Figure 1: Voltage at the location of current input as a function of time as computed with the algorithm delineated in this report


Running the simulation in the NEURON environment (see http://www.neuron.yale.edu/) with the same parameters yields the following voltage trace:


PIC

Figure 2: Voltage at the location of current input as a function of time as computed with the NEURON software


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.

4.2 Visualizing current spread

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.


PIC

Figure 3: Spread of potential along the cable with a uniform current input at a single location


4.3 Response to s sinusoidal current input

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.


PIC

Figure 4: Voltage response in the 10μm length cable to a current input at a single location with a sinusoidally varying amplitude


5 Discussion

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) f(xi+1)2-Δfx(xi-1) + Ox2). 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.

6 References

  1. Christof Koch. Biophysics of Computation. Information Processing in Single Neurons. 1999. Oxford University Press.
  2. http://reference.wolfram.com/mathematica/tutorial/NDSolvePDE.html#c:4
  3. Gerald W. Recktenwald. Finite-Difference Approximations to the Heat Equation. http://web.cecs.pdx.edu/~gerry/class/ME448/codes/FDheat.pdf
  4. Numerical Analysis of Partial Difference Equations. Hall and Porsching. 1990. Prentice Hall.
  5. Numerical Solution of Partial Difference Equations: Finite Difference Methods 3rd ed. G.D. Smith. 1985. Oxford University Press.
  6. NEURON for empirically-based simulations of neurons and networks of neurons. http://www.neuron.yale.edu/neuron