Differential equations (second edition) - William E. Boyce & Richard C. Diprima (#$31$, page $142$) 
In many physical problems, non-homogeneous term may differ from one
  time interval to another. By example, determine the solution $y =  \phi(t)$ at 
$$y'' + y =  \begin{cases} 
     t      & \quad \text{if } 0 \leq t \leq \pi \\
    \pi e^{\pi - t}  & \quad \text{if } t > \pi \\   \end{cases} $$ with the initial contitions $y(0) = 0$ and $y'(0)=1$
Suppose also that $y$ and $y'$ are continuous at $t = \pi$. Hint :
  First, resolve the problem at initial value for $t \leq \pi$. After,
  resolve for $t > \pi$ in determining the constantes of the last
  solution and in supposing the continuity at $t = \pi$

I obtain as solution 
$$y(t) =  \begin{cases} 
    t      & \quad \text{if } 0 \leq t \leq \pi \\
    \pi e^{\pi - t}  & \quad \text{if } t > \pi \\   \end{cases} $$
but the solution of the book is 
$$y(t) =  \begin{cases} 
    t      & \quad \text{if } 0 \leq t \leq \pi \\
   -(1+\frac{\pi}{2}) \sin(t) - (\frac{\pi}{2}) \cos(t) + \frac{\pi}{2} e^{\pi - t}  & \quad \text{if } t > \pi \\   \end{cases} $$
I'm trying for quite a while to resolve my problem, but without result. Does someone could explain to me how could I correct my solution?
This is the exercise #$28$, page $178$ of this link.
 A: By the characteristic equation, we get the general solution
$$y_c=c_1\cos t+c_2\sin t$$
For the first part, we try the particular solution
$$y_p=At+B$$
Since you got your first part correctly, I think you know how to get 
$$y=t, 0\leq t\leq \pi$$
Now for the second interval, you still have the general solution
$$y_c=c_1\cos t+c_2\sin t$$
For the particular solution, since right hand side is $\pi e^{\pi} e^{-t}$, we try $Ae^{-t}$:
$$y_p=Ae^{-t}$$
This gives 
$$y_p''=Ae^{-t}$$
Plugging these into the second part of the differential equation gives us
$$y_p''+y_p=2Ae^{-t}=\pi e^{\pi-t}$$
So $A=\frac{\pi}{2}e^{\pi}$.
Now we still don't know what are $c_1$ and $c_2$. Since $y$ and $y'$ have to be continuous at $\pi$, we set $y(\pi)=\pi$, and $y'(\pi)=1$ for
$$y=c_1\cos t+c_2\sin t+\frac{\pi}{2}e^{\pi-t}$$
which you can see easily comes from the first part of the solution. This will give us the desired solution.
A: The homogeneous part of the equation has the solution
$$
A\sin t+B\cos t
$$
Let's use operator method to find particular solution and then the complete solution.

$0\le t\le\pi$

$$
{1\over D^2+1}t=(1-D^2+D^4-\cdots)t=t\\
$$
In this case $y(0)=0$ yields $B=0$ and then $y'(0)=1$ yields $A=0$. So the complete solution is $$y=t$$

$t>\pi$

$$
{1\over D^2+1}\pi e^{\pi-t}=\pi e^{\pi-t}{1\over(-1)^2+1}={\pi\over2}e^{\pi-t}
$$
Using the continuity of $y,y'$ we have $y(\pi)=\pi,y'(\pi)=1$. Here $y(\pi)=\pi$ yields $B={\pi\over2}$ and then $y'(\pi)=1$ yields $A=-(1+{\pi\over2})$. So the complete solution is
$$
y=-(1+{\pi\over2})\sin t+{\pi\over2}\cos t+{\pi\over2}e^{\pi-t}
$$
A: Your solution is wrong because 


*

*It is not a solution of the differential equation. It's always a good idea to check your solution by plugging it in to the differential equation and seeing if the two sides are equal.

*Its derivative is not continuous at $t=\pi$.

