(x+2)y''+(2x+5)y'+2y=(x+1)eˣ.

Let y=a₀+a₁x+a₂x²+...=∑aᵣxʳfor r∈[0,∞)=a₀+a₁x+∑aᵣ₊₂xʳ⁺².

So y'=∑raᵣxʳ⁻¹=a₁+∑(r+2)aᵣ₊₂xʳ⁺¹ and y''=∑(r+2)(r+1)aᵣ₊₂xʳ.

eˣ=1+x+∑xʳ⁺²/(r+2)!.

(x+1)eˣ=(x+1)(1+x+∑xʳ⁺²/(r+2)!)=x²+2x+1+(x+1)(∑xʳ⁺²/(r+2)!).

All the summations applies for r∈[0,∞).

The DE can be written:

(x+2)∑(r+2)(r+1)aᵣ₊₂xʳ+

(2x+5)(a₁+∑(r+2)aᵣ₊₂xʳ⁺¹)+

2(a₀+a₁x+∑aᵣ₊₂xʳ⁺²)=

x²+2x+1+(x+1)(∑xʳ⁺²/(r+2)!).

This can be further expanded:

∑(r+2)(r+1)aᵣ₊₂xʳ⁺¹+2∑(r+2)(r+1)aᵣ₊₂xʳ+

2a₁x+5a₁+2∑(r+2)aᵣ₊₂xʳ⁺²+5∑(r+2)aᵣ₊₂xʳ⁺¹+

2a₀+2a₁x+2∑aᵣ₊₂xʳ⁺²=

x²+2x+1+∑xʳ⁺³/(r+2)!+∑xʳ⁺²/(r+2)!.

Next, group together the same powers of x:

∑2(r+3)aᵣ₊₂xʳ⁺²+

∑(r²+8r+12)aᵣ₊₂xʳ⁺¹+

2∑(r+2)(r+1)aᵣ₊₂xʳ+

4a₁x+

5a₁+2a₀=

x²+2x+1+∑xʳ⁺³/(r+2)!+∑xʳ⁺²/(r+2)!.

Now we need to match terms with the same power of x. To do this accurately we need to find which r values to substitute in each of these summation groups. If we start at x⁰ (constant terms), the only contributor is constant (x⁰):

2∑(r+2)(r+1)aᵣ₊₂xʳ+5a₁+2a₀=1,

Putting r=0, we get:

4a₂+5a₁+2a₀.

The contributing groups for x¹ are:

∑(r²+8r+12)aᵣ₊₂xʳ⁺¹ (r=0) and 2∑(r+2)(r+1)aᵣ₊₂xʳ(r=1) and 4a₁x.

This gives us:

12a₂+12a₃+4a₁.

For x²:

2∑(r+3)aᵣ₊₂xʳ⁺² (r=0) +

∑(r²+8r+12)aᵣ₊₂xʳ⁺¹ (r=1) +

2∑(r+2)(r+1)aᵣ₊₂xʳ(r=2).

This gives us:

6a₂+21a₃+24a₄.

For x³:

2∑(r+3)aᵣ₊₂xʳ⁺² (r=1) +

∑(r²+8r+12)aᵣ₊₂xʳ⁺¹ (r=2) +

2∑(r+2)(r+1)aᵣ₊₂xʳ(r=3).

This gives us:

8a₃+32a₄+40a₅.

On the right-hand side we have:

1+2x+x²+x²/2!+x³/2!+x³/3!+...

Equating coefficients:

x⁰: 2a₀+5a₁+4a₂=1.

x¹: 4a₁+12a₂+12a₃=2, 2a₁+6a₂+6a₃=1.

x²: 6a₂+21a₃+24a₄=1+½=3/2, 4a₂+14a₃+16a₄=1.

x³: 8a₃+32a₄+40a₅=½+⅙=⅔, 12a₃+48a₄+60a₅=1.

For xʳ:

2(r+1)aᵣ+(r+1)(r+5)aᵣ₊₁+2(r+1)(r+2)aᵣ₊₂=(r+1)/(r-1)! where r≥0. Note that factorial for values ≤ 0 is understood to be 1. Hence, for example, (-1)!=0!=1.

This formula relates the coefficients for each power r of x, so can be used to determine any coefficient from its predecessors.

We know there are going to be 2 constants of integration. If we make a₀ and a₁ those two constants A and B respectively, then we should be able to relate other coefficient to A and B.

a₀=A, a₁=B,

a₂=¼(1-2A-5B).

a₃=(6A+11B-1)/12.

Therefore the solution up to x³ is:

y=A+Bx+(1-2A-5B)x²/4+(6A+11B-1)x³/12+...