The locus of points that give the same value in the algorithm, for different values of alpha and beta

The alpha max plus beta min algorithm[1] 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 z = a + bi 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

edit

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%.

Largest error (%) Mean error (%)
1/1 1/2 11.80 8.68
1/1 1/4 11.61 3.20
1/1 3/8 6.80 4.25
7/8 7/16 12.50 4.91
15/16 15/32 6.25 3.08
3.96 2.41

Improvements

edit

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.

This can be improved even further by, instead of using as the second estimate, use a second pair of parameters and , with and adjusted accordingly.

Largest error (%)
1 0 7/8 17/32 −2.66%
1 0 29/32 61/128 +2.40%
1 0 0.898204193266868 0.485968200201465 ±2.12%
1 1/8 7/8 33/64 −1.67%
1 5/32 27/32 71/128 +1.21%
127/128 3/16 27/32 71/128 −1.12%

Of course, a non-zero 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

edit
  • Hypot, a precise function or algorithm that is also safe against overflow and underflow.

References

edit
  1. ^ Assim, Ara Abdulsatar Assim (2021). "ASIC implementation of high-speed vector magnitude & arctangent approximator". Computing, Telecommunication and Control. 71 (4): 7–14. doi:10.18721/JCSTCS.14401.
edit

📚 Artikel Terkait di Wikipedia

Alpha max

algorithm Alpha max plus beta min algorithm AlphaMax Academy (founded 1998) a private international school in Suriname Search for "alphamax" , "alpha

List of algorithms

Spigot algorithm: a way to compute the value of a mathematical constant without knowing preceding digits Square and Nth root of a number: Alpha max plus beta

Beta distribution

{6\left[(\alpha -\beta )^{2}(\alpha +\beta +1)-\alpha \beta (\alpha +\beta +2)\right]}{\alpha \beta (\alpha +\beta +2)(\alpha +\beta +3)}}} The mode of a beta distributed

Square root algorithms

the non-negative real part. Integer square root Alpha max plus beta min algorithm nth root algorithm Fast inverse square root The factors two and six

List of numerical analysis topics

roots nth root algorithm hypot — the function (x2 + y2)1/2 Alpha max plus beta min algorithm — approximates hypot(x,y) Fast inverse square root — calculates

Pythagorean addition

also developed analogous algorithms for computing Pythagorean sums of more than two values. The alpha max plus beta min algorithm is a high-speed approximation

Graph cut optimization

x ) ≤ 2 max α ≠ β ∈ Λ S ( α , β ) min α ≠ β ∈ Λ S ( α , β ) f ( x ∗ ) . {\displaystyle f(\mathbf {x} )\leq 2{\frac {\max _{\alpha \neq \beta \in \Lambda

Binomial distribution

p ) β − 1 Beta ⁡ ( α , β ) . {\displaystyle P(p;\alpha ,\beta )={\frac {p^{\alpha -1}(1-p)^{\beta -1}}{\operatorname {Beta} (\alpha ,\beta )}}.} Given