Difference between revisions of "NumericalDiffEqs"

From Sean_Carver
Jump to: navigation, search
(Numerical Solution of Differential Equations)
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
Today's lab is the next tutorial, the Action Potential Tutorial.
 +
 +
* '''Homework:''' Do as much of the tutorial as you can and make a PowerPoint out of three observations.
 +
 
== Equilibrium Potentials ==
 
== Equilibrium Potentials ==
 +
 +
Recall the equation for the membrane potential in the Hodgkin-Huxley model:
 +
 +
<math> C \frac{dV}{dt} = I(t) - g_L (V(t) - E_L) - g_{Na} m^3(t) h(t) (V(t) - E_{Na}) - g_K n^4(t) (V(t) - E_K) </math>
  
 
You can find the equilibrium potential for given channel conductances.  Set the injected current to zero I = 0.  Then fix and absorb the gating variables and maximal conductances <math> (g_L, g_{Na}, g_{K}) </math> into single conductance variables <math> (G_L, G_{Na}, G_{K}) </math>.
 
You can find the equilibrium potential for given channel conductances.  Set the injected current to zero I = 0.  Then fix and absorb the gating variables and maximal conductances <math> (g_L, g_{Na}, g_{K}) </math> into single conductance variables <math> (G_L, G_{Na}, G_{K}) </math>.
Line 5: Line 13:
 
For example
 
For example
  
<math> G_{K} = n^4 g_K </math>
+
<big> <big> <math> G_{K} = g_K n^4 </math> </big> </big>
  
 
Then the differential equation for the membrane is
 
Then the differential equation for the membrane is
Line 16: Line 24:
  
 
The equilibrium potential is the weighted average of the reversal potentials -- weighted by the corresponding conductances.  Note that the weights add to one.
 
The equilibrium potential is the weighted average of the reversal potentials -- weighted by the corresponding conductances.  Note that the weights add to one.
 +
 +
Now we can talk about the [[Media:Lab_F.pdf|homework due last night]].
  
 
== Numerical Solution of Differential Equations ==
 
== Numerical Solution of Differential Equations ==
Line 33: Line 43:
 
Here k is the rate constant, 1/k is the time constant, 1/k is <math> \frac{C}{g_L} = RC </math> in the notation above.  A leaky cell is what is called an RC circuit -- a resistor and capacitor together in a circuit.  The time constant of an RC circuit is RC.  The bigger k, the higher the rate of convergence, and the smaller the time constant 1/k.  The time constant is the time it takes the solution to decay to 1/e of its value.
 
Here k is the rate constant, 1/k is the time constant, 1/k is <math> \frac{C}{g_L} = RC </math> in the notation above.  A leaky cell is what is called an RC circuit -- a resistor and capacitor together in a circuit.  The time constant of an RC circuit is RC.  The bigger k, the higher the rate of convergence, and the smaller the time constant 1/k.  The time constant is the time it takes the solution to decay to 1/e of its value.
  
Solution of differential equations happens at discrete times: <math> y_k </math>, separated by small time intervals dt.
+
Solution of differential equations happens at discrete times: <big> <math> y_k </math> </big>, separated by small time intervals dt.
  
 
The simplest way of solving this equation is with Euler's method:
 
The simplest way of solving this equation is with Euler's method:
  
<big> <big> <big> <math> y_k = y_{k-1} + dt (-k y_{k-1}) </math> </big> </big> </big>
+
<big> <big> <big> <math> y_k = y_{k-1} + dt \ (-k y_{k-1}) </math> </big> </big> </big>
  
 
This is a special case of the general formula for Euler's method applied to the (vector) differential equation
 
This is a special case of the general formula for Euler's method applied to the (vector) differential equation
Line 43: Line 53:
 
<math> \frac{dy}{dt} = f(y) </math>
 
<math> \frac{dy}{dt} = f(y) </math>
  
