Time shifted function in differential equation from a control systems problem Suppose we had the following differential equation with zero initial conditions:
 $$\ddot{x}\left(t\right)+2\dot{x}\left(t\right)+x\left(t\right)=0.5u\left(t\right)$$
where $u\left(t\right)$ is given via the following graph:


Analytically  $$u\left(t\right)=2t(h(t)-h(t-1))$$
where $h(t)$ is the Heaviside unit step function.
This leaves us with the following ODE which I intend to solve using the superposition principle along with some other tricks:
$$\ddot{x}\left(t\right)+2\dot{x}\left(t\right)+x\left(t\right)=t(h(t)-h(t-1))$$

Firstly, I considered the differential equation:
$$\ddot{x}\left(t\right)+2\dot{x}\left(t\right)+x\left(t\right)=t(h(t))$$ with zero initial conditions.
It has a solution in the form of:
$$ x_1(t)=(2e^{-t}+te^{-t}+t-2)h(t)$$
The next step is to solve the differential equation$$\ddot{x}\left(t\right)+2\dot{x}\left(t\right)+x\left(t\right)=-t(h(t-1))$$ The initial conditions here ought to be $x(1^-)=x_1(1^-)=0.1036$ and $\dot{x}(1^-)=\dot{x_1}(1^-)=0.264$
Since "we are  starting at $t=1$", the solution for the homogeneous part should be in the form of:
$$x_{2h}=Ae^{-(t-1)}+B(t-1)e^{-(t-1)}$$ and we have one more solution in the form of $$x_{2p}=Ct+D$$
Using the initial conditions for $t=1^-$, I arrive to the solution:
$$x_2(t)=h(t-1)(-0.8964e^{-(t-1)}+0.3676(t-1)e^{-(t-1)}-t+2)$$
With the final solution being $x(t)=x_1(t)+x_2(t)$.
Here it is graphically shown, alongside with the system input as $0.5u(t)$:

I am sure there shouldn't be a discontinuity at $t=1$, from an engineering standpoint, the input suddenly vanishes, but the system gets an additional kick of energy. Makes no sense. I hope someone can point out where I made a mistake, assuming no numerical errors were made.
Either you compute the solution of
$$
L(u)=A+B
$$
as superposition (sum) $u=u_A+u_B$ of the solution of $L(u_A)=A$ and $L(u_B)=B$ 

or

you split the domain into subintervals with "standard" solutions and adapt the constants so that you get a differentiable solution.

Mixing both will result in problems. Since you largely follow the first approach, and the Heaviside functions "switch on" parts of the right side, your initial conditions for the second function should be, to enable a smooth sum, $x_2(1)=0=\dot x_2(1)$ and your full solution is then $x(t)=x_1(t)+x_2(t)$.



To demonstrate how the domain splitting works: First, for $t&lt;0$ the zero initial conditions imply for $L(u)=(\frac d{dt}+1)^2u=0$ the zero solution.

On $0\le0\le 1$ you get $L(u)(t)=t$ which with the trial solution $a+bt$ gives $(2b+a)+bt=2t$ or $b=1$, $a=-2$, thus 
$$
u(t)=(A+Bt)e^{-t}+t-2=(A+Bt)(1-t+O(t^2))+t-2=A-2+(-A+B+1)t+O(t^2)
$$
resulting in $A=2$, $B=1$ for differentiable continuation of the zero solution at $t\le0$.

On the third segment $t\ge 1$ one has again $L(u)=0$ thus
$$
u(t)=(A+Bt)e^{-t},\ u'(t)=(B-A-Bt)e^{-t}
$$
so that at $t=1$
$$
(A+B)e^{-1}=3e^{-1}-1, \ -Ae^{-1}=-2e^{-1}+1
$$
which implies $A=2-e$, $B=1$.

Thus
\begin{align}
u(t)&amp;=\begin{cases}
0&amp;t&lt;0\\
(2+t)e^{-t}+t-2&amp;0\le t\le 1\\
(2-e+t)e^{-t}&amp;1&lt;t
\end{cases}
\\
&amp;=[(2+t)e^{-t}+t-2]h(t)-(e^{1-t}+t-2)h(t-1)
\\
&amp;=[(2+t)e^{-t}h(t)-e^{1-t}h(t-1)+(t-2)(h(t)-h(t-1))
\end{align}
$x_1(t)$ must equal zero for $t\geq1$, which it currently does not. The correct solution could read something like this: 
\begin{equation}
x_1(t)=(2e^{-t}+te^{-t}+t-2)\big(h(t)-h(t-1)\big).
\end{equation}