Question:

How to get the series coefficient of a function defined by a differential equation

Zoe: 26 June 2022

I need a Taylor series approximation for $x(t)$, which is defined by the following differential equation.

$\frac{dx}{dt}=-k_1 x+(1-x)k_2 e^{-k_3 t}$, $x(0)=0$

     {
     D[x[t], t] == -k1 x[t] + (1 - x[t]) k2 Exp[-k2 t]
     , x[0] == 0
     }

How do I get the coefficients $x^{''}(0)$, $x^{'''}(0)$ from Mathematica?

Answer:
Joshua: 26 June 2022

Looks like homework, but anyway. The idea is to take derivatives, substituting from lower derivatives to rewrite e.g. x'' in terms of x' (which you can already rewrite in terms of x). Below I show this for x''[0]. Similar substitutuins, keeping track of past derivative rewrites, can be used to get higher derivatives to evaluate at t=0.

xprime[t] := -k1 x[t] + (1 - x[t]) k2 Exp[-k2 t]
substrule = x'[t] -> xprime[t];
x[0] = 0;

In[203]:= D[xprime[t], t] /. substrule /. t -> 0

(* Out[203]= -k1 k2 - 2 k2^2 *)