so let's say we have: $f''+4f=\frac{1}{\sin(2x)}$
Homogeneous Problem:
We use Euler-Ansatz: $char(\lambda)=\lambda^2+4 \Rightarrow \lambda=\pm 2i$
So we get
$f_h(x)=\hat{A}e^{2ix}+\hat{B}e^{-2ix}=A\cos(2x)+B\sin(2)$
Particular Problem:
We use variaton of constants. From the homogeneous solution we get the basis $\{\cos(2x),\sin(2x)\}$.
We get [I changed A and B to $u_1$ and $u_2$]
I: $-4u_1\cos(2x)+4u_2\cos(2x)=0$
II:$-4u_1\sin(2x)+4u_2\sin(2x)=\frac{1}{\sin(2x)}$
so:
$\begin{pmatrix}\cos(2x)&\sin(2x)\\-2\sin(x)&2\cos(x)\end{pmatrix}=\begin{pmatrix}u_1\\u_2\end{pmatrix}=\begin{pmatrix}0\\\frac{1}{\sin(2x)}\end{pmatrix}$
whereas the particular solution will be $y_p(x)=U_1\cos(2x) + U_2\sin(2x)$ with $U_i$ being the $u_i$'s integrated.
Question:
Let me also quickly tell you about the idea I have about the whole thing we are doing here. Basicaly, the solution to a ODE is a vector space, so by solving the homogeneous problem, we have a nice vector space. We then only need to somehow adjust that vectorspace s.t. it "works" with the inhomogenity. We can do that by "changign" the coefficients.
What I don't see yet is why we set I=0$ and $II=\frac{1}{\sin(2x)}$.
Could someone please elaborate? Why can't I do $I=\frac{1}{\sin(2x)}, II=\frac{1}{\sin(2x)}$? Could I also do $I=\frac{1}{\sin(2x)}, II=0$?
Consider the function $$ g_a(x)=2f(x)\cos(2x-2a)-f'(x)\sin(2x-2a) $$ then \begin{align} g_a'(x)&=-4f(x)\sin(2x-2a)-f''(x)\sin(2x-2a) \\& =-\frac{\sin(2x-2a)}{\sin(2x)} \\&=-\cos(2a)+\sin(2a)\frac{\cos(2x)}{\sin(2x)} \end{align} which can be integrated to $$ g_a(x)=-\cos(2a)x+\frac12\sin(2a)\ln|\sin(2x)|+C(a) $$ One can relate integration constant to initial conditions with for example $$C(a)=g_a(\frac\pi4)=2f(\frac\pi4)\sin(2a)-f'(\frac\pi4)\cos(2a).$$ Setting $x=a$ and then renaming $a$ to $x$ gives then $$ g_x(x)=2f(x)=-\cos(2x)x+\frac12\sin(2x)\ln|\sin(2x)|+2f(\frac\pi4)\sin(2a)-f'(\frac\pi4)\cos(2a). $$