
Anonymous A. answered 05/22/19
B.S. in phsycis with a minor in pure math
You want to split your differential equation into homogenous and nonhomogenous parts, y=p+q.
The homogenous part is
p''+2p=0
I'm guessing this is the part you were talking about when you said you knew how to solve it. You find non-trivial solutions by assuming p=e^(Ax) and solving for A
The nonhomogenous part is
q''+2q=f(x)
Here, you need to intuitively figure out which value for q will give you f(x) in this equation. For the intervals where f(x)=0, you have q(x)=0 satisfying the equation. For the interval where f(x)=1, you'll see that q(x)=1/2 works out.
Find p and find q, then you get y=p+q