
The alpha max plus beta min algorithm is a high-speed approximation of the
square root
In mathematics, a square root of a number is a number such that ; in other words, a number whose ''square'' (the result of multiplying the number by itself, or ⋅ ) is . For example, 4 and −4 are square roots of 16, because .
...
of the sum of two squares. The square root of the sum of two squares, also known as
Pythagorean addition
In mathematics, Pythagorean addition is a binary operation on the real numbers that computes the length of the hypotenuse of a right triangle, given its two sides. According to the Pythagorean theorem, for a triangle with sides a and b, this lengt ...
, is a useful function, because it finds the
hypotenuse
In geometry, a hypotenuse is the longest side of a right-angled triangle, the side opposite the right angle. The length of the hypotenuse can be found using the Pythagorean theorem, which states that the square of the length of the hypotenuse eq ...
of a right triangle given the two side lengths, the
norm
Naturally occurring radioactive materials (NORM) and technologically enhanced naturally occurring radioactive materials (TENORM) consist of materials, usually industrial wastes or by-products enriched with radioactive elements found in the envir ...
of a 2-D
vector
Vector most often refers to:
*Euclidean vector, a quantity with a magnitude and a direction
*Vector (epidemiology), an agent that carries and transmits an infectious pathogen into another living organism
Vector may also refer to:
Mathematic ...
, or the
magnitude
Magnitude may refer to:
Mathematics
*Euclidean vector, a quantity defined by both its magnitude and its direction
*Magnitude (mathematics), the relative size of an object
*Norm (mathematics), a term for the size or length of a vector
*Order of ...
of a
complex number
In mathematics, a complex number is an element of a number system that extends the real numbers with a specific element denoted , called the imaginary unit and satisfying the equation i^= -1; every complex number can be expressed in the for ...
given the
real
Real may refer to:
Currencies
* Brazilian real (R$)
* Central American Republic real
* Mexican real
* Portuguese real
* Spanish real
* Spanish colonial real
Music Albums
* ''Real'' (L'Arc-en-Ciel album) (2000)
* ''Real'' (Bright album) (201 ...
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.
The approximation is expressed as
where
is the maximum absolute value of ''a'' and ''b'', and
is the minimum absolute value of ''a'' and ''b''.
For the closest approximation, the optimum values for
and
are
and
, giving a maximum error of 3.96%.
Improvements
When
,
becomes smaller than
(which is geometrically impossible) near the axes where
is near 0.
This can be remedied by replacing the result with
whenever that is greater, essentially splitting the line into two different segments.
:
Depending on the hardware, this improvement can be almost free.
Using this improvement changes which parameter values are optimal, because they no longer need a close match for the entire interval. A lower
and higher
can therefore increase precision further.
''Increasing precision:'' When splitting the line in two like this one could improve precision even more by replacing the first segment by a better estimate than
, and adjust
and
accordingly.
:
:
:
Beware however, that a non-zero
would require at least one extra addition and some bit-shifts (or a multiplication), probably nearly doubling the cost and, depending on the hardware, possibly defeat the purpose of using an approximation in the first place.
See also
*
Hypot
In mathematics, Pythagorean addition is a binary operation on the real numbers that computes the length of the hypotenuse of a right triangle, given its two sides. According to the Pythagorean theorem, for a triangle with sides a and b, this leng ...
, 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
*{{cite web , title=Extension to three dimensions , date=May 14, 2015 , work=
Stack Exchange
Stack Exchange is a network of question-and-answer (Q&A) websites on topics in diverse fields, each site covering a specific topic, where questions, answers, and users are subject to a reputation award process. The reputation system allows t ...
, url=https://math.stackexchange.com/q/1282435
Approximation algorithms
Root-finding algorithms
Pythagorean theorem