I am aiming for the form of derivative below computed over time that causes its differentiated variable V to go from an initial -.001 and increase to reach 10. I will explain my current calcs below and please help me understand the correct approach.
The derivative is
[1] d(V)/d(t) = (-V(t) + W)/Z
Where: V = current in volts. t = time, W = weight, Z = time constant
The integral of the above equation is
[2] (-V[t]^2)/(2*Z) + (W*V[t])/Z
In this equation taking the integral cancels out the derivative according to the fundamental theorem of calculus and produces an equation with no derivative or integral.
It is my understanding that at each computational time step (for each t) V should approximately be able to be found by either [3] or [4] below when Deriv = [1] and Form = [2].
[3] V(t+1) = Form(t) + Deriv(t + 1)
[4] V(t+1) = Form(t+1)
Lets say for example where: Initial V = -0.001, W = 10, and Z = 0.02
With [3]: V reaches 10 and stops growing because the derivative becomes 0
With [4]: V continues growth until it reaches approximately 0 and stops growing.
Why do [3] and [4] produce different results? It would help me computationally to not have to compute the derivative for each time step and just use a formula with the derivative cancelled out like [4], how mathematically can I achieve my goal of V reaching 10 that way, what equation should I use? By the way this is to simulate neuron activity.
Good question, and thanks for giving detailed explanations of what you have done. It helps people understand. I can guess your intention from your user name :-).
Anyway, the question you have is one about integration of differential equations. Let me retypeset your equations: $$\frac{dV}{dt}=\frac{-V(t)+W}{Z}$$ Convert to the basic 1st-order ODE form: $$V'+\frac{V}{Z}=\frac{W}{Z}$$ Assuming that your weight $W$ and time-constant $Z$ are constants, the equation is 1 first order, linear, constant-coefficient, ODE. Thus, the solution can be done by solving the characteristic equation (incidentally, this is true for all linear, constant-coefficient ODE's, 2nd order and beyond). $$ V'+\frac{1}{Z}*V = \frac{W}{Z}$$ LET: $V_h(t)=C_1*e^{\lambda t}$ be your assumed solution. Thus solve the homogeneous solution part first: $$\lambda*C_1*e^{\lambda t}+\frac{1}{Z}*C_1*e^{\lambda t}=0=C_1*e^{\lambda t}\left(\lambda+\frac{1}{Z}\right)=0$$ Cancel exponential and solve for $\lambda$, your growth constant. $$\lambda=-\frac{1}{Z} \rightarrow V(t)=e^{-\frac{t}{Z}}$$ Now that we have the homogeneous solution, build the rest of the particular solution: LET: $V_p=A \rightarrow V_P'=0$ $$V_p'+\frac{1}{Z}V_p=0+\frac{A}{Z}=\frac{W}{Z} \leftrightarrow A=W$$ Thus, the full solution is: $$V(t)=V_h(t)+V_p(t)=C_1*e^{-\frac{t}{Z}}+W$$ Now we need to apply initial conditions to the full solution: $$V(0)=C_1*e^{-\frac{0}{0.02}}+10=-0.001 \leftrightarrow C_1=-10.001$$
The true solution is: $$V(t)=-10.001*e^{-\frac{t}{0.02}}+10$$
This equation you can use directly, or else you can integrate it numerically. the key piece you are missing is that: $\Delta y \approx y'*\Delta t$. The $\Delta t$ is what you are missing. Here are some plots (coming in a few minutes) of what the system looks like when integrated numerically, versus using the above closed-form solution.
Here is the solution when done using the analytical (blue) versus the numerical integration (green). I have used 200 time-steps. If you use more, the curves get even closer. Under about 50 time-steps, the integration is no longer stable.
In the spirit of Creative Commons, here is the source code required to generate the plot using pythonxy.