Suppose we have the differential equation:
$$ \ddot{y} + y = H(x - \pi) - H(x - 2\pi) $$
where $ H(x)$ is the Heaviside step function with initial conditions $ y(0) = \dot{y}(0) = 0 $ as initial conditions, and $ y(x) $ and $ \dot{y}(x) $ are continuous everywhere. I know how to solve this using Laplace Transforms, but I was curious if there are any alternative approaches for solving this and differential equations involving step functions in general.
You could solve the ODE on $(-\infty, \pi)$, $(\pi, 2\pi)$ and $(2\pi,+\infty)$ separately.
This gives you that $$y(x)=\left \{ \begin{array}{ccc} \alpha_0\cos x + \beta_0\sin x && \text{ if } x<\pi\\ \alpha_1\cos x + \beta_1\sin x + 1&& \text{ if } \pi<x<2\pi\\ \alpha_2\cos x + \beta_2\sin x && \text{ if } 2\pi<x\\ \end{array} \right.$$
Once it's done, you can adjust the constants.
From the boundary condition at $0$, you obtain $\alpha_0=\beta_0=0$.
From the fact that $y$ and $\dot y$ are continuous at $\pi$, you get $-\alpha_1+1=0$ and $-\beta_1=0$.
Finally, from the fact that $y$ and $\dot y$ are continuous at $2\pi$, you get $\alpha_1+1=\alpha_2$ and $\beta_1=\beta_2$. So $\alpha_2=2$ and $\beta_2=0$.
Thus $$y(x)=\left \{ \begin{array}{ccc} 0 && \text{ if } x<\pi\\ \cos x + 1&& \text{ if } \pi<x<2\pi\\ 2\cos x && \text{ if } 2\pi<x\\ \end{array} \right.$$ which you can rewrite as $$y(x)= H(x-\pi)(1+\cos x) + 2H(x-2\pi)\cos x$$