Solve the initial value problem $\frac{dy}{dx} + y = f(x) $, where $f(x)=\begin{cases} 2 \quad 0\leq x \lt 1 \\ 0 \quad x\geq1 \end{cases}$, $y(0)=0$. This is a very simple first order ordinary linear differential equation:
$$\frac{dy}{dx} + y = f(x) \tag{A}\label{A}$$, where $f(x)=\begin{cases} 2 \quad 0\leq x \lt 1 \\ 0 \quad x\geq1 \end{cases}$
with initial condition $y(0)=0$
The solutions of this differential equation according to the answer given in the book is:
$y=\begin{cases} 2(1-e^{-x}) \quad 0\leq x \lt 1 \\ 2(e-1)e^{-x} \quad x\geq1 \end{cases} \tag{B}\label{B}$
However I find that answer incorrect and all the solutions of this initial value problem should be given by:
$y=\begin{cases} 2(1-e^{-x}) \quad 0\leq x \lt 1 \\ ce^{-x} \quad x\geq1 \end{cases}$ , where c is an arbitrary real number.
For $0\leq x \lt 1$, we get the solution $$y=2(1-e^{-x}) \tag{i}\label{i}$$
For $x \geq 1$, the initial condition is not valid and we simply get the solution $y=ce^{-x} \tag{ii}\label{ii}$,where $c\in \mathbb R$
This can be verified.
It doesn't matter what real values does c take,  $g(x)=ce^{-x}$ will be a one parameter family of solutions of the given initial value problem since we get an identity on $\mathbb R$ after substituting $g(x)=ce^{-x}$ for y and $g'(x)=-ce^{-x}$ for $\frac{dy}{dx}$ in \eqref{A} when $x\geq1$ (where g is a real function defined on $\mathbb R$)
But the printed answer asserts that only a particular value of c, that is, $c=2e-2 \tag{iii}\label{iii}$ makes \eqref{ii} a solution of \eqref{A}
Now the question came to my mind, why only this special value and where's that coming from? So I deduced that equating the value of y at $x=1$ in \eqref{i} (though we are not supposed to do that unless we are finding $\lim {y}$ as x tends to 1 from left) with y at $x=1$ in \eqref{ii} will lead to \eqref{iii}
That can only mean one thing, we are making the solution function continuous at x=1.
Why are we ensuring the continuity of solution function? As far as continuity is concerned, Is it necessary for every linear first order ordinary differential equation solution to be continuous everywhere?
I have got a counter example against this statement. Consider a differential equation $d(xy)=0$
Which is linear since it can expressed as $xdy +ydx=0$
implies $\frac{dy}{dx} +\frac{y}{x}=0$ (derivative form)
The one parameter family of solutions of this differential equation is given by $xy =k ,k \in \mathbb R$ i.e., $y=\frac{k}{x}$ which is discontinuous at $x=0$ (but $x=0$ is not in domain of definition) so still not sure about this counter example.
There must be some reason for ensuring continuity atleast for this particular differential equation \eqref{A} or at the particular value x=1 since \eqref{B} doesn't seem like a misprint.
Also I remember a similar problem solved using Laplace transformations led to a solution which matches to the solution obtained simply by integrating only after ensuring continuity.
My final question is- Aren't all those solutions of the form $y=ce^{-x}, x\geq1$ lost where c is any real number other than one substituted for ensuring continuity? For example- $y=5e^{-x},x\geq1$ which is indeed an explicit solution of the initial value problem but not a member of solutions given in \eqref{B}.
 A: When solving an ODE, as well as for PDEs, you have to choose what is your notion of solution. In this case, you have that the forcing term $f$ is not continuous. This means that your solution will probably be non-differentiable, meaning that you can't manage to define a notion of solution that satisfies reasonable properties with regular functions. Moreover, if you consider your equation for example in the distributional sense, assuming $y$ to be continuous, it is clear that the derivative of $y$ will not be continuous, as it can be written as $-y+f$ that would have a jump. If you look at the answer of the book, you can check that is continuous, but non differentiable in $t=1$.
