Let \( y(x) \) be the solution of the differential equation \( \frac{dy}{dx} + y = f(x) \), for \( x \geq 0, y(0) = 0 \), where
\[ f(x) = \begin{cases} 2, & 0 \leq x < 1 \\ 0, & x \geq 1 \end{cases} \] Then \( y(x) \) is
\( 2(1 - e^{-x}) \) when \( 0 \leq x < 1 \) and \( 2(e - 1)e^{-x} \) when \( x \geq 1 \)
\( 2(1 - e^{-x}) \) when \( 0 \leq x < 1 \) and \( 2e^{1-x} \) when \( x \geq 1 \)
Given differential equation: $$\frac{dy}{dx} + y = f(x), \quad y(0) = 0$$
where $$f(x) = \begin{cases} 2, & 0 \leq x < 1 \ 0, & x \geq 1 \end{cases}$$
The differential equation is: $$\frac{dy}{dx} + y = 2$$
This is a first-order linear ODE. The integrating factor is: $$\mu(x) = e^{\int 1 , dx} = e^x$$
Multiplying both sides by $e^x$: $$e^x \frac{dy}{dx} + e^x y = 2e^x$$
$$\frac{d}{dx}(e^x y) = 2e^x$$
Integrating: $$e^x y = 2e^x + C_1$$
$$y = 2 + C_1 e^{-x}$$
Using the initial condition $y(0) = 0$: $$0 = 2 + C_1 e^0 = 2 + C_1$$ $$C_1 = -2$$
Therefore, for $0 \leq x < 1$: $$y(x) = 2 - 2e^{-x} = 2(1 - e^{-x})$$
For $x \geq 1$, the differential equation becomes: $$\frac{dy}{dx} + y = 0$$
The general solution is: $$y = C_2 e^{-x}$$
To find $C_2$, we use continuity at $x = 1$. From Case 1: $$y(1^-) = 2(1 - e^{-1}) = 2(1 - e^{-1})$$
For continuity at $x = 1$: $$y(1) = C_2 e^{-1} = 2(1 - e^{-1})$$
$$C_2 = 2(1 - e^{-1}) \cdot e^1 = 2(e - 1)$$
Therefore, for $x \geq 1$: $$y(x) = 2(e - 1)e^{-x}$$
$$y(x) = \begin{cases} 2(1 - e^{-x}), & 0 \leq x < 1 \ 2(e - 1)e^{-x}, & x \geq 1 \end{cases}$$
Answer: (A)