2.90   ODE No. 90

  1. Problem in Latex
  2. Mathematica input
  3. Maple input

\[ x y'(x)+y(x)-x \sin (x)=0 \] Mathematica : cpu = 0.0163707 (sec), leaf count = 19

\[\left \{\left \{y(x)\to \frac {c_1+\sin (x)-x \cos (x)}{x}\right \}\right \}\]

Maple : cpu = 0.019 (sec), leaf count = 17

\[ \left \{ y \left ( x \right ) ={\frac {\sin \left ( x \right ) -\cos \left ( x \right ) x+{\it \_C1}}{x}} \right \} \]

Hand solution

\[ xy^{\prime }+y=x\sin x \]

Linear first order, exact, separable. \(y^{\prime }+\frac {y}{x}=\sin x\), integrating factor \(\mu =e^{\int \frac {1}{x}dx}=x\), hence\begin {align*} d\left ( \mu y\right ) & =\mu \sin x\\ xy & =\int x\sin xdx+C \end {align*}

Using integration by parts. \(\int udv=uv-\int vdu\). Let \(u=x,dv=\sin x\), hence \(du=1,v=-\cos x\), therefore\begin {align*} \int x\sin xdx & =-x\cos x+\int \cos x\\ & =-x\cos x+\sin x \end {align*}

Hence\begin {align*} xy & =-x\cos x+\sin x+C\\ y & =\frac {\sin x}{x}-\cos x+\frac {C}{x} \end {align*}

Verification

restart; 
ode:=x*diff(y(x),x)+y(x)=x*sin(x); 
my_sol:=sin(x)/x-cos(x)+_C1/x; 
odetest(y(x)=my_sol,ode); 
0