Solve the following differential equation: $xy''-\cos(x)y'+\sin(x)y=2$ Solve the following differential equation:
$$xy''-\cos(x)y'+\sin(x)y=2$$

We have that $f_1(x)=x,f_2(x)=-\cos(x),f_3(x)=\sin(x)$
And since $f''_1(x)-f'_2(x)+f_3(x)=0$ so the second order differential equation is exact, hence we should solve:
$$\frac{d}{dx}\left[f_{1}\left(x\right)y'+\left(f_{2}\left(x\right)-f'_{1}\left(x\right)\right)y'\right]=r\left(x\right)$$
Or equivalently $$xy'+\left(-\cos\left(x\right)-1\right)y=2\int_{ }^{ }dx$$
From which we conclude $$y'+\frac{\left(-\cos\left(x\right)-1\right)}{x}y=2+\frac{c_{1}}{x}$$
So $$y=e^{-\int_{ }^{ }\frac{\left(-\cos\left(x\right)-1\right)}{x}dx}\left(\int_{ }^{ }\left(2+\frac{c_{1}}{x}\right)e^{\int_{ }^{ }\frac{\left(-\cos\left(x\right)-1\right)}{x}dx}dx+c_{2}\right)$$
But  $$e^{\int_{ }^{ }\frac{\left(-\cos\left(x\right)-1\right)}{x}dx}$$ doesn't have a closed form, So what should I do?
 A: Recall the fact

Let $$(E): \quad \boxed{f_{1}(x)y''(x)+f_{2}(x)y'(x)+f_{3}(x)y(x)=f_{4}(x)}$$ be a differential equations with $f_{1}f_{2},f_{3},f_{4}\in \mathcal{C}^{+\infty}(\mathbb{R},\mathbb{R})$ we say that $(E)$ is exact equation in second order if $$\boxed{f_{1}''(x)-f_{2}'(x)+f_{3}'(x)=0}.$$
Then we can solve $(E)$ rewriting as $$(f_{1}(x)y'(x))'+(f_{2}(x)y(x))'-(f'(x)y(x))'=f_{4}(x).$$
That is $$\boxed{\frac{{\rm d}}{{\rm d}x}\left(f_{1}(x)y'(x)+(f_{2}(x)-f_{1}'(x))y\right)=f_{4}(x)}$$
Integration over $[1,\tau][$ give
$$\boxed{f_{1}(x)y'(x)+(f_{2}(x)-f_{1}'(x))y=\int_{1}^{\tau}f_{4}(\tau)\, {\rm d}\tau}$$
that is a first-order differential equation.

So, setting $f_{1}(x)=x,f_{2}(x)=-\cos x,f_{3}(x)=\sin x$ and $f_{4}(x)=2$ we have
$$f_{1}''(x)-f_{2}'(x)+f_{3}(x)=0$$
For $x\not=0$ we have so using the fact above for arbitrary constant $c_{1}$ that
$$y'(x)+\frac{-1-\cos x}{x}y(x)=2+\frac{c_{1}}{x}$$
That is a linear first order differential equation with general solution
$$y(x)=xe^{{\rm Ci}(x)}\left(\int_{1}^{x}\frac{e^{-{\rm Ci}(\tau)}(2\tau+c_{1})}{\tau^{2}}\, {\rm d}\tau+c_{2}\right).$$
where ${\rm Ci}(\tau)$ is the cosine integral and the answer above that's the same that your answer with arbitrary constant $c_{1}$ and $c_{2}$,
$$y(x)=e^{-\int \frac{-1-\cos x}{x}\, {\rm d}x}\left(\int \left(2+\frac{c_{1}}{x}\right)e^{-\int \frac{-1-\cos x}{x}\, {\rm d}x}\, {\rm d}x +c_{2}\right).$$
Notice that,
$$e^{-\int \frac{1+\cos x}{x}\, {\rm d}x}=\frac{e^{-{\rm Ci}(x)}}{x} \quad \text{and} \quad e^{\int \frac{1+\cos x}{x}\, {\rm d}x}=\frac{e^{{\rm Ci}(x)}}{x}.$$
