2.2.4 problem 4
Internal
problem
ID
[8234]
Book
:
Own
collection
of
miscellaneous
problems
Section
:
section
2.0
Problem
number
:
4
Date
solved
:
Sunday, November 10, 2024 at 03:29:28 AM
CAS
classification
:
[[_2nd_order, _with_linear_symmetries]]
Solve
\begin{align*} y^{\prime \prime }-x y^{\prime }-x y-x^{2}-x&=0 \end{align*}
Solved as second order ode using Kovacic algorithm
Time used: 1.014 (sec)
Writing the ode as
\begin{align*} y^{\prime \prime }-x y^{\prime }-x y &= 0 \tag {1} \\ A y^{\prime \prime } + B y^{\prime } + C y &= 0 \tag {2} \end{align*}
Comparing (1) and (2) shows that
\begin{align*} A &= 1 \\ B &= -x\tag {3} \\ C &= -x \end{align*}
Applying the Liouville transformation on the dependent variable gives
\begin{align*} z(x) &= y e^{\int \frac {B}{2 A} \,dx} \end{align*}
Then (2) becomes
\begin{align*} z''(x) = r z(x)\tag {4} \end{align*}
Where \(r\) is given by
\begin{align*} r &= \frac {s}{t}\tag {5} \\ &= \frac {2 A B' - 2 B A' + B^2 - 4 A C}{4 A^2} \end{align*}
Substituting the values of \(A,B,C\) from (3) in the above and simplifying gives
\begin{align*} r &= \frac {x^{2}+4 x -2}{4}\tag {6} \end{align*}
Comparing the above to (5) shows that
\begin{align*} s &= x^{2}+4 x -2\\ t &= 4 \end{align*}
Therefore eq. (4) becomes
\begin{align*} z''(x) &= \left ( \frac {1}{4} x^{2}+x -\frac {1}{2}\right ) z(x)\tag {7} \end{align*}
Equation (7) is now solved. After finding \(z(x)\) then \(y\) is found using the inverse transformation
\begin{align*} y &= z \left (x \right ) e^{-\int \frac {B}{2 A} \,dx} \end{align*}
The first step is to determine the case of Kovacic algorithm this ode belongs to. There are 3
cases depending on the order of poles of \(r\) and the order of \(r\) at \(\infty \). The following table
summarizes these cases.
| | |
Case |
Allowed pole order for \(r\) |
Allowed value for \(\mathcal {O}(\infty )\) |
| | |
1 |
\(\left \{ 0,1,2,4,6,8,\cdots \right \} \) |
\(\left \{ \cdots ,-6,-4,-2,0,2,3,4,5,6,\cdots \right \} \) |
| | |
2
|
Need to have at least one pole
that is either order \(2\) or odd order
greater than \(2\). Any other pole order
is allowed as long as the above
condition is satisfied. Hence the
following set of pole orders are all
allowed. \(\{1,2\}\),\(\{1,3\}\),\(\{2\}\),\(\{3\}\),\(\{3,4\}\),\(\{1,2,5\}\). |
no condition |
| | |
3 |
\(\left \{ 1,2\right \} \) |
\(\left \{ 2,3,4,5,6,7,\cdots \right \} \) |
| | |
Table 2.26: Necessary conditions for each Kovacic case
The order of \(r\) at \(\infty \) is the degree of \(t\) minus the degree of \(s\). Therefore
\begin{align*} O\left (\infty \right ) &= \text {deg}(t) - \text {deg}(s) \\ &= 0 - 2 \\ &= -2 \end{align*}
There are no poles in \(r\). Therefore the set of poles \(\Gamma \) is empty. Since there is no odd order pole
larger than \(2\) and the order at \(\infty \) is \(-2\) then the necessary conditions for case one are met.
Therefore
\begin{align*} L &= [1] \end{align*}
Attempting to find a solution using case \(n=1\).
Since the order of \(r\) at \(\infty \) is \(O_r(\infty ) = -2\) then
\begin{alignat*}{3} v &= \frac {-O_r(\infty )}{2} &&= \frac {2}{2} &&= 1 \end{alignat*}
\([\sqrt r]_\infty \) is the sum of terms involving \(x^i\) for \(0\leq i \leq v\) in the Laurent series for \(\sqrt r\) at \(\infty \). Therefore
\begin{align*} [\sqrt r]_\infty &= \sum _{i=0}^{v} a_i x^i \\ &= \sum _{i=0}^{1} a_i x^i \tag {8} \end{align*}
Let \(a\) be the coefficient of \(x^v=x^1\) in the above sum. The Laurent series of \(\sqrt r\) at \(\infty \) is
\[ \sqrt r \approx \frac {x}{2}+1-\frac {3}{2 x}+\frac {3}{x^{2}}-\frac {33}{4 x^{3}}+\frac {51}{2 x^{4}}-\frac {339}{4 x^{5}}+\frac {591}{2 x^{6}} + \dots \tag {9} \]
Comparing Eq. (9)
with Eq. (8) shows that
\[ a = {\frac {1}{2}} \]
From Eq. (9) the sum up to \(v=1\) gives
\begin{align*} [\sqrt r]_\infty &= \sum _{i=0}^{1} a_i x^i \\ &= \frac {x}{2}+1 \tag {10} \end{align*}
Now we need to find \(b\), where \(b\) be the coefficient of \(x^{v-1} = x^{0}=1\) in \(r\) minus the coefficient of same term but
in \(\left ( [\sqrt r]_\infty \right )^2 \) where \([\sqrt r]_\infty \) was found above in Eq (10). Hence
\[ \left ( [\sqrt r]_\infty \right )^2 = \frac {1}{4} x^{2}+x +1 \]
This shows that the coefficient of \(1\) in the
above is \(1\). Now we need to find the coefficient of \(1\) in \(r\). How this is done depends on if \(v=0\) or
not. Since \(v=1\) which is not zero, then starting \(r=\frac {s}{t}\), we do long division and write this
in the form
\[ r = Q + \frac {R}{t} \]
Where \(Q\) is the quotient and \(R\) is the remainder. Then the coefficient
of \(1\) in \(r\) will be the coefficient this term in the quotient. Doing long division gives
\begin{align*} r &= \frac {s}{t} \\ &= \frac {x^{2}+4 x -2}{4} \\ &= Q + \frac {R}{4} \\ &= \left (\frac {1}{4} x^{2}+x -\frac {1}{2}\right ) + \left ( 0\right ) \\ &= \frac {1}{4} x^{2}+x -\frac {1}{2} \end{align*}
We see that the coefficient of the term \(\frac {1}{x}\) in the quotient is \(-{\frac {1}{2}}\). Now \(b\) can be found.
\begin{align*} b &= \left (-{\frac {1}{2}}\right )-\left (1\right )\\ &= -{\frac {3}{2}} \end{align*}
Hence
\begin{alignat*}{3} [\sqrt r]_\infty &= \frac {x}{2}+1\\ \alpha _{\infty }^{+} &= \frac {1}{2} \left ( \frac {b}{a} - v \right ) &&= \frac {1}{2} \left ( \frac {-{\frac {3}{2}}}{{\frac {1}{2}}} - 1 \right ) &&= -2\\ \alpha _{\infty }^{-} &= \frac {1}{2} \left ( -\frac {b}{a} - v \right ) &&= \frac {1}{2} \left ( -\frac {-{\frac {3}{2}}}{{\frac {1}{2}}} - 1 \right ) &&= 1 \end{alignat*}
The following table summarizes the findings so far for poles and for the order of \(r\) at \(\infty \) where \(r\)
is
\[ r=\frac {1}{4} x^{2}+x -\frac {1}{2} \]
| | | |
Order of \(r\) at \(\infty \) |
\([\sqrt r]_\infty \) |
\(\alpha _\infty ^{+}\) |
\(\alpha _\infty ^{-}\) |
| | | |
\(-2\) |
\(\frac {x}{2}+1\) | \(-2\) | \(1\) |
| | | |
Now that the all \([\sqrt r]_c\) and its associated \(\alpha _c^{\pm }\) have been determined for all the poles in the set \(\Gamma \) and \([\sqrt r]_\infty \)
and its associated \(\alpha _\infty ^{\pm }\) have also been found, the next step is to determine possible non negative
integer \(d\) from these using
\begin{align*} d &= \alpha _\infty ^{s(\infty )} - \sum _{c \in \Gamma } \alpha _c^{s(c)} \end{align*}
Where \(s(c)\) is either \(+\) or \(-\) and \(s(\infty )\) is the sign of \(\alpha _\infty ^{\pm }\). This is done by trial over all set of families \(s=(s(c))_{c \in \Gamma \cup {\infty }}\) until
such \(d\) is found to work in finding candidate \(\omega \). Trying \(\alpha _\infty ^{-} = 1\), and since there are no poles then
\begin{align*} d &= \alpha _\infty ^{-} \\ &= 1 \end{align*}
Since \(d\) an integer and \(d \geq 0\) then it can be used to find \(\omega \) using
\begin{align*} \omega &= \sum _{c \in \Gamma } \left ( s(c) [\sqrt r]_c + \frac {\alpha _c^{s(c)}}{x-c} \right ) + s(\infty ) [\sqrt r]_\infty \end{align*}
The above gives
\begin{align*} \omega &= (-) [\sqrt r]_\infty \\ &= 0 + (-) \left ( \frac {x}{2}+1 \right ) \\ &= -1-\frac {x}{2}\\ &= -1-\frac {x}{2} \end{align*}
Now that \(\omega \) is determined, the next step is find a corresponding minimal polynomial \(p(x)\) of degree
\(d=1\) to solve the ode. The polynomial \(p(x)\) needs to satisfy the equation
\begin{align*} p'' + 2 \omega p' + \left ( \omega ' +\omega ^2 -r\right ) p = 0 \tag {1A} \end{align*}
Let
\begin{align*} p(x) &= x +a_{0}\tag {2A} \end{align*}
Substituting the above in eq. (1A) gives
\begin{align*} \left (0\right ) + 2 \left (-1-\frac {x}{2}\right ) \left (1\right ) + \left ( \left (-{\frac {1}{2}}\right ) + \left (-1-\frac {x}{2}\right )^2 - \left (\frac {1}{4} x^{2}+x -\frac {1}{2}\right ) \right ) &= 0\\ -2+a_{0} = 0 \end{align*}
Solving for the coefficients \(a_i\) in the above using method of undetermined coefficients gives
\[ \{a_{0} = 2\} \]
Substituting these coefficients in \(p(x)\) in eq. (2A) results in
\begin{align*} p(x) &= 2+x \end{align*}
Therefore the first solution to the ode \(z'' = r z\) is
\begin{align*} z_1(x) &= p e^{ \int \omega \,dx}\\ & = \left (2+x\right ) {\mathrm e}^{\int \left (-1-\frac {x}{2}\right )d x}\\ & = \left (2+x\right ) {\mathrm e}^{-x -\frac {1}{4} x^{2}}\\ & = \left (2+x \right ) {\mathrm e}^{-\frac {x \left (4+x \right )}{4}} \end{align*}
The first solution to the original ode in \(y\) is found from
\begin{align*}
y_1 &= z_1 e^{ \int -\frac {1}{2} \frac {B}{A} \,dx} \\
&= z_1 e^{ -\int \frac {1}{2} \frac {-x}{1} \,dx} \\
&= z_1 e^{\frac {x^{2}}{4}} \\
&= z_1 \left ({\mathrm e}^{\frac {x^{2}}{4}}\right ) \\
\end{align*}
Which simplifies to
\[
y_1 = \left (2+x \right ) {\mathrm e}^{-x}
\]
The second
solution \(y_2\) to the original ode is found using reduction of order
\[ y_2 = y_1 \int \frac { e^{\int -\frac {B}{A} \,dx}}{y_1^2} \,dx \]
Substituting gives
\begin{align*}
y_2 &= y_1 \int \frac { e^{\int -\frac {-x}{1} \,dx}}{\left (y_1\right )^2} \,dx \\
&= y_1 \int \frac { e^{\frac {x^{2}}{2}}}{\left (y_1\right )^2} \,dx \\
&= y_1 \left (-\frac {{\mathrm e}^{-2+\frac {\left (2+x \right )^{2}}{2}}}{2+x}-\frac {i \sqrt {\pi }\, {\mathrm e}^{-2} \sqrt {2}\, \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right )}{2}\right ) \\
\end{align*}
Therefore
the solution is
\begin{align*}
y &= c_1 y_1 + c_2 y_2 \\
&= c_1 \left (\left (2+x \right ) {\mathrm e}^{-x}\right ) + c_2 \left (\left (2+x \right ) {\mathrm e}^{-x}\left (-\frac {{\mathrm e}^{-2+\frac {\left (2+x \right )^{2}}{2}}}{2+x}-\frac {i \sqrt {\pi }\, {\mathrm e}^{-2} \sqrt {2}\, \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right )}{2}\right )\right ) \\
\end{align*}
This is second order nonhomogeneous ODE. Let the solution be
\[
y = y_h + y_p
\]
Where \(y_h\) is the solution to
the homogeneous ODE \( A y''(x) + B y'(x) + C y(x) = 0\), and \(y_p\) is a particular solution to the nonhomogeneous ODE \(A y''(x) + B y'(x) + C y(x) = f(x)\). \(y_h\) is the
solution to
\[
y^{\prime \prime }-x y^{\prime }-x y = 0
\]
The homogeneous solution is found using the Kovacic algorithm which results in
\[
y_h = c_1 \left (2+x \right ) {\mathrm e}^{-x}-\frac {c_2 \,{\mathrm e}^{-x} \left (i \sqrt {2}\, \sqrt {\pi }\, {\mathrm e}^{-2} \left (2+x \right ) \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right )+2 \,{\mathrm e}^{\frac {x \left (4+x \right )}{2}}\right )}{2}
\]
The particular solution \(y_p\) can be found using either the method of undetermined coefficients,
or the method of variation of parameters. The method of variation of parameters will be
used as it is more general and can be used when the coefficients of the ODE depend on \(x\) as
well. Let
\begin{equation}
\tag{1} y_p(x) = u_1 y_1 + u_2 y_2
\end{equation}
Where \(u_1,u_2\) to be determined, and \(y_1,y_2\) are the two basis solutions (the two linearly
independent solutions of the homogeneous ODE) found earlier when solving the
homogeneous ODE as
\begin{align*}
y_1 &= \left (2+x \right ) {\mathrm e}^{-x} \\
y_2 &= -\frac {{\mathrm e}^{-x} \left (i \sqrt {2}\, \sqrt {\pi }\, {\mathrm e}^{-2} \left (2+x \right ) \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right )+2 \,{\mathrm e}^{\frac {x \left (4+x \right )}{2}}\right )}{2} \\
\end{align*}
In the Variation of parameters \(u_1,u_2\) are found using
\begin{align*}
\tag{2} u_1 &= -\int \frac {y_2 f(x)}{a W(x)} \\
\tag{3} u_2 &= \int \frac {y_1 f(x)}{a W(x)} \\
\end{align*}
Where \(W(x)\) is the
Wronskian and \(a\) is the coefficient in front of \(y''\) in the given ODE. The Wronskian is given
by \(W= \begin {vmatrix} y_1 & y_{2} \\ y_{1}^{\prime } & y_{2}^{\prime } \end {vmatrix} \). Hence
\[ W = \begin {vmatrix} \left (2+x \right ) {\mathrm e}^{-x} & -\frac {{\mathrm e}^{-x} \left (i \sqrt {2}\, \sqrt {\pi }\, {\mathrm e}^{-2} \left (2+x \right ) \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right )+2 \,{\mathrm e}^{\frac {x \left (4+x \right )}{2}}\right )}{2} \\ \frac {d}{dx}\left (\left (2+x \right ) {\mathrm e}^{-x}\right ) & \frac {d}{dx}\left (-\frac {{\mathrm e}^{-x} \left (i \sqrt {2}\, \sqrt {\pi }\, {\mathrm e}^{-2} \left (2+x \right ) \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right )+2 \,{\mathrm e}^{\frac {x \left (4+x \right )}{2}}\right )}{2}\right ) \end {vmatrix} \]
Which gives
\[ W = \begin {vmatrix} \left (2+x \right ) {\mathrm e}^{-x} & -\frac {{\mathrm e}^{-x} \left (i \sqrt {2}\, \sqrt {\pi }\, {\mathrm e}^{-2} \left (2+x \right ) \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right )+2 \,{\mathrm e}^{\frac {x \left (4+x \right )}{2}}\right )}{2} \\ {\mathrm e}^{-x}-\left (2+x \right ) {\mathrm e}^{-x} & \frac {{\mathrm e}^{-x} \left (i \sqrt {2}\, \sqrt {\pi }\, {\mathrm e}^{-2} \left (2+x \right ) \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right )+2 \,{\mathrm e}^{\frac {x \left (4+x \right )}{2}}\right )}{2}-\frac {{\mathrm e}^{-x} \left (i \sqrt {\pi }\, {\mathrm e}^{-2} \sqrt {2}\, \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right )-2 \,{\mathrm e}^{-2} \left (2+x \right ) {\mathrm e}^{\frac {\left (2+x \right )^{2}}{2}}+2 \left (2+x \right ) {\mathrm e}^{\frac {x \left (4+x \right )}{2}}\right )}{2} \end {vmatrix} \]
Therefore
\[
W = \left (\left (2+x \right ) {\mathrm e}^{-x}\right )\left (\frac {{\mathrm e}^{-x} \left (i \sqrt {2}\, \sqrt {\pi }\, {\mathrm e}^{-2} \left (2+x \right ) \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right )+2 \,{\mathrm e}^{\frac {x \left (4+x \right )}{2}}\right )}{2}-\frac {{\mathrm e}^{-x} \left (i \sqrt {\pi }\, {\mathrm e}^{-2} \sqrt {2}\, \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right )-2 \,{\mathrm e}^{-2} \left (2+x \right ) {\mathrm e}^{\frac {\left (2+x \right )^{2}}{2}}+2 \left (2+x \right ) {\mathrm e}^{\frac {x \left (4+x \right )}{2}}\right )}{2}\right ) - \left (-\frac {{\mathrm e}^{-x} \left (i \sqrt {2}\, \sqrt {\pi }\, {\mathrm e}^{-2} \left (2+x \right ) \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right )+2 \,{\mathrm e}^{\frac {x \left (4+x \right )}{2}}\right )}{2}\right )\left ({\mathrm e}^{-x}-\left (2+x \right ) {\mathrm e}^{-x}\right )
\]
Which simplifies to
\[
W = {\mathrm e}^{\frac {\left (2+x \right )^{2}}{2}} {\mathrm e}^{-2} {\mathrm e}^{-2 x} x^{2}+4 \,{\mathrm e}^{\frac {\left (2+x \right )^{2}}{2}} {\mathrm e}^{-2} {\mathrm e}^{-2 x} x -{\mathrm e}^{\frac {x \left (4+x \right )}{2}} {\mathrm e}^{-2 x} x^{2}+4 \,{\mathrm e}^{\frac {\left (2+x \right )^{2}}{2}} {\mathrm e}^{-2} {\mathrm e}^{-2 x}-4 \,{\mathrm e}^{\frac {x \left (4+x \right )}{2}} {\mathrm e}^{-2 x} x -3 \,{\mathrm e}^{\frac {x \left (4+x \right )}{2}} {\mathrm e}^{-2 x}
\]
Which simplifies to
\[
W = {\mathrm e}^{\frac {x^{2}}{2}}
\]
Therefore Eq. (2) becomes
\[
u_1 = -\int \frac {-\frac {{\mathrm e}^{-x} \left (i \sqrt {2}\, \sqrt {\pi }\, {\mathrm e}^{-2} \left (2+x \right ) \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right )+2 \,{\mathrm e}^{\frac {x \left (4+x \right )}{2}}\right ) \left (x^{2}+x \right )}{2}}{{\mathrm e}^{\frac {x^{2}}{2}}}\,dx
\]
Which simplifies to
\[
u_1 = - \int -\frac {x \,{\mathrm e}^{-\frac {x \left (2+x \right )}{2}} \left (i \sqrt {2}\, \sqrt {\pi }\, {\mathrm e}^{-2} \left (2+x \right ) \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right )+2 \,{\mathrm e}^{\frac {x \left (4+x \right )}{2}}\right ) \left (1+x \right )}{2}d x
\]
Hence
\[
u_1 = -\left (\int _{0}^{x}-\frac {\alpha \,{\mathrm e}^{-\frac {\alpha \left (2+\alpha \right )}{2}} \left (i \sqrt {2}\, \sqrt {\pi }\, {\mathrm e}^{-2} \left (2+\alpha \right ) \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+\alpha \right )}{2}\right )+2 \,{\mathrm e}^{\frac {\alpha \left (4+\alpha \right )}{2}}\right ) \left (1+\alpha \right )}{2}d \alpha \right )
\]
And Eq. (3) becomes
\[
u_2 = \int \frac {\left (2+x \right ) {\mathrm e}^{-x} \left (x^{2}+x \right )}{{\mathrm e}^{\frac {x^{2}}{2}}}\,dx
\]
Which
simplifies to
\[
u_2 = \int \left (2+x \right ) x \left (1+x \right ) {\mathrm e}^{-\frac {x \left (2+x \right )}{2}}d x
\]
Hence
\[
u_2 = -\left (x^{2}+2 x +2\right ) {\mathrm e}^{-\frac {x \left (2+x \right )}{2}}
\]
Therefore the particular solution, from equation (1) is
\[
y_p(x) = -\left (\int _{0}^{x}-\frac {\alpha \,{\mathrm e}^{-\frac {\alpha \left (2+\alpha \right )}{2}} \left (i \sqrt {2}\, \sqrt {\pi }\, {\mathrm e}^{-2} \left (2+\alpha \right ) \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+\alpha \right )}{2}\right )+2 \,{\mathrm e}^{\frac {\alpha \left (4+\alpha \right )}{2}}\right ) \left (1+\alpha \right )}{2}d \alpha \right ) \left (2+x \right ) {\mathrm e}^{-x}+\frac {{\mathrm e}^{-x} \left (i \sqrt {2}\, \sqrt {\pi }\, {\mathrm e}^{-2} \left (2+x \right ) \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right )+2 \,{\mathrm e}^{\frac {x \left (4+x \right )}{2}}\right ) \left (x^{2}+2 x +2\right ) {\mathrm e}^{-\frac {x \left (2+x \right )}{2}}}{2}
\]
Which
simplifies to
\[
y_p(x) = \frac {{\mathrm e}^{-x} \left (2+x \right ) \left (\int _{0}^{x}\alpha \,{\mathrm e}^{-\frac {\alpha \left (2+\alpha \right )}{2}} \left (i \sqrt {2}\, \sqrt {\pi }\, {\mathrm e}^{-2} \left (2+\alpha \right ) \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+\alpha \right )}{2}\right )+2 \,{\mathrm e}^{\frac {\alpha \left (4+\alpha \right )}{2}}\right ) \left (1+\alpha \right )d \alpha \right )}{2}+\frac {\left (x^{2}+2 x +2\right ) \left (2+i \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right ) \sqrt {\pi }\, \sqrt {2}\, \left (2+x \right ) {\mathrm e}^{-\frac {\left (2+x \right )^{2}}{2}}\right )}{2}
\]
Therefore the general solution is
\begin{align*}
y &= y_h + y_p \\
&= \left (c_1 \left (2+x \right ) {\mathrm e}^{-x}-\frac {c_2 \,{\mathrm e}^{-x} \left (i \sqrt {2}\, \sqrt {\pi }\, {\mathrm e}^{-2} \left (2+x \right ) \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right )+2 \,{\mathrm e}^{\frac {x \left (4+x \right )}{2}}\right )}{2}\right ) + \left (\frac {{\mathrm e}^{-x} \left (2+x \right ) \left (\int _{0}^{x}\alpha \,{\mathrm e}^{-\frac {\alpha \left (2+\alpha \right )}{2}} \left (i \sqrt {2}\, \sqrt {\pi }\, {\mathrm e}^{-2} \left (2+\alpha \right ) \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+\alpha \right )}{2}\right )+2 \,{\mathrm e}^{\frac {\alpha \left (4+\alpha \right )}{2}}\right ) \left (1+\alpha \right )d \alpha \right )}{2}+\frac {\left (x^{2}+2 x +2\right ) \left (2+i \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right ) \sqrt {\pi }\, \sqrt {2}\, \left (2+x \right ) {\mathrm e}^{-\frac {\left (2+x \right )^{2}}{2}}\right )}{2}\right ) \\
\end{align*}
Will add steps showing solving for IC
soon.
Summary of solutions found
\begin{align*}
y &= c_1 \left (2+x \right ) {\mathrm e}^{-x}-\frac {c_2 \,{\mathrm e}^{-x} \left (i \sqrt {2}\, \sqrt {\pi }\, {\mathrm e}^{-2} \left (2+x \right ) \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right )+2 \,{\mathrm e}^{\frac {x \left (4+x \right )}{2}}\right )}{2}+\frac {{\mathrm e}^{-x} \left (2+x \right ) \left (\int _{0}^{x}\alpha \,{\mathrm e}^{-\frac {\alpha \left (2+\alpha \right )}{2}} \left (i \sqrt {2}\, \sqrt {\pi }\, {\mathrm e}^{-2} \left (2+\alpha \right ) \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+\alpha \right )}{2}\right )+2 \,{\mathrm e}^{\frac {\alpha \left (4+\alpha \right )}{2}}\right ) \left (1+\alpha \right )d \alpha \right )}{2}+\frac {\left (x^{2}+2 x +2\right ) \left (2+i \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (2+x \right )}{2}\right ) \sqrt {\pi }\, \sqrt {2}\, \left (2+x \right ) {\mathrm e}^{-\frac {\left (2+x \right )^{2}}{2}}\right )}{2} \\
\end{align*}
Maple step by step solution
Maple trace
`Methods for second order ODEs:
--- Trying classification methods ---
trying a quadrature
trying high order exact linear fully integrable
trying differential order: 2; linear nonhomogeneous with symmetry [0,1]
trying a double symmetry of the form [xi=0, eta=F(x)]
-> Try solving first the homogeneous part of the ODE
checking if the LODE has constant coefficients
checking if the LODE is of Euler type
trying a symmetry of the form [xi=0, eta=F(x)]
checking if the LODE is missing y
-> Trying a Liouvillian solution using Kovacics algorithm
A Liouvillian solution exists
Reducible group (found an exponential solution)
Group is reducible, not completely reducible
<- Kovacics algorithm successful
<- solving first the homogeneous part of the ODE successful`
Maple dsolve solution
Solving time : 0.012
(sec)
Leaf size : 54
dsolve(diff(diff(y(x),x),x)-diff(y(x),x)*x-x*y(x)-x^2-x = 0,
y(x),singsol=all)
\[
y = i c_{1} \sqrt {\pi }\, \left (x +2\right ) \sqrt {2}\, {\mathrm e}^{-2-x} \operatorname {erf}\left (\frac {i \sqrt {2}\, \left (x +2\right )}{2}\right )+2 \,{\mathrm e}^{\frac {x \left (x +2\right )}{2}} c_{1} +{\mathrm e}^{-x} \left (x +2\right ) c_{2} -x
\]
Mathematica DSolve solution
Solving time : 1.764
(sec)
Leaf size : 84
DSolve[{D[y[x],{x,2}]-x*D[y[x],x]-x*y[x]-x^2-x==0,{}},
y[x],x,IncludeSingularSolutions->True]
\[
y(x)\to \frac {1}{2} e^{-x} \left (-\sqrt {2 \pi } c_2 \sqrt {(x+2)^2} \text {erfi}\left (\frac {\sqrt {(x+2)^2}}{\sqrt {2}}\right )-2 e^x x+2 \sqrt {2} c_1 (x+2)+2 c_2 e^{\frac {1}{2} (x+2)^2}\right )
\]