# I am trying to convert a signal into another unit, but the error keeps increasing during each iteration

I have a signal, A, and I want to convert it into another unit by using a formula:

$$s_i = \frac{(1+x_i)}{(1-x_i)}\cdot s_{i-1}$$

where $$x_i$$ is each sample of the signal. I am using a loop where the last value of $$s$$ is stored and used for the next iteration (as the new value of $$P$$). It goes on and on until the last sample of the signal. Signal B is the result of the calculation. However, I noticed that the error keeps increasing during the calculation. As shown in the figure, the red line is how I want the signal to be. • Hi and welcome to Signal Processing SE. Can you post some code so we can recreate the problem? Can you elaborate on the mathematics of your operation? These two alone may already help you figure out the problem, If not, we will be happy to help. – havakok May 23 at 12:20

## 2 Answers

If I understand your notation, you have $$y[n] = \frac{1+x[n]}{1-x[n]}y[n-1]$$, where $$y[n]$$ is the output signal.

This can be rewritten as $$y[n] = y[n-1] + \frac{2x[n]}{1-x[n]}y[n-1]$$. This is an integrator ($$y[n] = y[n-1] + w[n]$$) where $$w[n]$$ is some non-linear function of $$x$$ and $$y$$.

This integrating component is what gives you the drift in output. Note that the small positive offset in your input signal will result in a drift in your output.

If you could explain your application, and why you came up with the original difference equation, maybe some of us could come up with some insights for a solution.

I am not sure which language are you using to implement this. A simple Matlab implementation for a given signal A could be:

s=(1+A)./(1-A);
s(2:end)=s(1:end-1).*s(2:end);
B=s(2:end);


This is If I understand your notation and given that you B signal will be one less sample than your A signal.