Is there a closed form solution for this differential equation? I was trying to solve the following ODE, but I cannot find an easy way anywhere. I also tried using Mathematica, but it also does not provide me with a solution.
$\frac{dx}{dt}=-k_1 x+(1-x)k_2 e^{-k_3 t}$, $x(0)=0$
However on simulating I find a smooth curve increasing till a threshold time and later on, decreasing.
Can someone help me solve this ODE?
 A: After moving the terms involving $x$ to the left side, you see a first order linear differential equation with nonconstant coefficients. The general procedure for solving such an equation is the method of integrating factors. Since we have
$$\frac{dx}{dt} + \left ( k_1 + k_2 e^{-k_3 t} \right ) x = k_2 e^{-k_3 t},$$
the integrating factor is $\exp \left ( k_1 t - \frac{k_2}{k_3} e^{-k_3 t} \right )$. In other words we have
$$\frac{d}{dt} \left ( x(t) \exp \left ( k_1 t - \frac{k_2}{k_3} e^{-k_3 t} \right ) \right ) = k_2 e^{-k_3 t} \exp \left ( k_1 t - \frac{k_2}{k_3} e^{-k_3 t} \right )$$
Now integrate both sides with respect to $t$ and divide through by the integrating factor. Note that the integral on the right side is not elementary.
This problem is a bit easier to study if you first nondimensionalize. Let $x=x_C y$ and $t=t_C s$, then the equation is
$$\frac{dy}{ds} = -k_1 t_C y + \frac{k_2 t_C e^{-k_3 t_C s}}{x_C} - y k_2 t_C e^{-k_3 t_C s}$$
Let $t_C = 1/k_3$ and $x_C = \frac{k_2}{k_3}$:
$$\frac{dy}{ds} = -\frac{k_1}{k_3} y + e^{-s} - \frac{k_2}{k_3} y e^{-s}$$
So we have reduced the problem to
$$\frac{dy}{ds} = c_1 y + c_2 y e^{-s} + e^{-s}$$
where $c_1,c_2 < 0$.
A: $$
\dfrac{dx}{dt} = -\left(k_1 + k_2\mathrm{e}^{-k_3 t}\right)x  + k_2\mathrm{e}^{-k_3t}
$$
$$
x(t)\mathrm{e}^{I} = \int k_2\mathrm{e}^{-k_2t}\mathrm{e}^{I}dt + \lambda \tag{1}
$$
where
$$
I = \int \left(k_1 + k_2\mathrm{e}^{-k_3 t}\right)dt = k_1 t -\dfrac{k_2}{k_3}\mathrm{e}^{-k_3 t}
$$
so the RHS of Eq.(1) becomes
$$
\begin{align}
\int k_2\mathrm{e}^{-k_2t}\mathrm{e}^{I}dt  &=& \int k_2\mathrm{e}^{-k_2t}\mathrm{e}^{k_1t}\mathrm{e}^{-\dfrac{k_2}{k_3}\mathrm{e}^{-k_3 t}}dt\\
&=&\int k_2\mathrm{e}^{-(k_2-k_1)t}\mathrm{e}^{-\dfrac{k_2}{k_3}\mathrm{e}^{-k_3 t}}dt
\end{align}
$$
let $k_3t = -\ln u$
we find
$$
\int k_2\mathrm{e}^{(k_2-k_1)\dfrac{\ln u}{k_3}}\mathrm{e}^{-\dfrac{k_2}{k_3}u}\dfrac{-1}{k_3}\dfrac{1}{u}du=\\
-\int \dfrac{k_2}{k_3}\dfrac{1}{u}u^{\dfrac{k_2-k_1}{k_3}}\mathrm{e}^{-\dfrac{k_2}{k_3}u}du=\\
-\dfrac{k_2}{k_3}\int u^{\dfrac{k_2-k_1-k_3}{k_3}}\mathrm{e}^{-\dfrac{k_2}{k_3}u}du
$$
the last integral is
$$
-\dfrac{k_2}{k_3}\int u^{\alpha}\mathrm{e}^{\beta u}du = \dfrac{k_2}{k_3}u^{\alpha + 1}\mathrm{E}_{-\alpha}(-\beta u)
$$
or finally
$$
x(t) = \dfrac{\lambda + \dfrac{k_2}{k_3}\mathrm{e}^{-k_3\left(\alpha + 1\right)t}\mathrm{E}_{-\alpha}(-\dfrac{k_2}{k_3}\mathrm{e}^{-k_3t})}{k_1 t -\dfrac{k_2}{k_3}\mathrm{e}^{-k_3 t}}
$$
Due to the exponential integral in the final answer, means that this is not really a solution in elementary terms but at least you can work with the properties maybe.
A: Related techniques: (I). Here is an approach to find an approximate solution using power series techniques. We start by assuming our solution to have the form

$$ x(t) = x(0) + \frac{x'(0)}{1!}\,t+ \frac{x''(0)}{2!}t^2+ \frac{x'''(0)}{3!}t^3+\dots\,. $$ 

As you see we need to find $\left\{ x(0),x'(0), x''(0),\dots\,\right\} $. $x(0)$ stands for your initial condition and it is given $x(0)=0$. For $x'(0)$ and higher derivatives of $x(t)$ we can use use the given ode 

$$ x'(t) = -k_1 x(t)+(1-x(t))k_2 e^{-k_3 t} \longrightarrow (*)$$

to find them as

$$ x'(0) =  k_2 .  $$
$$ x''(t) = \frac{d}{dt}x'(t)\Big|_{t=0} =-( k_{{1}}k_{{2}}+{k_{{2}}}^{2}+k_{{2}}k_{{3}}).  $$

Now an approximate solution by a polynomial of degree $2$ 

$$x(t) \approx k_2\,e^{-k_3}\,t -( k_{{1}}k_{{2}}+{k_{{2}}}^{2}+k_{{2}}k_{{3}})\frac{t^2}{2!} .$$

Note that you can get higher degree polynomials to approximate your solution by deriving higher derivatives.
