+10 XP

The Euler Method

The LIF equation is continuous math. The Euler method converts it to a discrete update rule that computers can execute step by step.

The idea: instead of solving the equation analytically, we compute what happens in tiny time steps:
1. Start with current voltage V
2. Compute how much V would change in time dt
3. Add that change: V_new = V_old + change
4. Repeat for each step

V(t+dt) = V(t) + (dt/τ) × (EL − V(t) + R × I(t))

Discrete version of τm·dV/dt = EL − V + R·I. One update per ms.

In Python, one line:
v = v + (dt / tau) (el - v + r i_t)

This is an in-place update — we read the current v on the right, compute the new v, and store it on the left.

python
import numpy as np
dt=1e-3; tau=20e-3; el=-60e-3; r=100e6; i_mean=25e-11
v = el  # start at rest
Always start at resting potential el = -60 mV
print(f"Initial V = {v*1000:.1f} mV")
for step in range(5):
    t = step * dt
    i_t = i_mean * (1 + np.sin(2 * np.pi * t / 0.01))
    v = v + (dt / tau) * (el - v + r * i_t)
Euler update: the heart of every LIF simulation
    print(f"step {step+1}: V = {v*1000:.2f} mV")

Watch V rise from -60 mV as current drives it toward threshold (-50 mV).