Solve $ xf”(x)-xf'(x)+f(x)=2x-x^2 $

ordinary differential equations

Book Differential Equations and Boundary Value Problems (by Charles Henry Edwards and David E Penney) describes that, generally, differential equations with variable coefficients require numerical methods to be solved, obviously there are such equations that have an analytical solution. It is one of them that I want to talk about in my question, here it is:

$$ xf''(x)-xf'(x)+f(x)=2x-x^2 $$

I know that it has an analytical solution because it is in a calculus worksheets, so it shouldn't be too complicated to solve too, but nothing I've tried works (I've tried the method of indeterminate coefficients, variation of constants and by Laplace transform), there is probably something I am missing.

When I look on Wolfram Alpha, it gives me the following answer:

$$ f(x)=c_2\left(x\text{Ei}(x)-e^x\right)+c_1x+x^2 $$

where $\text{Ei}$ is the exponential integral, I am a little surprised that it appears in the solution because it is not a trivial term. I don't know how Wolfram arrives at this solution, but given the head of the original equation, I'm pretty sure there is a simpler solution.

What method should be used to arrive at the general solution of this differential equation?

Best Answer

Whenever you get a multiple of $xf'(x)-f(x)$ in the lower order terms, then $f(x)=x$ is a solution of the homogeneous DE. Now apply the reduction-of-order formula or set for the long way $f(x)=xg(x)$ to reduce the homogeneous equation to $$ x(xg''(x)+2g'(x))-x^2g'(x)=0. $$ This is first-order in $g'$, so that $$ g'(x)=\exp\left(x-2\ln x \right)=\frac{e^x}{x^2}. $$ To this you can apply partial integration once in a useful manner $$ g(x)=-\frac{e^x}{x}+\int\frac{e^x}{x}dx. $$ The last term is the exponential integral (as we look for one basis solution, the integration constants can be set arbitrarily). The second basis function is thus $x·Ei(x)-e^x$

Related Question