Forward and Backward Filtering (MATLAB's `filtfilt()`) I have an input sequence $x(n)$ and impulse sequence 

\begin{equation}
h(n) = \begin{cases} 0 &amp; \quad \text{when } n = 0 \\ .239052 &amp; \quad \text{when } n = 1 \\1.3357\exp(-0.650286n) &amp; \quad \text{when } n &gt; 1\\ \end{cases}
\end{equation}

I did a convolution and obtained $y(n)=x(n)*h(n)$. I trimmed some of the data  in the end from $y(n)$ and then I flipped $h(n)$ and I did reverse filtering $w(n)=y(n)*h(-n)$.
When I researched about this I found filtfilt in matlab is an easier option but I am trying to implement this in C.
So my question is without trimming the first output sequence  $y(n)$ I am getting a drifted version of the result (there is a delay). 

Is it trimming really necessary or am I doing something wrong here.
One more question is I can see some transients both at the start and end  of $w(n)$ sequence when I use filtfilt I don't see that transients.The reason is matlab is using some initial states based on the below paper to get rid of the transients. 

Gustafsson, F. "Determining the initial states in forward-backward filtering." IEEE® Transactions on Signal Processing. Vol. 44, April 1996, pp. 988–992.  

To summarize :


Is it trimming really necessary ?
PS the figure attached without trimming the the resultant data has a lag..Trimming the $y(n)$ sequence before backward filtering aligns the result.
how to determine the initial states for getting rid of transients.
My opinion is that the trimming isn't necessary.  

The method in the paper is based on a simple idea, if we filter the signal $ x [n] $ forward and then backward, the result should be equal to the result of doing it backward and then forward.

The paper shows how to chose the initial conditions which minimize the $ {\ell}_{2} $ norm between the the different approaches.