# Finding terms of the perturbation solution

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 == 1}, y[t], t]


{{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.

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

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 = x /.
First@DSolve[{First@SeriesCoefficient[equ, {\[Epsilon], 0, 0}] == 0,
x == 1}, x, 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}, 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"]] 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

• 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? – Photon Light Nov 21 '15 at 19:50
• @PhotonLight You're welcome. You may find the explicit solution with DSolve[{equ == 0, y == 1}, y, t]. – mmal Nov 21 '15 at 19:54
• 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}, 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... – Photon Light Nov 22 '15 at 15:48

In Version 12 you can now do

AsymptoticDSolveValue[{y'[t] == 1 + (1 + e) y[t]^2, y == 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.

## protected by xzczdDec 4 '17 at 8:47

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).