# First Order Differential Equation -Variation of Parameters Method

I'm trying to solve arbitrary current equation for neuron membrane from Gerstner's book.

Here it begins:

Question: Assuming that before a given time t0 the current is null and the membrane potential is at rest, derive the general solution to Eq. (1) for arbitrary I(t).

My Solution: Variation of Parameters method is used to solve differential equation:

$$\tau\frac{du}{dt} = \ - (u(t) - u_{\text{rest}}) + RI(t)\quad \tag1$$ $$\tau\frac{du}{dt} +u(t) =0 \implies \tau\frac{du}{dt}=-u(t)\implies \int \frac{du}{u}=-\int\frac{dt}{\tau}$$ $$u(t)= e^{-t/{\tau}}\cdot C \implies u(t)=C(t)\cdot e^{-t/{\tau}}$$ $$u^{'}(t)=C^{'}(t)\cdot {e^{-t/{\tau}}-\frac{1}{\tau}e^{-t/\tau}}\cdot C(t)$$ Inserting into Eq. $$(1)$$: $$\tau\left(C^{'}(t)\cdot {e^{-t/{\tau}} - \frac{1}{\tau}e^{-t/\tau}}\cdot C(t)\right)= -C(t)e^{-t/\tau} +u_{\text{rest}}+RI(t)$$ $$\tau\cdot C^{'}(t)\cdot e^{-t/{\tau}} =u_{\text{rest}}+RI(t)$$ $$\int C^{'}(t)=\int \frac{1}{\tau} \left(u_{\text{rest}}+RI(t)\right)\cdot e^{t/{\tau}}dt \implies C(t)= C_{1}+ \frac{1}{\tau}\int_{t_{0}}^t (u_{\text{rest}}+RI(t))e^{t/{\tau}}dt$$

$$u(t)= e^{-t/{\tau}}\left(C_{1} +\frac{1}{\tau}\int_{t_{0}}^t (u_{\text{rest}}+RI(t))e^{t/{\tau}}dt \right)$$

In solution, it says before a given time $$t_{0}$$ the current is zero and the $$ut_{0} = u_{\text{rest}}$$. With this information I can't apply it to find $$C_{1}$$. In some resources, they say applying initial condition results that integration part of equation equals to zero. So I tried that: $$u(t)= e^{-t/{\tau}}\left(C_{1} +\frac{1}{\tau}\int_{t_{0}}^t (u_{\text{rest}}+RI(t))e^{t/{\tau}}dt \right)$$ Initial condition $$ut_{0} = u_{0}$$ $$u_{0} =e^{-t0/{\tau}}(C_{1} + \text{ (they specified integration equals to zero)) } \implies C_{1}=u_{0}\cdot e^{t0/{\tau}}$$ $$u(t)=e^{(t0-t)/{\tau}}\cdot u_{0} + \frac{e^{-t/{\tau}}}{\tau}\int_{t_{0}}^t(u_{\text{rest}}+RI(t))e^{s/{\tau}}ds$$

I couldn't proceed from that point.

Book's Solution: $$\tau\frac{du}{dt} +u(t) =0 \iff \frac{du/dt}{u}=-\frac{1}{\tau} \implies u(t)=ke^{-t/{\tau}}$$ A particular solution can be obtained by the "variation of parameters" method: we write $$u(t)=k(t)e^{-t/{\tau}}$$ and replace it in Eq. (1). $$\tau\left(\frac{dk(t)}{dt}-\frac{1}{\tau}k(t)\right)e^{-t/{\tau}} + k(t)e^{-t/{\tau}} =u_{\text{rest}}+RI(t)$$ $$\frac{dk(t)}{dt}=\frac{1}{\tau}(u_{\text{rest}}+RI(t))e^{t/{\tau}}$$ Integrating, we find $$k(t) = k_{2}+\frac{1}{\tau}\int_{t_{0}}^t (u_{\text{rest}}+RI(s))e^{s/{\tau}}ds$$ where k2 is a new integration constant. Denoting the initial condition by $$u_{0} = u_{to}$$, we obtain: $$u(t) = u_{\text{rest}} + (u_{0}-u_{\text{rest}})\cdot e^{-(t-t0)/{\tau}} +\frac{1}{\tau}\int_{t_{0}}^t RI(s)e^{-(t-s)/{\tau}}ds$$ Using the particular initial condition $$u(t_{0}) = u_{\text{rest}}$$, the equation simplifies to: $$\bbox[yellow]{ u(t) = u_{\text{rest}} + \frac{1}{\tau}\int_{t_{0}}^t RI(s)e^{-(t-s)/{\tau}}ds \implies \text{The real solution}}$$

As you can realize, my solution is wrong. How can I achieve the correct solution. Also some sources say, these equations can be solved by laplas and convolution methods. I searched this, but this method is used solve second degree diff equations. If someone wish to solve by laplas, I will be appreciated. Pls try to help me, I am very desperate right now. Best regards.

• Welcome to Math Stackexchange! Your formatting is pretty good, but you did not specify what $RI(t)$ is. For Variation of Parameters this is an important information. Apr 29, 2022 at 8:58
• Thank you very much, R is resistant and I(t) is current which are simple components of a R/C circuit used to modelling of a neuron cell. The basic electrical circuit representing a cell model consists of a capacitor C in parallel with a resistor R driven by a current I(t). A neuron, which is enclosed by the cell membrane, receives a positive input current I(t) which increases the electrical charge inside the cell. The cell membrane acts like a capacitor in parallel with a resistor which is in line with a battery of potential Urest Apr 29, 2022 at 9:43
• R and I(t) are are in multiplication state in the equation. Apr 29, 2022 at 9:49
• Thank you sir, but R is in the integration at the solution manual, not especially in my approach. They keeped it in the integration. I wanted to emphasize it. Best regards Apr 29, 2022 at 13:42
• I meant not to bother you with too much info. But it is allready free to use. neuronaldynamics.epfl.ch/online/Ch1.S3.html May 5, 2022 at 15:14

$$\require{cancel}$$

Let $$x(t)=u_{rest}+RI(t)$$

Thus the inhomogeneous general solution of your ode is

$$u=C\cdot e^{-\frac{t}{\tau}}+\frac{1}{\tau}\cdot\int_{t_0}^tx(\sigma)e^{\frac{\sigma-t}{\tau}}d\sigma$$

$$u=C\cdot e^{-\frac{t}{\tau}}+\frac{1}{\tau}\cdot\int_{t_0}^t\left[u_{rest}+RI(\sigma)\right]e^{\frac{\sigma-t}{\tau}}d\sigma$$

where $$C$$ is an arbitrary positive real and we introduce $$\sigma$$ as a dummy variable as we can't have $$t$$ both as the variable of integration and the upper(or lower) limit of it.
After this, the initial value can be calculated. The integral where you got stuck can be found at the end of my post, it seems the Laplace-transform method leads to the same form of 'problem'.

I feel like a big part of your confusion stems from either the book being too vague or you not being strict enough with your letters and constants and syntactically getting lost.

The Laplace-transform method is very similar to this one, but it allows us to calculate initial value problems to constant-coeff. linear odes much faster, than Variation of Parameters(which gets you general solutions).

Basically we say that the Laplace-transform of a function allows us to linearly work originally different things. (like a function and its derivative)

The Laplace transform of a function $$f(t)$$ is

$$\mathcal{L}\{f(t)\}=F(s)=\int_{0}^\infty f(t)\cdot e^{-st}dt$$

So the function i plug in in $$t$$ variables, comes out as a different function in $$s$$ variables. Of course we need to transform it back(take the inverse Laplace-transform) if we want it to be in $$t$$ again.

(Please make note that the solution in your exercise containing $$s$$ is a pure coincidence and has to do nothing with the Laplace-transform's variable.)

The Laplace-transform takes a real function usually understood as something that changes over time ($$t$$) and changes it into a complex-valued frequency function.

The integration bounds mirror the sort of problems we try to solve, it starts from now ($$0$$) and goes until infinity as transient phenomenon last until forever, in theory at least.

Let's calculate a simple one. Let our function $$f(t)=1$$

$$\mathcal{L}\{1\}=\int_0^\infty 1\cdot e^{-st}dt=\int_0^\infty e^{-st}dt= \lim_{r\to\infty}\int_0^r e^{-st}dt=\left[-\frac{1}{s}e^{-st}\right]_0^r=\lim_{r\to\infty}\left[ \left(-\frac{1}{s}e^{-s\cdot r}\right)-\left(-\frac{1}{s}e^{-s\cdot0}\right)\right]=$$

$$=\lim_{r\to\infty}\left[ -\frac{1}{s}e^{-s\cdot r}+\frac{1}{s}\right]=$$

$$=\left[-\frac{1}{s}\cancelto{0}{e^{-\infty}}+\frac{1}{s}\right]=\frac{1}{s}$$

Let $$f(t)=e^{at}$$ where $$a$$ is a real number.

$$\mathcal{L}\{e^{at}\}=\int_0^\infty e^{at}\cdot e^{-st}dt=\int_0^\infty e^{t(a-s)}dt=\lim_{r\to\infty}\left[\frac{e^{t(a-s)}}{a-s}\right]_0^r=\lim_{r\to\infty}\left(\frac{e^{r(a-s)}}{a-s}\right)-\frac{e^{0(a-s)}}{a-s}\stackrel{\text{as long as }a

More complicated functions such as $$t^n$$ or $$sin(t)$$ can be calculated in a similar fashion.

Let's find $$\mathcal{L}\{f'(t)\}$$ now. By definition

$$\int_0^\infty f'(t)e^{-st}dt=$$

Integrating by parts

$$=\left[f(t)\cdot e^{-st}\right]_0^\infty-\int_0^\infty f(t)\cdot -s \cdot e^{-st}dt$$

Doesn't the second part look familiar? It's literally the Laplace-transform of $$f(t)$$ and multiplied by constant $$-s$$, the $$s$$ variable is constant with respect to the integration variable $$t$$.

Evaluating at $$0$$ and $$\infty$$

$$\lim_{r\to\infty}\left[f(r)\cdot e^{-s\cdot r}\right]-\left[f(0)\cdot e^{-s\cdot0}\right] +s\cdot\mathcal{L}\{f(t)\}=$$

Plugging in $$\infty$$ into the limit results in a $$\frac{\infty}{\infty}$$ problem, especially that we don't know what $$f(t)$$ does at $$\infty$$. Lucky for us the Laplace-transform can't deal with super 'steep' functions in the first place. As long as $$f(t)$$ is in the class of functions of polynomials, trigonometric functions and constant coefficient exponentials, our handy transform can dampen it enough (pun intended) for it to be integrable. (For example $$e^{x^2}$$ is so steep, it doesn't have a Laplace-transform)

So we can say that $$f(\infty)\cdot e^{-\infty}$$ tends to zero. Thus

$$\mathcal{L}\{f'(t)\}=s\mathcal{L\{f(t)\}}-f(0)$$

And we are really fond of this thing, because it allows us to compare different orders of derivates and also gives us an explicit starting value $$f(0)$$

Laplace-transforms of higher order derivates can be 'crafted' in a similar fashion for higher order constant-coefficient linear ode.

Let's transform your equation, shall we?

$$\tau\frac{du(t)}{dt}+u(t)=x(t)$$

$$\mathcal{L}\left\{\tau\frac{du(t)}{dt}+u(t)=x(t)\right\}$$

By the linearity of the Laplace transform:

$$\tau\mathcal{L}\left\{\frac{du(t)}{dt}\right\}+\mathcal{L}\{u(t)\}=\mathcal{L}\{x(t)\}$$

$$\tau(sU(s)-u(0))+U(s)=X(s)$$ Warning: We do not know $$X(s)$$, we don't explicitly know $$x(t)$$ so we can't express its Laplace-transform in any more direct way.

Solving for $$U(s)$$

$$U(s)=\frac{X(s)+\tau u(0)}{\tau s+1}$$

Now to get back our $$u(t)$$ we take the inverse Laplace-transform of this expression:

$$\mathcal{L}^{-1}\{U(s)\}=u(t)=\color{purple}{ \mathcal{L}^{-1}\left\{\frac{X(s)}{\tau s+1}\right\}} +\color{green}{\mathcal{L}^{-1}\left\{\frac{\tau u(0)}{\tau s+1}\right\}}$$

$$\color{green}{\mathcal{L}^{-1}\left\{\frac{\tau u(0)}{\tau s+1}\right\}=u(0)\cdot\mathcal{L}^{-1}\left\{\frac{1}{ s+\frac{1}{\tau}}\right\}=u(0)\cdot e^{-\frac{t}{\tau}}}$$

$$\color{purple}{\mathcal{L}^{-1}\left\{\frac{X(s)}{\tau s+1}\right\}= \frac{1}{\tau}\cdot\mathcal{L}^{-1}\left\{\frac{X(s)}{s+\frac{1}{\tau}}\right\}}$$

By the convolution rule (for L-t.):

$$F(s)\cdot G(s)\Rightarrow f(t)*g(t)=\int_0^t f(\theta)\cdot g(\theta-t)d\theta$$

Thus

$$\mathcal{L}^{-1}\{X(s)\}=x(t)\qquad\mathcal{L}^{-1}\left\{\frac{1}{s+\frac{1}{\tau}}\right\}=e^{-\frac{t}{\tau}}$$

$$\color{purple}{ \frac{1}{\tau}\cdot\mathcal{L}^{-1} \left\{ \frac{X(s)}{s+\frac{1}{\tau}}\right\}=\frac{1}{\tau}\int_0^t x(\theta)\cdot e^{\frac{\theta-t}{\tau} }d\theta=\frac{1}{\tau}\int_0^t (u_{rest}+RI(\theta))\cdot e^{\frac{\theta-t}{\tau} }d\theta=}$$

$$\color{purple}{ \frac{1}{\tau}\int_0^t (u_{rest}+RI(\theta))\cdot e^{\frac{\theta-t}{\tau}}d\theta= \frac{1}{\tau}\left( \int_0^t u_{rest}\cdot e^{\frac{\theta-t}{\tau}}d\theta +\int_0^t RI(\theta)\cdot e^{\frac{\theta-t}{\tau}}d\theta\right)=}$$

$$\color{purple}{ \frac{1}{\tau} \left(\tau\cdot u_{rest}\cdot e^{\frac{t-t}{\tau}} +\int_0^t RI(\theta)\cdot e^{\frac{\theta-t}{\tau}}d\theta\right)=}$$

$$\color{purple}{ \mathcal{L}^{-1}\left\{ \frac{X(s)}{\tau s+1}\right\}= u_{rest} +\frac{1}{\tau}\int_0^t RI(\theta)\cdot e^{\frac{\theta-t}{\tau}}d\theta}$$

$$u(t)=\color{green}{u(0)\cdot e^{-\frac{t}{\tau}}}+\color{purple}{u_{rest}+\frac{1}{\tau}\int_0^t RI(\theta)\cdot e^{\frac{\theta-t}{\tau}}d\theta}$$

This is the first time I've done convolution so there might be some mistakes.
If we assume $$u(t_0)=u(0)=0$$ (eg. the currect is zero at the start) then

$$u(t)=\color{purple}{u_{rest}+\frac{1}{\tau}\int_0^t RI(\theta)\cdot e^{\frac{\theta-t}{\tau}}d\theta}$$

• Thank you so much. Actually I was wondering the Laplace solution more than the VOP method. So I will study it, comment it later. But again thank you for your kindness. Best regards. May 5, 2022 at 13:29
• You are welcome! If you feel like I helped you, please mark it as an answer. And don't fret about not understanding it or being overwhelmed. It took me half a year to get used to Laplace-transforms and I'm still learning. :) May 5, 2022 at 15:02
• I used Paul's Online Notes to study Laplace method. But it gives superficial examination and is not for engineering problems. Can you recommend me some resources which might be book, online sites or others. Thanks. May 7, 2022 at 20:38
• Could you expand on what kind of exercises you are looking for? As far as I know the Laplace method isn't more special than any other, as long as you were able to set up the ODE, it is linear and const.-coeff. you can just apply this method, sometimes it is faster than others. There are many great books, I'm sure, but i didn't learn from one, so I cannot recommend you any. May 8, 2022 at 5:29
• Actually I wish to understand the equations in the book which I shared before neuronaldynamics.epfl.ch/online/Ch1.S3.html Someone in reddit suggested me to learn laplace transform for these ODEs. So I tried to learn Laplace from Paul's online notes. I am not an expert mathematician, in fact I studied ODEs from the Paul's website and some chapters of Elementary Differential Equations with Boundary Value Problems William F. Trench. Book. Someone who studied this book gave advice to me that If I learnt Laplace transform it would be enough for all. May 8, 2022 at 19:46

Modified solution with variation of parameters method. From the Laurent Demanet's video, I made some changes. After finding $$C_{1}=U_{0}\cdot e^{t0/{\tau}}$$ and inserting it to equation, method tells us that t in integration and exponential value differs from each other. Because at this point t in exponential is named as free variable, and t in integration is named as integration variable. So we must change it to different variable, I used $$s$$ as from the book.
(Note that, I am not an expert mathematician, I'm studying Laplace and other methods to understand concepts behind the neuron models.)

Rearranging the eqution, we have:

$$u(t) = e^{-t/{\tau}}\left(u_{0}e^{t_{0}/{\tau}}+ \frac{1}{\tau}\int_{t_{0}}^t\left(u_{\text{rest}}+RI(s)\right).e^{s/{\tau}}ds \right)$$ $$u(t) = e^{-t/{\tau}}\left(u_{0}e^{t_{0}/{\tau}}+ \frac{1}{\tau}\int_{t_{0}}^t u_{\text{rest}}.e^{s/{\tau}}ds + \frac{1}{\tau}\int_{t_{0}}^t RI(s)e^{s/{\tau}}ds \right)$$ $$u(t) = e^{-t/{\tau}}\left(u_{0}e^{t_{0}/{\tau}}+u_{\text{rest}}e^{t/{\tau}}.(1-e^{t_{0}-t/{\tau}})+\frac{1}{\tau}\int_{t_{0}}^tRI(s).e^{s/{\tau}}ds \right)$$ $$u(t) = u_{0}.e^{t_{0}-t/{\tau}}+u_{\text{rest}}-u_{\text{rest}}.e^{t_{0}-t/{\tau}}+\frac{e^{-t/{\tau}}}{\tau}\int_{t_{0}}^tRI(s).e^{s/{\tau}}ds$$

Using particular initial condition $$u(t_{0})=u_{\text{rest}};$$ $$u(t) =\underbrace{(u_{0}-u_{\text{rest}})}_{0}e^{t_{0}-t/{\tau}}+u_{\text{rest}}+\frac{1}{\tau}\int_{t_{0}}^tRI(s).e^{s-t/{\tau}}ds$$ $$u(t) = u_{\text{rest}} + \frac{1}{\tau}\int_{t_{0}}^t RI(s)e^{-(t-s)/{\tau}}ds$$