Solve by the method of variation of parameters y'' + y =…
Solve by the method of variation of parameters $y'' + y = \frac{1}{\sin x}$.
Explanation of Method
With $y_1=\cos x,\ y_2=\sin x$ and $W=1$, the particular solution $-x\cos x+\sin x\ln|\sin x|$ checks out exactly against $y''+y=1/\sin x$.
Step 1: Solve the homogeneous equation
\[ r^2+1=0 \implies r=\pm i, \qquad y_1=\cos x,\ \ y_2=\sin x. \]
Step 2: Wronskian
\[ W(y_1,y_2) = \begin{vmatrix}\cos x & \sin x \\ -\sin x & \cos x\end{vmatrix} = \cos^2x+\sin^2x = 1. \]
Step 3: Set up the variation-of-parameters system
Write $y=u_1\cos x+u_2\sin x$, with $f(x)=1/\sin x$ and $W=1$. By Cramer's rule: \[u_1' = -\frac{y_2f}{W} = -\frac{\sin x}{\sin x} = -1, \qquad u_2' = \frac{y_1f}{W} = \frac{\cos x}{\sin x} = \cot x.\]
Step 4: Integrate
\[ u_1 = \int(-1)\,dx = -x, \qquad u_2 = \int\cot x\,dx = \ln|\sin x|. \]
Step 5: Form the particular solution
\[ y^* = u_1\cos x + u_2\sin x = -x\cos x + \sin x\ln|\sin x|. \]
Step 6: Verify $y^*$
\[ y^{*\prime} = -\cos x + x\sin x + \cos x\ln|\sin x| + \cos x = x\sin x + \cos x\ln|\sin x|. \]
\[ y^{*\prime\prime} = \sin x + x\cos x - \sin x\ln|\sin x| + \frac{\cos^2x}{\sin x}. \]
Adding $y^*$ cancels the $x\cos x$ and $\ln|\sin x|$ terms exactly: \[y^{*\prime\prime}+y^* = \sin x + \frac{\cos^2x}{\sin x} = \frac{\sin^2x+\cos^2x}{\sin x} = \frac{1}{\sin x}.\ \checkmark\]
Step 7: General solution
The solution is recorded in the result below.
Result
Final answer:
\[\boxed{\,y = C_1\cos x + C_2\sin x - x\cos x + \sin x\ln|\sin x|\,}\]
Remark
Domain. Valid on any interval avoiding $x=k\pi$, where $\sin x=0$ and the right-hand side is undefined.