What about continuity? In general, you can manage to build a notion of solution to a linear inhomogeneous ODE of the form
$$y'(t)=A(t)y+f(t)$$
if $A(t)$ and $f(t)$ are locally integrable functions in the variable $t$ (you can prove a version of existence and uniqueness theorem using the fixed point theorem) and what you will manage to prove is that your solution will be continuous, actually absolutely continuous (meaning that is a function whose distributional derivative is locally integrable). I can give you more details on this if you want.
Again, if you look at the equation, it is perfectly fine if you assume $y$ continuous, your equation works well in the distributional setting and there is no contradiction (you obtain that the derivative of $y$ is locally integrable, thus $u$ is absolutely continuous).
Of course, the regularity of the solution of the ODE, in general, depends on the regularity of the coefficients or of the forcing term. And this is true for high regularity, but also for low regularity coefficients. For instance, if instead of $f$ you have the Dirac delta, then it doesn't even make sense for the solution $y$ to be continuous. In this case you can manage to work with continuous solutions because $f$ is still reasonable, but not with $C^1$ solutions as $f$ is not continuous.

Edit:
To sum up things and put things in a simpler way, I guess that the main point is that if the forcing term $f(t)$ is regular enough (e.g. continuous) you have solutions that are differentiable with continuous derivative, and that satisfy the equation. I would call that kind of solutions "classical". When $f$ is not continuous, so if it has a jump like in this example, you in general can't hope to have a classical solution, for instance it could be non-differentiable for some $t$ and it could just satisfy the equation for all $t$ except some points.
But for this kind of $f(t)$ we always have existence and uniqueness of a continuous solution of the equation, even if it satisfies it everywhere except in "t=1".
There is, as I said, a strong mathematical reason for this, but I would also try to explain myself from a physical point of view. You could think of this problem as the model of a car that you are driving, $y(t)$ is the position of the car with respect to time, and $f(t)$ is an additional velocity given by the 'gas pedal'. For the times $t$ where $f(t)=0$, the car decelerates by external friction (in this case exponentially, as when $f(t)=0$ the equation becomes $\dot y=-y$ that has exponential-like solutions). Where $f(t)>0$, the velocity changes and the car goes faster. Even if this is not the perfect example, there are instances of problems modeled by ODE where the solution is the trajectory of a body, that must hence be continuous (objects do not teleport), but they might be non continuously differentiable, for instance, the car could break and change velocity instantaneously (in the real world the driver would probably die, but it sort of makes sense physically). As soon as the velocity given by the breaks or by the gas pedal is bounded, then it is reasonable that the car moves with a continuous motion.
From the mathematical point of view, as I said, it also makes sense that $u$ is continuous if $f$ is bounded. Just integrate the equation with respect to time:
$$y(t)=y(0)+\int_0^t (-y(s)+f(s))ds $$
and if you start with continuous $y$, the right hand side is the primitive of a bounded function plus a continuous one, that is continuous (thus you get no contradiction, that we instead found assuming $y$ having continuous derivative).
Let me say that you could do it also for more general $f$. In Mathematical Analysis we also have a weaker notion of solution that is that of "distributional solution", but no problem if you don't know it. The main point is that with that, taking sufficiently non-regular $f$, we could make $y$ behave even worse, even building non-continuous solutions.
This is a more mathematical stuff, but the reason I mentioned it is just to say that continuity has nothing special from the mathematical point of view, and it just makes sense to look for continuous solutions to this ODE by the fact that $f(t)$ is a bounded function (and the car, coming back to the physical point of view, doesn't travel with infinite velocity at some time $t$).
P.s.: I said you have existence and uniqueness even for non-continuous $f$, but i mean, as I said, that this is true when the equation is of the form
$$y'(t)=A(t)\cdot y(t) + f(t),$$
where $y,f:I\to\mathbb{R}^n$, $A:I\to M_{n\times n}(\mathbb{R})$, and $f,A$ are bounded and eventually (it actually just suffices that they have finite integral on every closed time interval if we want to find a minimal hypothesis), but this is not so straightforward for instance for
$$y'(t)=f(y(t)).$$
In that case, if $f$ is not locally lipshitz, we don't have uniqueness of the solution. If f is not continuous we could obtain bad things, think for instance about $f(t)=-$sgn$(t)$.
