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.
$\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<s}{=}\frac{e^{-\infty}}{a-s}-\frac{1}{a-s}=\frac{1}{s-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}$$