2
$\begingroup$

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?

$\endgroup$
2
  • 2
    $\begingroup$ Have you tried to search this site for Taylor series? Series features prominently in the results... $\endgroup$
    – Yves Klett
    Commented Sep 16, 2014 at 10:10
  • 1
    $\begingroup$ You ask questions in a way that gives the idea that you are nor even trying yourself. You are expected to at least try to search the documentation by yourself and also include Mathematica code with a minimal working formatted code example of your problem or your efforts. Only good questions are likely to get great answers. $\endgroup$
    – rhermans
    Commented Sep 16, 2014 at 10:34

2 Answers 2

2
$\begingroup$

Search the documentation for Taylor, first hit is Series.

Solve Differential equation,

sol = x[t] /. First@DSolve[
    {
     D[x[t], t] == -k1 x[t] + (1 - x[t]) k2 Exp[-k2 t]
     , x[0] == 0
     }
    , x[t], t];

You can get the series by Series[sol, {t, 0, 3}] but you are interested only in the 2nd and 3rd order coefficients, so you see at the bottom of the documentation the related functions and you find SeriesCoefficient

The Series 2nd order coefficient is:

SeriesCoefficient[sol, {t, 0, 2}]

-((k1 k2)/2) - k2^2

Third order:

SeriesCoefficient[sol, {t, 0, 3}]

1/6 (k1^2 k2 + 3 k1 k2^2 + 5 k2^3)

$\endgroup$
1
  • 1
    $\begingroup$ Sorta' defeats the concept of developing a local series solution if you get a closed form instead. (Just saying..) $\endgroup$ Commented Sep 16, 2014 at 16:17
3
$\begingroup$

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 *)
$\endgroup$
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.