Q:

Solving the ODE $(x^2 - 1) y''- 2xy' + 2y = (x^2 - 1)^2$

I want to solve this ODE:  

$$(x^2 - 1)y'' - 2xy' + 2y = (x^2 - 1)^2.$$

I found out that $y_1 = x$ and $y_2 = x^2+1$ are solutions of the associated  homogeneous equation, $x$ by inspecting, and $x^2+1$ by multiplying $x$ by a function and solving. Now, I know that a particular solution of the problem is given by $y_p = k_1x + k_2(x^2+1)$, for some functions $k_1,k_2$, which must satisfy the following relations: $$\left\{ \begin{array}{l} k_1'x + k_2'(x²+1) = 0 \\k_1' + k_2'(2x) = (x^2-1)^2 \end{array}\right.$$
From the second equation, I have that $k_1' = (x^2-1)^2 - 2xk_2'$, and in the first equation we get that: $$ x(x^2-1)^2 - 2x^2k_2' + (x^2+1)k_2' = 0 \implies (-x^2+1)k_2' = -x(x^2-1)^2$$
and so $k_2' = x(x^2-1) = x³ - x$. Back in the second equation, we obtain: $$k_1' = (x^2-1)^2 - 2x^2(x^2-1) \implies k_1' = (x^2-1)(-x²-1) = -x⁴ + 1.$$
By simple integration, we get $k_1 = -\frac{x^5}{5}+x$ and $k_2 = \frac{x^4}{4} - \frac{x^2}{2}$. By this calculation, the particular solution would be: $$y_p =-\frac{x^6}{5} + x^2 + \frac{x^6}{4} -\frac{x^4}{2} + \frac{x^4}{4} - \frac{x^2}{2} \\ \implies y_p = \frac{x^6}{20} - \frac{x^4}{4} + \frac{x^2}{2}.$$
Differentiating, we get $y_p' = \frac{3x^5}{10} - x^3 + x$ and $y_p'' = \frac{3x^4}{2} - 3x^2 + 1$. Notice that the only constant term on the left side will be a lonely $-1$. But this can't be right, since it'll have to appear a $+1$ term on the right side, to match the $+1$ in $x^4-2x^2 + 1$ on the right side. 
I don't have a single clue of why this isn't working. This is bothering me since yesterday, and I can't think of anything. Can someone help me?

A:

I have redone the calculations and solved the problem. I'll leave my solution here, in case it helps someone. This time, my mistake was not writing the equation as: $$y'' - \frac{2x}{x^2 - 1}y' + \frac{2}{x^2 - 1}y = (x^2 - 1)$$
before applying the method.Really, $y_1 = x$ and $y_2 = x^2+1$ are solutions for the homogeneous equation. Then, we go for: 
$$\left\{ \begin{array}{l} k_1'x + k_2'(x²+1) = 0 \\k_1' + k_2'(2x) = (x^2-1) \end{array}\right.$$
Multiplying the second equation by $x$ and subtracting the first equation from it yields $(x^2-1)k_2' = x(x²-1)$, and hence $k_2' = x$. Back into the second equation, we have $k_1' = -x^2 - 1$. Integrating, we obtain $k_1 = -\frac{x^3}{3}-x$ and $k_2 = \frac{x^2}{2}$. The constants of integration are not needed. I have done the calculations with them, and all of the terms containing them kill each other. So, we have as a particular solution: $$y_p = -\frac{x^4}{3}-x^2 + (x^2+1)\frac{x^2}{2} \\ \implies y_p = -\frac{x^2}{2} + \frac{x^4}{6}.$$
Differentiating we get: $$\begin{align}y_p' &= -x + \frac{2x^3}{3} \\ y_p'' &= -1+2x^2 \end{align}$$
and it is easy to check now that it is really a solution. Hence, the general solution is given by: $$y = -\frac{x^2}{2} + \frac{x^4}{6} + c_1x + c_2(x^2+1), \qquad c_1,c_2 \in \Bbb R.$$

