<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Alpha_max_plus_beta_min_algorithm</id>
	<title>Alpha max plus beta min algorithm - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Alpha_max_plus_beta_min_algorithm"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Alpha_max_plus_beta_min_algorithm&amp;action=history"/>
	<updated>2026-05-05T01:00:20Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Alpha_max_plus_beta_min_algorithm&amp;diff=3179569&amp;oldid=prev</id>
		<title>imported&gt;Fgnievinski at 19:05, 18 May 2025</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Alpha_max_plus_beta_min_algorithm&amp;diff=3179569&amp;oldid=prev"/>
		<updated>2025-05-18T19:05:39Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{short description|High-speed approximation of the square root of the sum of two squares}}&lt;br /&gt;
{{Distinguish|Minimax|Alpha–beta pruning}}&lt;br /&gt;
&lt;br /&gt;
[[File:AlphaMaxBetaMin.png|thumb|The locus of points that give the same value in the algorithm, for different values of alpha and beta]]&lt;br /&gt;
&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;alpha max plus beta min algorithm&amp;#039;&amp;#039;&amp;#039;&amp;lt;ref&amp;gt;{{Cite journal |last=Assim |first=Ara Abdulsatar Assim |date=2021 |title=ASIC implementation of high-speed vector magnitude &amp;amp; arctangent approximator |journal=Computing, Telecommunication and Control |volume=71 |issue=4 |pages=7–14 |url=https://infocom.spbstu.ru/en/article/2021.71.01/ |language=en |doi=10.18721/JCSTCS.14401}}&amp;lt;/ref&amp;gt; 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 (mathematics)|norm]] of a 2-D [[vector (geometric)|vector]], or the [[magnitude (mathematics)|magnitude]] &amp;lt;math&amp;gt;|z| = \sqrt{a^2 + b^2}&amp;lt;/math&amp;gt; of a [[complex number]] {{math|1=&amp;#039;&amp;#039;z&amp;#039;&amp;#039; = &amp;#039;&amp;#039;a&amp;#039;&amp;#039; + &amp;#039;&amp;#039;bi&amp;#039;&amp;#039;}} given the [[real number|real]] and [[imaginary number|imaginary]] parts.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==Formulation==&lt;br /&gt;
The approximation is expressed as&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;|z| = \alpha\,\mathbf{Max} + \beta\,\mathbf{Min},&amp;lt;/math&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;\mathbf{Max}&amp;lt;/math&amp;gt; is the maximum absolute value of &amp;#039;&amp;#039;a&amp;#039;&amp;#039; and &amp;#039;&amp;#039;b&amp;#039;&amp;#039;, and &amp;lt;math&amp;gt;\mathbf{Min}&amp;lt;/math&amp;gt; is the minimum absolute value of &amp;#039;&amp;#039;a&amp;#039;&amp;#039; and &amp;#039;&amp;#039;b&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
For the closest approximation, the optimum values for &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; are &amp;lt;math&amp;gt;\alpha_0 = \frac{2 \cos \frac{\pi}{8}}{1 + \cos \frac{\pi}{8}} = 0.960433870103...&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\beta_0 = \frac{2 \sin \frac{\pi}{8}}{1 + \cos \frac{\pi}{8}} = 0.397824734759...&amp;lt;/math&amp;gt;, giving a maximum error of 3.96%.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right&amp;quot;&lt;br /&gt;
! &amp;lt;math&amp;gt;\alpha\,\!&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;\beta\,\!&amp;lt;/math&amp;gt; || Largest error (%) || Mean error (%)&lt;br /&gt;
|-&lt;br /&gt;
| 1/1 || 1/2 || 11.80 || 8.68&lt;br /&gt;
|-&lt;br /&gt;
| 1/1 || 1/4 || 11.61 || 3.20&lt;br /&gt;
|-&lt;br /&gt;
| 1/1 || 3/8 || 6.80 || 4.25&lt;br /&gt;
|-&lt;br /&gt;
| 7/8 || 7/16 || 12.50 || 4.91&lt;br /&gt;
|-&lt;br /&gt;
| 15/16 || 15/32 || 6.25 || 3.08&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;\alpha_0&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;\beta_0&amp;lt;/math&amp;gt; || 3.96 || 2.41&lt;br /&gt;
|}&lt;br /&gt;
[[File:Alpha Max Beta Min approximation.png|800px|centre]]&lt;br /&gt;
&lt;br /&gt;
==Improvements==&lt;br /&gt;
When &amp;lt;math&amp;gt;\alpha &amp;lt; 1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;|z|&amp;lt;/math&amp;gt; becomes smaller than &amp;lt;math&amp;gt;\mathbf{Max}&amp;lt;/math&amp;gt; (which is geometrically impossible) near the axes where &amp;lt;math&amp;gt;\mathbf{Min}&amp;lt;/math&amp;gt; is near 0.&lt;br /&gt;
This can be remedied by replacing the result with &amp;lt;math&amp;gt;\mathbf{Max}&amp;lt;/math&amp;gt; whenever that is greater, essentially splitting the line into two different segments.&lt;br /&gt;
&lt;br /&gt;
: &amp;lt;math&amp;gt;|z| = \max(\mathbf{Max}, \alpha\,\mathbf{Max} + \beta\,\mathbf{Min}).&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Depending on the hardware, this improvement can be almost free.&lt;br /&gt;
&lt;br /&gt;
Using this improvement changes which parameter values are optimal, because they no longer need a close match for the entire interval. A lower &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; and higher &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; can therefore increase precision further.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Increasing precision:&amp;#039;&amp;#039; When splitting the line in two like this one could improve precision even more by replacing the first segment by a better estimate than &amp;lt;math&amp;gt;\mathbf{Max}&amp;lt;/math&amp;gt;, and adjust &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; accordingly. &lt;br /&gt;
&lt;br /&gt;
: &amp;lt;math&amp;gt;|z| = \max\big(|z_0|, |z_1|\big),&amp;lt;/math&amp;gt;&lt;br /&gt;
: &amp;lt;math&amp;gt;|z_0| = \alpha_0\,\mathbf{Max} + \beta_0\,\mathbf{Min},&amp;lt;/math&amp;gt;&lt;br /&gt;
: &amp;lt;math&amp;gt;|z_1| = \alpha_1\,\mathbf{Max} + \beta_1\,\mathbf{Min}.&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:right&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! &amp;lt;math&amp;gt;\alpha_0&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;\beta_0&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;\alpha_1&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;\beta_1&amp;lt;/math&amp;gt; || Largest error (%)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 7/8 || 17/32 || −2.65% &lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 29/32 || 61/128 || +2.4%&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 0.898204193266868 || 0.485968200201465 || ±2.12%&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1/8 || 7/8 || 33/64 || −1.7%&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 5/32 || 27/32 || 71/128 || 1.22%&lt;br /&gt;
|-&lt;br /&gt;
| 127/128 || 3/16 || 27/32 || 71/128 || −1.13%  &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Beware however, that a non-zero &amp;lt;math&amp;gt;\beta_0&amp;lt;/math&amp;gt; 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.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[Hypot]], a precise function or algorithm that is also safe against overflow and underflow.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{Reflist}}&lt;br /&gt;
*[[Richard G. Lyons|Lyons, Richard G]]. &amp;#039;&amp;#039;Understanding Digital Signal Processing, section 13.2.&amp;#039;&amp;#039; Prentice Hall, 2004 {{ISBN|0-13-108989-7}}.&lt;br /&gt;
*Griffin, Grant. [http://www.dspguru.com/dsp/tricks/magnitude-estimator DSP Trick: Magnitude Estimator].&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
*{{cite web |title=Extension to three dimensions |date=May 14, 2015 |work=[[Stack Exchange]] |url=https://math.stackexchange.com/q/1282435 }}&lt;br /&gt;
&lt;br /&gt;
[[Category:Approximation algorithms]]&lt;br /&gt;
[[Category:Root-finding algorithms]]&lt;br /&gt;
[[Category:Pythagorean theorem]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Fgnievinski</name></author>
	</entry>
</feed>