# If condition in differential equation

I need to plot the Integrate the Fire model of neuron. The differential equation is $$\frac{dV}{dt} + \frac{V}{\tau} = \frac{I}{C}$$. The initial condition is $$V(0) = 0$$. And there is this condition if whenever $$V(t) = \theta$$ then $$V(t+h) = 0$$ where h->0. If you leave the condition then I know how to solve the equation using NDSolve but I don't know how to use that condition and sove the equation. Sample Values $$I = 60 × 10^{-9}, R = 10^9,C = 10^{-11}, \theta=5$$.

Edit1 - Code for NDSolve using WhenEvent[]  NDSolve[{V'[t]+ V[t]/0.01 == 6000,V[0]==0,WhenEvent[V[t]==50,V[t]->0]},V[t],{t,0,10}].

Code for DSolve using WhenEvent-> DSolve[{V'[t]+ V[t]/0.01 == 6000,V[0]==0,WhenEvent[V[t]==50,V[t]->0]},V[t],{t,0,0.1}]. Here you need to specify the range also.

Thanks everyone who helped.

• Look up WhenEvent[]. Feb 16, 2021 at 6:19
• @J.M. Thanks, it worked for the NDSolve. I want to ask can something similar to WhenEvent be done for DSolve also.
– A Q
Feb 16, 2021 at 6:36
• it worked for the NDSolve Why then not post the code you used? This will make it easier to use it as starting point. WhenEvent is supposed to work for DSolve also. There is example here mathematica.stackexchange.com/questions/165405/… Feb 16, 2021 at 6:59
• @Nasser Actually, you need to specify the range for independent variable in the DSolve when using with WhenEvent. I missed the range, as I had never put range in DSolve till now. Thanks for the help.
– A Q
Feb 16, 2021 at 7:11