## Monday, June 27, 2011

### DSP Trick: Magnitude Estimator

To compute the approximate absolute magnitude of a vector given the real and imaginary parts:

use the alpha max plus beta min algorithm. The approximation is expressed as:

For closest approximation, the use
and

giving a maximum error of 3.96%.

To improve accuracy at the expense of a compare operation, if Min ≤ Max/4, we use the coefficients, α = 1 and β = 0;
otherwise, if Min > Max/4, we use α = 7/8 and β = 1/2.

Division by powers of 2 can be easily done in hardware. Error comparisons for various min/max values:

$\alpha\,\!$ $\beta\,\!$ Largest error (%) Mean error (%)
1/1 1/2 11.80 8.68
1/1 1/4 11.61 0.65
1/1 3/8 6.80 4.01
7/8 7/16 12.5 4.91
15/16 15/32 6.25 1.88
α0 β0 3.96 1.30