Solve the piecewise linear ODE, y' - y = f(x), y(0) = 1, where f(x) = 1 when 0 \le x \le 1 and f(x) = -1 when x > 1. What is y(2)? Round to the nearest tenth.

I stated and got

y'-y= ce^x , but wasn't really sure if that was right so I didn't know where to go from there.

1 answer

y'-y = 1: y = ce^x - 1 for 0<=x<=1
y'-y = -1: y = ce^x + 1 for x>1

y(0) = 1 means c=2, so
y = 2e^x - 1 for 0<=x<=1

If we want y to be continuous, then since y(1) = 2e-1,
y = (2 - 2/e)e^x + 1 for x>1
Thus,
y(2) = (2 - 2/e)e^2 + 1 = 2e^2-2e+1