### Time Derivative

Posted:

**Thu Sep 08, 2011 9:52 am**Dear all,

I am using this part in a hoc file in order to calculate the stim_amp(see code). However, the equation used for stim_amp is the derivative calculated by hand which creates inaccuracy in my results. I want to replace this part and make neuron calculate the derivative given the equation. By this I mean that I want to give neuron for example the equation: I(t)=v*c*exp(-w1*t)*sinh(w*t) and it will calculate the dI/dt.

Is this possible? And should it be done in a hoc or a mod file?

Thank you so much in advance for your answer!

I am using this part in a hoc file in order to calculate the stim_amp(see code). However, the equation used for stim_amp is the derivative calculated by hand which creates inaccuracy in my results. I want to replace this part and make neuron calculate the derivative given the equation. By this I mean that I want to give neuron for example the equation: I(t)=v*c*exp(-w1*t)*sinh(w*t) and it will calculate the dI/dt.

Is this possible? And should it be done in a hoc or a mod file?

Thank you so much in advance for your answer!

Code: Select all

```
for i=0,int(tstop/dt){
stim_time.x[i]=i*dt
if(i>pstart && i<pstop) {
if((RC/(2*LC))^2>1/(LC*CC)){
//Overdamped
W1=RC/(2*LC) //1/sec
W2=sqrt((W1*W1)-(1/(LC*CC))) //1/sec
scale1=amp*CC*W2*((W1/W2)^2-1)/2 // [Ampere]
exp1=exp(-W1*(stim_time.x[i]-$1)/1000) // divide by 1000 to keep units in exp in sec
exp2=exp( W2*(stim_time.x[i]-$1)/1000)
exp3=exp(-W2*(stim_time.x[i]-$1)/1000)
stim_amp.x[i]=(scale1*exp1*((W2-W1)*exp2+(W2+W1)*exp3))/1000 // dI/dt in [A/millisec]
}
}
testg.line(i*dt,stim_amp.x[i])
}
```