Wikipedia / Alpha max plus beta min algorithm
Wikipedia / Alpha max plus beta min algorithm
The alpha max plus beta min algorithm is a high-speed approximation of the square root of the sum of two squares. The square root of the sum of two squares, also known as Pythagorean addition, is a useful function, because it finds the hypotenuse of a right triangle given the two side lengths, the norm of a 2-D vector, or the magnitude of a complex number given the real and imaginary parts.
The algorithm avoids performing the square and square-root operations, instead using simple operations such as comparison, multiplication, and addition. Some choices of the α and β parameters of the algorithm allow the multiplication operation to be reduced to a simple shift of binary digits that is particularly well suited to implementation in high-speed digital circuitry.
Formulation
is the maximum absolute value of a and b is the minimum absolute value of a and b.
are
and
,
giving a maximum error of 3.96%.
Improvements
whenever that is greater, essentially splitting the line into two different segments.
Depending on the hardware, this improvement can be almost free.
can therefore increase precision further.
adjusted accordingly.
requires at least one extra addition and some bit-shifts (or a multiplication), nearly doubling the cost and, depending on the hardware, possibly defeating the purpose of using an approximation in the first place.
See also
Hypot, a precise function or algorithm that is also safe against overflow and underflow.
References
Lyons, Richard G. Understanding Digital Signal Processing, section 13.2. Prentice Hall, 2004 .
Griffin, Grant. DSP Trick: Magnitude Estimator.
External links