I am trying to solve a recurrence relation using generating functions method: $$a_n=a_{n-1}+(n-1)a_{n-2}+(0.5n^2-1.5n+1)a_{n-3}$$
After some long calculations, I have arrived to this second-order differential equation: $$0.5 x^5 y''(x)+(2x^4+x^3)y'(x)+\left(x^3+x^2+x-1\right)y(x)+1=0$$
and these conditions: $y(0)=1, y'(0)=1$. $y(x)$ is the function that needs to be expanded as Taylor Series at $x=0$ to obtain the sequence from the coefficients. However, when I try to solve it both using DSolve and NDSolve, I have no luck. With DSolve it just returns the request itself:
$$\text{DSolve}\left[\left\{0.5 x^5 y''(x)+(2. x+1) x^3 y'(x)+\left(1. x^3+x^2+x-1\right)y(x)+1=0,y(0)=1,y'(0)=1\right\},y,x\right]$$
And with NDSolve I just receive errors and no equation:
Power::infy: Infinite expression 1/0.^5 encountered.
Infinity::indet: Indeterminate expression 0. ComplexInfinity encountered.
NDSolve::ndnum: Encountered non-numerical value for a derivative at x == 0.`.
$$\text{NDSolve}\left[\left\{0.5 x^5 y''(x)+(2. x+1) x^3 y'(x)+\left(1. x^3+x^2+x-1\right)y(x)+1=0,y(0)=1,y'(0)=1\right\},y,\{x,0,1\}\right]$$
How could I resolve this problem?
Code:
Simplify[y[x] - (1 + x + 2 x^2)]
l = Expand[%]
Simplify[x (y[x] - (1 + x))]
r1 = Expand[%]
Simplify[x*D[x^2 (y[x] - 1), x] - x^2 (y[x] - 1)]
r2 = Expand[%]
Simplify[0.5 x*D[x*D[x^3*y[x], x], x] - 1.5 x*D[x^3*y[x], x] +
x^3*y[x]]
r3 = Expand[%]
eq = FullSimplify[r1 + r2 + r3 - l]
DSolve[{eq == 0, y[0] == 1}, y, x]
NDSolve[{eq == 0, y[0] == 1, y'[0] == 1}, y, {x, 0, 1}]
NDSolve
fails here, because the ODE is singular atx = 0
. Try integrating from a slightly larger value ofx
, but even then expect some difficulties. $\endgroup$RecurrenceTable[{a[n] == a[n - 1] + (n - 1) a[n - 2] + (n^2 - 3 n + 2)/2 a[n - 3], a[1] == 1, a[2] == 1, a[3] == 2}, a, {n, 11}]
yields{1, 1, 2, 8, 22, 82, 334, 1370, 6338, 30692, 155722}
. $\endgroup$