In class we solved y' +2y = g(x) where g(x) was a peicewise constant function; it is plotted below.
> plot(piecewise( x<0, 0, 0<=x and x<=1, 1, 1<x, 0), x=-3..3,y=-1..2,thickness=3, discont=true);
We can use dsolve in Maple to find the solution when y(0)=0 is the given initial condition.
> dsolve({diff(y(x),x)+2*y(x)=piecewise(x<0, 0, 0<=x and x<=1, 1, 1<x, 0),y(0)=0});
Notice that the form of the answer is a bit awkward. We simplify it by inspection and graph it below.
> plot(piecewise(x<0,0,0<=x and x<=1, -1/2*exp(-2*x)+1/2, 1<x, -1/2*exp(-2*x)+1/2*exp(-2*x+2)), x=-1..3,y=0..1,thickness=3, color=blue);
>
>