So I'm working with the following differences equation:
$$y_n=\alpha y_{n-1}+(1-\alpha)x_n$$
I know this works with 16-fixed point arithmetic, and given some samples I'm trying to figure out how the operation is working. The data given to me is: ´
$$-13559=23528\times(-23528)+(1-23528)\times 12539$$
So my attempt was to do the multiplications, then shift one bit to the left (to eliminate the repeated sign bit) and then shift 16 bits to the right so that result is kept in Q15.
I obtain: $$-13559=-16893-9002$$
Now the result is divided by 2 to put the result in Q14 (I know this is not needed here but since this needs to be general for any pair of numbers we need to guarantee there is no overflow). So now I get: $$-13559=-12947$$
Which is way off. Any idea about what I might be doing wrong? I can provide more pairs of samples if needed.
Thank you!
EDIT: I was pointed out that my samples might be wrong but I don't think they are I provide here the respective values:
$$\alpha=23528$$
Sequence of values
yn=-32767
xn=0 -> yn=-23528
xn=12539 -> yn=-13359
xn=23170 -> yn=-3060
xn=30273 -> yn=6338
xn=32767 -> yn=13789
EDIT2: Ok so now I seem to be achieving more consistent things. However I still can't achieve the exact values of the samples given. Below are my results:
Sequence of values
yn=-32767
xn=0 -> yn=-23528 -> ynOBTAINED=-23528
xn=12539 -> yn=-13359 -> ynOBTAINED=-13359
xn=23170 -> yn=-3060 -> ynOBTAINED=-3059
xn=30273 -> yn=6338 -> ynOBTAINED=6339
xn=32767 -> yn=13789 -> ynOBTAINED=13790
So it is quite similar but there seems to be an offset. I unfortunately noticed later samples have a deviation of 3 or more so there is something wrong with the way I am computing this.
I've tried two different approaches but with the same results
output_filt=((((output_filt*alpha)<<1)>>16)+(((input_filt*(32767-alpha))<<1)>>16));
OR
output_filt=((output_filt*alpha + input_filt*(32767-alpha))<<1)>>16;
Can someone please help me?