INTRODUCTIONTO THEORETICAL NEUROSCIENCE,SPRING 2015

Homework 5 Love in the time of Hodgkin-Huxley

Due 2pm, March 5, 2015

Romeo & : A (dynamical systems) love story

In this problem we will study a model of the star-crossed lovers—in an alternate, less fatal uni- verse. Our simple model, due to the mathematician Steven H. Strogatz, has two variables whose behavior we would like to determine as a function of time:

R(t) ’s feelings toward Juliet at time t, = J(t) Juliet’s feelings toward Romeo at time t. = When R(t) 0, Romeo loves Juliet; when R(t) 0, Romeo hates Juliet; and when R(t) 0, Romeo > < = is indifferent to Juliet. J(t) similarly represents Juliet’s feelings toward Romeo.

1. What system of differential equations for R(t) and J(t) describes the situation in which ’s feelings toward each other remain constant over time? (“O, swear not by the moon, the inconstant moon.”)

2. What system of differential equations for R(t) and J(t) describes the situation in which Romeo’s love for Juliet is constantly increasing while Juliet’s love for Romeo is constantly decreasing?

3. Suppose now that Romeo loves Juliet, but unfortunately Juliet is a fickle lover: the more Romeo loves her, the more Juliet wants to run away and hide. But when Romeo gets dis- couraged and backs off, Juliet begins to find him strangely attractive. Romeo, on the other

1 hand, tends to echo Juliet’s feelings: he warms up when Juliet loves him, and grows cold when Juliet hates him.

a) What is a simple system of differential equations for R(t) and J(t) that describes the above situation, and what is the fixed point of this system, i.e., at what value of J and R do their values not change in time? What interpretation does this point have?

b) Write a program that uses Euler’s method with ∆t 0.0001 to simulate the system from = part (a) for about T 10 (our time units are arbitrary here). Start with the initial condi- = tions R(0) 0, J(0) J , using J 1,2,3. Create a plot showing R(t) and J(t) for J 1, = = 0 0 = 0 = then produce a plot showing R vs. J for all three starting conditions as representative trajectories in the R-J plane (that’s R(t) on the x-axis and J(t) on the y-axis). What do the solutions tell you about Romeo and Juliet’s fate as a couple? In this type of situation the fixed point at the origin is called a center. Hint: This is the first time we’ve had to simulate two variables simultaneously, but the idea is the same as before. There are now two righthand sides, so we need a function that returns both: def f(R,J): dRdt=J dJdt=-R

return dRdt, dJdt

Similarly, the loop that solves the differential equation now looks like (assuming the arrays R and J have been initialized as before) R[0] = 0 J[0] = J0 fori in xrange(1, len(t)): dRdt, dJdt=f(R[i-1],J[i-1])

R[i] =R[i-1] + dRdt*dt J[i] =J[i-1] + dJdt*dt

As in the previous homework, since you have to solve the system for several values of J0, it is best to wrap the whole thing in a function that takes J0 as an argument. You already know how to plot R(t) and J(t) as functions of time (include a legend!), and it is no different plotting R(t) vs. J(t). However, since time is not shown in these plots it is difficult to know in what direction things are moving. So it’s nice to include a little arrow, and one trick for doing so is u=0 plt.arrow(R[u],J[u],R[u+1]-R[u],J[u+1]-J[u], head_width=0.2, head_length=0.25, fc=’black’, ec=’black’)

