The partial fraction expression for \(Y(s)\) has the form
\begin{equation*}
Y(s) = \frac{D}{s}+\frac{C_1}{s+1}+\frac{C_2}{(s+1)^2} + \frac{2A(s-0) - 2B(1)}{(s-0)^2+1^2}\text{.}
\end{equation*}
Since the linear factor \(s\) is nonrepeated, we have
\begin{equation*}
D = \mathrm{Res}[Y(s),0] = \lim_{s \to 0} \frac{s^3+3s^2-s+1}{(s+1)^2(s^2+1)} = 1\text{.}
\end{equation*}
Since the factor \(s+1\) is repeated, we have
\begin{align*}
C_1 \amp = \mathrm{Res}[Y(s),-1]\\
\amp = \lim_{s\to -1}\frac{d}{ds}\left(\frac{s^3+3s^2-s+1}{s(s^2+1)}\right)\\
\amp = \lim_{s \to -1}\frac{-3s^4+4s^3-1}{s^2(s+1)^2}\\
\amp = -2;\\
C_2 \amp =\mathrm{Res}[(s+1) Y(s) ,-1]\\
\amp =\lim\limits_{s \to -1}\frac{s^3+3s^2-s+1}{s(s^2+1)}\\
\amp =-2\text{.}
\end{align*}
The term \(s^2+1\) is an irreducible quadratic, with roots \(\pm i\text{,}\) so that
\begin{equation*}
A+iB = \mathrm{Res}[Y,i] =\lim\limits_{s \to i}\frac{s^3+3s^2-s+1}{s(s+1)^2(s+i)} = \frac{1-i}{2}\text{,}
\end{equation*}
and we obtain \(A=\frac{1}{2}\) and \(B=-\frac{1}{2}\text{.}\) Therefore,
\begin{align*}
Y(s) \amp = \frac{1}{s}+\frac{-2}{s+1}+\frac{-2}{(s+1)^2} + \frac{2\frac{1}{2}(s-0)-2(-\frac{1}{2})(1)}{(s-0)^2+1^2}\\
\amp = \frac{1}{s} - \frac{2}{s+1} - \frac{2}{(s+1)^2} + \frac{s+1}{s^2+1}\text{.}
\end{align*}
\begin{equation*}
y(t) = 1-2e^{-t}-2te^{-t} + \cos t + \sin t
\end{equation*}