Solve by the method of variation of parameters y'' + 4y =…
Solve by the method of variation of parameters $y'' + 4y = 2\tan x$.
Explanation of Method
With $y_1=\cos2x,\ y_2=\sin2x$ and $W=2$, the double-angle terms in $y^*$ cancel to $-x\cos2x+\sin2x\ln|\cos x|$, which checks against $y''+4y=2\tan x$.
Step 1: Solve the homogeneous equation
\[ r^2+4=0 \implies r=\pm2i, \qquad y_1=\cos 2x,\ \ y_2=\sin 2x. \]
Step 2: Wronskian
\[ W(y_1,y_2) = \begin{vmatrix}\cos2x & \sin2x \\ -2\sin2x & 2\cos2x\end{vmatrix} = 2\cos^22x+2\sin^22x = 2. \]
Step 3: Set up the variation-of-parameters system
Write $y=u_1\cos2x+u_2\sin2x$, with $f(x)=2\tan x$ and $W=2$. By Cramer's rule: \[u_1' = -\frac{y_2f}{W} = -\sin2x\tan x, \qquad u_2' = \frac{y_1f}{W} = \cos2x\tan x.\]
Step 4: Integrate
Using $\sin2x=2\sin x\cos x$: \[u_1 = -\int\sin2x\tan x\,dx = -2\int\sin^2x\,dx = -\int(1-\cos2x)\,dx = -x+\frac{\sin2x}{2}.\]
Using $\cos2x=1-2\sin^2x$ and $2\sin^3x=2\sin x-2\sin x\cos^2x$: \[u_2 = \int\cos2x\tan x\,dx = \int\!\left(-\tan x+2\sin x\cos x\right)dx = \int(-\tan x+\sin2x)\,dx = \ln|\cos x| - \frac{\cos2x}{2}.\]
Step 5: Form and simplify the particular solution
\[ y^* = u_1\cos2x + u_2\sin2x = \left(-x+\frac{\sin2x}{2}\right)\cos2x + \left(\ln|\cos x|-\frac{\cos2x}{2}\right)\sin2x. \]
The two $\tfrac12\sin2x\cos2x$ terms cancel: $y^* = -x\cos2x + \sin2x\ln|\cos x|.$
Step 6: Verify $y^*$
\[ y^{*\prime} = -\cos2x + 2x\sin2x + 2\cos2x\ln|\cos x| - \sin2x\tan x. \]
\[ y^{*\prime\prime} = 4\sin2x + 4x\cos2x - 4\sin2x\ln|\cos x| - 4\cos2x\tan x - \frac{\sin2x}{\cos^2x}. \]
Adding $4y^*$ cancels the $x\cos2x$ and $\ln|\cos x|$ terms: $y^{*\prime\prime}+4y^* = 4\sin2x - 4\cos2x\tan x - \frac{\sin2x}{\cos^2x}.$
Since $\sin2x/\cos^2x = 2\sin x\cos x/\cos^2x = 2\tan x$, and since $\sin2x\cot x = 2\cos^2x = 1+\cos2x$, so that
\[ 4\sin2x-4\cos2x\tan x = 4\tan x(\sin2x\cot x-\cos2x) = 4\tan x\bigl[(1+\cos2x)-\cos2x\bigr] = 4\tan x, \]
the total is
\[ y^{*\prime\prime}+4y^* = 4\tan x - 2\tan x = 2\tan x.\ \checkmark \]
Step 7: General solution
The solution is recorded in the result below.
Result
Final answer:
\[\boxed{\,y = C_1\cos2x + C_2\sin2x - x\cos2x + \sin2x\ln|\cos x|\,}\]
Remark
Domain. Valid on any interval avoiding $x=\pi/2+k\pi$, where $\cos x=0$ and $\tan x$ is undefined.