Here u indicates where along the plot you would like put the arrow, and is set to the beginning (in the simplified Hodgkin-Huxley model later you may want to set this to

2 something like u = len(t)//4). Unfortunately, specifying the size of the arrow is a bit unintuitive and you will have to play with head_width and head_length for each graph to make the arrowhead look nice. Meanwhile, fc and ec are face color and edge color, respectively, and should of course be changed to match the color of your lines.

4. Cautious lovers. A more general model of Romeo and Juliet should of course include the effects of their own feelings: dR aR bJ, dt = + d J cR d J. dt = + For instance, a 0, b 0 describes the case where Romeo is an “eager beaver”: he gets ex- > > cited by Juliet’s love for him, and is further spurred on by his own affectionate feelings for her. Here we will focus on what is probably closer to modern practice: a 0, b 0, or the “cau- < > tious lover.” Can two identically cautious lovers get together? That is, what happens when Romeo and Juliet’s relationship is governed by the following system of equations? dR R bJ, = − + dt (1) d J bR J. dt = − The negative term represents cautiousness (each person tries to avoid throwing themselves at the other) and b is a measure of responsiveness (they both get excited by the other’s ad- vances). a) What is the fixed point of the system in Eq. (1)?

b) Write a program that uses Euler’s method to solve for the case where b 1/2, using var- = ious initial conditions R(0) R , J(0) J (be sure to cover all quadrants, say -3, -2, -1, = 0 = 0 1, 2, 3 for each). This will require a double for-loop. Include a figure with representa- tive trajectories in the R-J plane. What interpretation can you give for the result? What property does the point R J 0 have? In this type of situation the fixed point is called = = a stable node.

c) Write a program that uses Euler’s method to solve for the case where b 10, using vari- = ous initial conditions R(0) R , J(0) J (again, be sure to cover all quadrants). Include = 0 = 0 a figure with representative trajectories in the R-J plane. What interpretation can you give for the result? In this type of situation the fixed point at the origin is called a saddle point. Hint: In this problem some of the solutions grow without bound very quickly, so you’ll have to be careful with the total integration time. For each initial condition, start with

3 something small, say T 0.05, then increase the range for different starting points until = you get a reasonably full picture of the trajectory.

A simplified Hodgkin-Huxley model

5. In this problem we consider the following, “simplified” form of the Hodgkin-Huxley equa- tions:

dV 2 1 τV (a bV cV )(V ENa) eR(V EK) Iext, dt = − + + − − − + g (2) dR τR R pV q. dt = − + + Here V (t) is the membrane potential and the dimensionless R(t) represents a recovery vari- able that combines the effects of the closing of Na+channels and opening of K+channels. Note that R does not stand for resistance. The two-dimensional equations above are less complicated than they appear at first sight. First, because there are two variables, there are two time constants, τ 4 ms and τ 5 ms. V = R = E 65 mV and E 85 mV are the reversal potentials for Na+and K+, respectively. We set Na = K = − the conductance to g 1 nS; thus currents are now in pA to keep the membrane potential in = mV. The remaining constants are

a 17.8, = 1 b 0.48 (mV)− , = 2 c 0.0032 (mV)− , = e 26, = 1 p 0.014 (mV)− , = q 1. = a) Use Euler’s method with a time step of ∆t 0.02 ms to simulate the system in Eq. (2) = with I 50 pA for 50 ms. Plot both V (t) and R(t); because the two variables have ext = very different scales, you will need to plot them separately, or look up how to use two different axes (i.e., left and right axes) in the same plot. How is the trajectory of R(t) related to that of V (t)? What is the firing rate of the neuron during this time? Hint: In this model the spikes are generated “organically,” so there is no need for any manual resets of the membrane potential. As a result, however, the old way of detecting spikes will not quite work, because the spikes have finite width. You will instead want to use something like the following:

4 ifV[i-1] < Vth andV[i] >= Vth: spiketimes.append(t[i]) b) Plot the solution from part (a) in the phase plane with V (t) on the x-axis and R(t) on the y-axis. What can you say about what the system is doing? This behavior is called a limit cycle, and is the nonlinear analogue of the circular (and unrealistic, in biological systems) orbits we saw for Romeo and Juliet. c) Plot the f -I curve for currents from 0 to 200 pA, in 5 pA intervals. For this part make sure you simulate the neuron for a long enough time, especially for low currents.

5