ODEs – Variation of Parameters Method Giving Wrong Answer

ordinary differential equations

I had a Differential Equations midterm yesterday with the problem:
$$x^3y''+x^2y'-xy=\frac{x}{x+1}.$$
We were told beforehand that the homogeneous equation had a solution set $y_1(x)=x, y_2(x)=x^{-1}$, so we were only supposed to find the particular solution using the Variation of parameters method. I started by solving for the Wronskian which should be $$W=\begin{vmatrix}x&\frac{1}{x}\\1&-\frac1{x^2}\end{vmatrix}=-\frac2x.$$
Now, as far as I know, we need to suppose that the particular solution is of the form $y=u_1(x)y_1(x)+u_2(x)y_2(x)$, and we can calculate $u_1$ and $u_2$ in the following way:
$$u_1=\int\frac{-y_2(x)g(x)}{W}dx\text{ and }u_2=\int\frac{y_1(x)g(x)}{W}dx,$$
giving me in this case that
$$\begin{align}u_1&=\int\frac{-\frac{1}{x}\frac{x}{1+x}}{\frac{-2}{x}}dx\\&=\frac{1}{2}\int\frac{x}{1+x}dx=\frac{1}{2}(x+1-\ln|x+1|)\\u_2&=\int\frac{x\frac{x}{1+x}}{\frac{-2}{x}}dx\\&=-\frac12\int\frac{x^3}{1+x}dx\\&=-\frac12\left(\frac{(x+1)^3}{3}-\frac{3(x+1)^2}{2}+3(x+1)-\ln|x+1|\right).\end{align}$$
Thus, the particular solution should be
$$y=\frac{x}{2}(x+1-\ln|x+1|)-\frac{1}{2x}\left(\frac{(x+1)^3}{3}-\frac{3(x+1)^2}{2}+3(x+1)\ln|x+1|\right).$$
I tried to check this solution using Mathematica, but when I plug it in the ODE, the expression simplifies to $\frac{x^4}{x+1}$, not $\frac{x}{x+1}$ as the problem initially wanted. Also, in online calculators, the solution sometimes has a $\ln(x)$ that does not appear anywhere on my solution.

I'm honestly really confused, I don't see at all where the mistake could be. Any help will be really appreciated.

Best Answer

The function $g(x)$ in the equations $$ u_1=\int\frac{-y_2(x)g(x)}{W}dx\quad\text{and}\quad u_2=\int\frac{y_1(x)g(x)}{W}dx \tag{1} $$ is the RHS of the ODE when the coefficient of $y''$ is $1$, i.e. $$ y''+\frac{1}{x}y'-\frac{1}{x^2}y=\frac{1}{x^2(x+1)}=:g(x). \tag{2} $$ See, for instance, https://en.wikipedia.org/wiki/Variation_of_parameters#General_second-order_equation.