<s>[INST] How to simplify solutions for $y'' + 4y = 2 \tan x$? The original equation is $$y'' + 4y = 2 \tan x$$
What I did so far:
$$\lambda^2+4 = 0$$
$$\lambda_1 = -2i \quad \lambda_2 = 2i$$
$$y(x) = C_1\cos2x+C_2\sin2x$$

Write down the system:
$$\begin{cases} C_1'\cos2x + C_2'\sin2x = 0 \\
2C'_2\cos2 x - 2C_1'\sin2x = 2\tan x \end{cases}$$

Applying Krammer's formulas
$$\Delta = \begin{vmatrix}\cos2x & \sin2x \\ 2\cos2x  & -2\sin2x \end{vmatrix} = -2\cos4x$$
$$\Delta_2 = \begin{vmatrix} 0 & \sin2x \\ 2\tan x & -2\sin2x\end{vmatrix} = -2\tan x\sin2x = -4\sin^2x$$
$$\Delta_3 = \begin{vmatrix}\cos2x & 0 \\ 2\cos2x & 2\tan x \end{vmatrix} = -2\cos2x\tan x$$
but when I tried to find solutions I got different expressions which I do not know how to integrate, what is the best way to simplify solutions here to get better integrals?
 [/INST] Mutiply the first equation by $\cos(2x)$ and the second by $\sin(2x)$ and subtract them from each other to get:
$$C_1'\cos^2(2x) + C_2'\cos(2x)\sin(2x) - C_2'\cos(2x)\sin(2x) + C_1'\sin^2(2x) = - \tan(x)\sin(2x)$$
$$C_1' = - 2\frac{\sin x}{\cos x} \cos(x)\sin(x) = - 2\sin^2(x) = \cos(2x) - 1$$
This is easily integrable.
</s>