An algorithm for computing the equations of a compartmental neuron model for a general tree structure:

- For each cylinder i with radius and length a_i and L_i in micrometers, let the surface area,
A_i = 2 \pi a_i L_iand the axial resistance,Q_i = L_i / (\pi a_i^2)
- Given specific membrane capacitance and resistance c_i and r_{m_i}, respectively, the compartmental capacitance is
C_i = c_i A_i 10^{-8}and the compartmental resistance isR_i = (r_{m_i} / A_i) 10^8
- Given longitudinal (intracellular) resistivity r_l, the coupling resistance between compartments i and j is
R_{ij} = 0.5 r_l (Q_i + Q_j) 10^4
- The membrane potential equation for compartment i is then
C_i \frac{dV_i}{dt} = -\frac{V_i}{R_i} + \sum_{j,i} \frac{(V_j - V_i)}{R_{ij}} + I_i A_i {10^{-2}}

The factors of 10^-8, 10^8 and 10^4 are conversion factors from micrometers to centimeters.