# fixed point – Computer arithmetic algorithm: what might I be doing wrong?

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=23528times(-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

Posted on Categories Articles