3
$\begingroup$

I've got a task to find first three terms of the perturbation series solution to:
$$y' = 1 +(1+\epsilon)y^2,\quad y(0)=1, \quad t > 0,$$ for a small $\epsilon$. I am supposed to use Mathematica document to solve that. So far, I have found a similar problem here. I solved it for $\epsilon = 0$:

sol1 = DSolve[{y'[t] == 1 + y[t]^2, y[0] == 1}, y[t], t] 

and I received soultion:

{{y(t)->Tan(t+π/4)}}

so as my $y(t) = \tan(\pi/4 + t)$ I need to find now:

$$y = \tan(\pi/4 + t) + \epsilon y_1(t) + \epsilon^2 y_2(t) + \epsilon^3 y_3(t) + \ldots .$$

Because $y(0) = 1$, I need all $y_1(0) = y_2(0) = y_3(0) =... = 0 $ and substitute $y$ in my first equation and later on find terms for each power of $\epsilon$. Now my problem is how to do it? I'm not Mathematica proficient user (used it shortly ~1 year ago), so it may be simple, but I do not know how to code it in.

$\endgroup$
  • $\begingroup$ Hello ı need solve perturbation problem with mathematica.Help me pls.Thanks.. $\endgroup$ – Necmi Gurkan Dec 4 '17 at 8:29
  • 1
    $\begingroup$ @NecmiGurkan if you have a specific problem see asking guidelines and add a new question instead of posting it as an answer. $\endgroup$ – Kuba Dec 4 '17 at 8:47
3
$\begingroup$

You may start with something like that

equ = {-y'[t] + 1 + (1 + \[Epsilon]) y[t]^2};
y[t_] := Sum[x[i][t] \[Epsilon]^i, {i, 0, 10}] // Evaluate;

First order solution (use SeriesCoefficient function to expand equation with series substituted)

x[0] = x[0] /. 
  First@DSolve[{First@SeriesCoefficient[equ, {\[Epsilon], 0, 0}] == 0,
      x[0][0] == 1}, x[0], t];

and then loop over higher order terms (all with zero BC)

Do[
  x[k] = x[k] /. 
    First@DSolve[{First@SeriesCoefficient[equ, {\[Epsilon], 0, k}] == 
        0, x[k][0] == 0}, x[k], t], {k, 1, 4}];

Set not defined coefficients to zero by

x[_] = Function[t, 0];

Finally, compare with explicit solution, either by plotting

Block[{\[Epsilon] = 0.1}, 
 Plot[{y[t], 
   Tan[t Sqrt[1 + \[Epsilon]] + ArcTan[Sqrt[1 + \[Epsilon]]]]/Sqrt[
   1 + \[Epsilon]]}, {t, -3, 1}, PlotRange -> Automatic,
 PlotLegends -> "Expressions"]]

enter image description here

or comparing series expansions

Equal @@ Normal@
   Series[{y[t], 
     Tan[t Sqrt[1 + \[Epsilon]] + ArcTan[Sqrt[1 + \[Epsilon]]]]/Sqrt[
     1 + \[Epsilon]]}, {\[Epsilon], 0, 4}] // Simplify

True

$\endgroup$
  • $\begingroup$ Thank you, looks good. I've got one question however, how you foud out this expression: Tan[t Sqrt[1 + [Epsilon]] + ArcTan[Sqrt[1 + [Epsilon]]]]/Sqrt[ 1 + [Epsilon]] ? Where it comes from? $\endgroup$ – Photon Light Nov 21 '15 at 19:50
  • $\begingroup$ @PhotonLight You're welcome. You may find the explicit solution with DSolve[{equ == 0, y[0] == 1}, y, t]. $\endgroup$ – mmal Nov 21 '15 at 19:54
  • $\begingroup$ I don't want to trash stack with similiar question, so maybe you can tell me how to add additional initial condition to this: Do[ x[k] = x[k] /. First@DSolve[{First@SeriesCoefficient[equ, {[Epsilon], 0, k}] == 0, x[k][0] == 0}, x[k], t], {k, 1, 4}] I mean I have similiar problem, but y''[t] + (1 + eps)*y'[t] = 0 with y(0) = 1 and y'(0) = 0. I don't know how to add second one, I tried in few places, but I'm only getting errors... $\endgroup$ – Photon Light Nov 22 '15 at 15:48
5
$\begingroup$

In Version 12 you can now do

AsymptoticDSolveValue[{y'[t] == 1 + (1 + e) y[t]^2, y[0] == 1}, y[t], t, {e, 0, 4}]

Note that the result for this problem uses complex numbers so when you plot the results you want to use Chop[] or Re[] when converting the exact solution to a numerical one. MMA returns answers with tiny (10^-16) or even 0.0 complex parts.

$\endgroup$

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