<big> <big> <big> <math> y_k = y_{k-1} + dt f(y_{k-1}) </math> </big> </big> </big>
+
<big> <big> <big> <math> y_k = y_{k-1} + dt \ f(y_{k-1}) </math> </big> </big> </big>
   
+
 
 +
Euler's equation is the simplest way to solve a differential equation numerically.  However it is often not the preferred method: often you need to take much smaller time steps with Euler than with some other methods, so it takes longer to get as good a solution. Still if you are doing something complicated, like solving an equation with noise, or Bayesian filtering (to compute likelihood), an argument can be made that a simpler method is desirable -- at least as a first step.
 +
 
 
Click here for [[Media:intuit.hoc|code]] for visualizing the numerical solution of differential equations.
 
Click here for [[Media:intuit.hoc|code]] for visualizing the numerical solution of differential equations.

Latest revision as of 21:31, 17 February 2009

Today's lab is the next tutorial, the Action Potential Tutorial.

  • Homework: Do as much of the tutorial as you can and make a PowerPoint out of three observations.

Equilibrium Potentials

Recall the equation for the membrane potential in the Hodgkin-Huxley model:

 C \frac{dV}{dt} = I(t) - g_L (V(t) - E_L) - g_{Na} m^3(t) h(t) (V(t) - E_{Na}) - g_K n^4(t) (V(t) - E_K)

You can find the equilibrium potential for given channel conductances. Set the injected current to zero I = 0. Then fix and absorb the gating variables and maximal conductances  (g_L, g_{Na}, g_{K}) into single conductance variables  (G_L, G_{Na}, G_{K}) .

For example

 G_{K} = g_K n^4

Then the differential equation for the membrane is

 C \frac{dV}{dt} = - G_L (V - E_L) - G_{Na} (V - E_{Na}) - G_K (V - E_K)

The equilibrium potential is the value of V such that  \frac{dV}{dt} is zero. You can plug in  \frac{dV}{dt} = 0 and solve for  V_{equilibrium}.

 V_{equilibrium} = \frac{G_L E_L + G_{Na} E_{Na} + G_K E_K}{G_L + G_{Na} + G_K}

The equilibrium potential is the weighted average of the reversal potentials -- weighted by the corresponding conductances. Note that the weights add to one.

Now we can talk about the homework due last night.

Numerical Solution of Differential Equations

Remember the equation for the cell with only leak channels.

 C \frac{dV}{dt} = I(t) - g_L(V - E_L)

Let's simplify: suppose there is no injected current and that the reversal potential for the leak channels is  E_L = 0 . Then our equation is

 \frac{dV}{dt} = - \frac{g_L}{C} V

Using different letters for the variables (because this is done in the software linked below):

 \frac{dy}{dt} = - k y

Here k is the rate constant, 1/k is the time constant, 1/k is  \frac{C}{g_L} = RC in the notation above. A leaky cell is what is called an RC circuit -- a resistor and capacitor together in a circuit. The time constant of an RC circuit is RC. The bigger k, the higher the rate of convergence, and the smaller the time constant 1/k. The time constant is the time it takes the solution to decay to 1/e of its value.

Solution of differential equations happens at discrete times:  y_k , separated by small time intervals dt.

The simplest way of solving this equation is with Euler's method:

 y_k = y_{k-1} + dt \ (-k y_{k-1})

This is a special case of the general formula for Euler's method applied to the (vector) differential equation

 \frac{dy}{dt} = f(y)

 y_k = y_{k-1} + dt \ f(y_{k-1})

Euler's equation is the simplest way to solve a differential equation numerically. However it is often not the preferred method: often you need to take much smaller time steps with Euler than with some other methods, so it takes longer to get as good a solution. Still if you are doing something complicated, like solving an equation with noise, or Bayesian filtering (to compute likelihood), an argument can be made that a simpler method is desirable -- at least as a first step.

Click here for code for visualizing the numerical solution of differential equations.