
In
mathematics
Mathematics is a field of study that discovers and organizes methods, Mathematical theory, theories and theorems that are developed and Mathematical proof, proved for the needs of empirical sciences and mathematics itself. There are many ar ...
, Pythagorean addition is a
binary operation
In mathematics, a binary operation or dyadic operation is a rule for combining two elements (called operands) to produce another element. More formally, a binary operation is an operation of arity two.
More specifically, a binary operation ...
on the
real number
In mathematics, a real number is a number that can be used to measure a continuous one- dimensional quantity such as a duration or temperature. Here, ''continuous'' means that pairs of values can have arbitrarily small differences. Every re ...
s that computes the length of the
hypotenuse
In geometry, a hypotenuse is the side of a right triangle opposite to the right angle. It is the longest side of any such triangle; the two other shorter sides of such a triangle are called '' catheti'' or ''legs''. Every rectangle can be divided ...
of a
right triangle
A right triangle or right-angled triangle, sometimes called an orthogonal triangle or rectangular triangle, is a triangle in which two sides are perpendicular, forming a right angle ( turn or 90 degrees).
The side opposite to the right angle i ...
, given its two sides. Like the more familiar addition and multiplication operations of
arithmetic
Arithmetic is an elementary branch of mathematics that deals with numerical operations like addition, subtraction, multiplication, and division. In a wider sense, it also includes exponentiation, extraction of roots, and taking logarithms.
...
, it is both
associative
In mathematics, the associative property is a property of some binary operations that rearranging the parentheses in an expression will not change the result. In propositional logic, associativity is a valid rule of replacement for express ...
and
commutative
In mathematics, a binary operation is commutative if changing the order of the operands does not change the result. It is a fundamental property of many binary operations, and many mathematical proofs depend on it. Perhaps most familiar as a pr ...
.
This operation can be used in the conversion of
Cartesian coordinates
In geometry, a Cartesian coordinate system (, ) in a plane is a coordinate system that specifies each point uniquely by a pair of real numbers called ''coordinates'', which are the signed distances to the point from two fixed perpendicular o ...
to
polar coordinates
In mathematics, the polar coordinate system specifies a given point (mathematics), point in a plane (mathematics), plane by using a distance and an angle as its two coordinate system, coordinates. These are
*the point's distance from a reference ...
, and in the calculation of
Euclidean distance
In mathematics, the Euclidean distance between two points in Euclidean space is the length of the line segment between them. It can be calculated from the Cartesian coordinates of the points using the Pythagorean theorem, and therefore is o ...
. It also provides a simple notation and terminology for the
diameter
In geometry, a diameter of a circle is any straight line segment that passes through the centre of the circle and whose endpoints lie on the circle. It can also be defined as the longest Chord (geometry), chord of the circle. Both definitions a ...
of a
cuboid
In geometry, a cuboid is a hexahedron with quadrilateral faces, meaning it is a polyhedron with six Face (geometry), faces; it has eight Vertex (geometry), vertices and twelve Edge (geometry), edges. A ''rectangular cuboid'' (sometimes also calle ...
, the
energy-momentum relation in
physics
Physics is the scientific study of matter, its Elementary particle, fundamental constituents, its motion and behavior through space and time, and the related entities of energy and force. "Physical science is that department of knowledge whi ...
, and the overall noise from independent sources of noise. In its applications to
signal processing
Signal processing is an electrical engineering subfield that focuses on analyzing, modifying and synthesizing ''signals'', such as audio signal processing, sound, image processing, images, Scalar potential, potential fields, Seismic tomograph ...
and
propagation of
measurement uncertainty
In metrology, measurement uncertainty is the expression of the statistical dispersion of the values attributed to a quantity measured on an interval or ratio scale.
All measurements are subject to uncertainty and a measurement result is complet ...
, the same operation is also called addition in quadrature. A scaled version of this operation gives the
quadratic mean
In mathematics, the root mean square (abbrev. RMS, or rms) of a set of values is the square root of the set's mean square.
Given a set x_i, its RMS is denoted as either x_\mathrm or \mathrm_x. The RMS is also known as the quadratic mean (denoted M ...
or ''root mean square''.
It is implemented in many programming libraries as the hypot function, in a way designed to avoid errors arising due to limited-precision calculations performed on computers.
Donald Knuth
Donald Ervin Knuth ( ; born January 10, 1938) is an American computer scientist and mathematician. He is a professor emeritus at Stanford University. He is the 1974 recipient of the ACM Turing Award, informally considered the Nobel Prize of comp ...
has written that "Most of the square root operations in computer programs could probably be avoided if
ythagorean additionwere more widely available, because people seem to want square roots primarily when they are computing distances."
Definition
According to the
Pythagorean theorem
In mathematics, the Pythagorean theorem or Pythagoras' theorem is a fundamental relation in Euclidean geometry between the three sides of a right triangle. It states that the area of the square whose side is the hypotenuse (the side opposite t ...
, for a
right triangle
A right triangle or right-angled triangle, sometimes called an orthogonal triangle or rectangular triangle, is a triangle in which two sides are perpendicular, forming a right angle ( turn or 90 degrees).
The side opposite to the right angle i ...
with side lengths
and
, the length of the
hypotenuse
In geometry, a hypotenuse is the side of a right triangle opposite to the right angle. It is the longest side of any such triangle; the two other shorter sides of such a triangle are called '' catheti'' or ''legs''. Every rectangle can be divided ...
can be calculated as
This formula defines the Pythagorean addition operation, denoted here as
: for any two
real number
In mathematics, a real number is a number that can be used to measure a continuous one- dimensional quantity such as a duration or temperature. Here, ''continuous'' means that pairs of values can have arbitrarily small differences. Every re ...
s
and
, the result of this operation is defined to be
For instance, the
special right triangle based on the
Pythagorean triple
A Pythagorean triple consists of three positive integers , , and , such that . Such a triple is commonly written , a well-known example is . If is a Pythagorean triple, then so is for any positive integer . A triangle whose side lengths are a Py ...
gives
.
[This example is from . uses two more integer Pythagorean triples, (119,120,169) and (19,180,181), as examples.] However, the
integer
An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
result of this example is unusual: for other integer arguments, Pythagorean addition can produce a
quadratic irrational number
In mathematics, a quadratic irrational number (also known as a quadratic irrational or quadratic surd) is an irrational number that is the solution to some quadratic equation with rational coefficients which is irreducible over the rational number ...
as its result.
Properties
The operation
is
associative
In mathematics, the associative property is a property of some binary operations that rearranging the parentheses in an expression will not change the result. In propositional logic, associativity is a valid rule of replacement for express ...
and
commutative
In mathematics, a binary operation is commutative if changing the order of the operands does not change the result. It is a fundamental property of many binary operations, and many mathematical proofs depend on it. Perhaps most familiar as a pr ...
. Therefore, if three or more numbers are to be combined with this operation, the order of combination makes no difference to the result:
Additionally, on the non-negative real numbers, zero is an
identity element
In mathematics, an identity element or neutral element of a binary operation is an element that leaves unchanged every element when the operation is applied. For example, 0 is an identity element of the addition of real numbers. This concept is use ...
for Pythagorean addition. On numbers that can be negative, the Pythagorean sum with zero gives the
absolute value
In mathematics, the absolute value or modulus of a real number x, is the non-negative value without regard to its sign. Namely, , x, =x if x is a positive number, and , x, =-x if x is negative (in which case negating x makes -x positive), ...
:
The three properties of associativity, commutativity, and having an identity element (on the non-negative numbers) are the defining properties of a
commutative monoid
In abstract algebra, a monoid is a set equipped with an associative binary operation and an identity element. For example, the nonnegative integers with addition form a monoid, the identity element being .
Monoids are semigroups with identity ...
.
Applications
Distance and diameter
The
Euclidean distance
In mathematics, the Euclidean distance between two points in Euclidean space is the length of the line segment between them. It can be calculated from the Cartesian coordinates of the points using the Pythagorean theorem, and therefore is o ...
between two points in the
Euclidean plane
In mathematics, a Euclidean plane is a Euclidean space of Two-dimensional space, dimension two, denoted \textbf^2 or \mathbb^2. It is a geometric space in which two real numbers are required to determine the position (geometry), position of eac ...
, given by their
Cartesian coordinates
In geometry, a Cartesian coordinate system (, ) in a plane is a coordinate system that specifies each point uniquely by a pair of real numbers called ''coordinates'', which are the signed distances to the point from two fixed perpendicular o ...
and
, is
In the same way, the distance between three-dimensional points
and
can be found by repeated Pythagorean addition as
Pythagorean addition can also find the length of an interior
diagonal
In geometry, a diagonal is a line segment joining two vertices of a polygon or polyhedron, when those vertices are not on the same edge. Informally, any sloping line is called diagonal. The word ''diagonal'' derives from the ancient Greek � ...
of a
rectangle
In Euclidean geometry, Euclidean plane geometry, a rectangle is a Rectilinear polygon, rectilinear convex polygon or a quadrilateral with four right angles. It can also be defined as: an equiangular quadrilateral, since equiangular means that a ...
or
rectangular cuboid
A rectangular cuboid is a special case of a cuboid with rectangular faces in which all of its dihedral angles are right angles. This shape is also called rectangular parallelepiped or orthogonal parallelepiped.
Many writers just call these ...
. For a rectangle with sides
and
, the diagonal length is
. For a cuboid with side lengths
,
, and
, the length of a
body diagonal
In geometry, a space diagonal (also interior diagonal or body diagonal) of a polyhedron is a line connecting two vertices that are not on the same face. Space diagonals contrast with '' face diagonals'', which connect vertices on the same face (b ...
is
.
Coordinate conversion
Pythagorean addition (and its implementation as the
hypot
function) is often used together with the
atan2
In computing and mathematics, the function (mathematics), function atan2 is the 2-Argument of a function, argument arctangent. By definition, \theta = \operatorname(y, x) is the angle measure (in radians, with -\pi 0, \\ mu \arctan\left(\fr ...
function (a two-parameter form of the
arctangent
In mathematics, the inverse trigonometric functions (occasionally also called ''antitrigonometric'', ''cyclometric'', or ''arcus'' functions) are the inverse functions of the trigonometric functions, under suitably restricted domains. Specific ...
) to convert from
Cartesian coordinates
In geometry, a Cartesian coordinate system (, ) in a plane is a coordinate system that specifies each point uniquely by a pair of real numbers called ''coordinates'', which are the signed distances to the point from two fixed perpendicular o ...
to
polar coordinates
In mathematics, the polar coordinate system specifies a given point (mathematics), point in a plane (mathematics), plane by using a distance and an angle as its two coordinate system, coordinates. These are
*the point's distance from a reference ...
:
Quadratic mean and spread of deviation
The
root mean square
In mathematics, the root mean square (abbrev. RMS, or rms) of a set of values is the square root of the set's mean square.
Given a set x_i, its RMS is denoted as either x_\mathrm or \mathrm_x. The RMS is also known as the quadratic mean (denote ...
or quadratic mean of a
finite set
In mathematics, particularly set theory, a finite set is a set that has a finite number of elements. Informally, a finite set is a set which one could in principle count and finish counting. For example,
is a finite set with five elements. Th ...
of
numbers is
times their Pythagorean sum. This is a
generalized mean
In mathematics, generalised means (or power mean or Hölder mean from Otto Hölder) are a family of functions for aggregating sets of numbers. These include as special cases the Pythagorean means (arithmetic mean, arithmetic, geometric mean, ge ...
of the numbers.
The
standard deviation
In statistics, the standard deviation is a measure of the amount of variation of the values of a variable about its Expected value, mean. A low standard Deviation (statistics), deviation indicates that the values tend to be close to the mean ( ...
of a collection of observations is the quadratic mean of their individual deviations from the mean. When two or more independent random variables are added, the standard deviation of their sum is the Pythagorean sum of their standard deviations. Thus, the Pythagorean sum itself can be interpreted as giving the amount of overall noise when combining independent sources of noise.
If the
engineering tolerance
Engineering tolerance is the permissible limit or limits of variation in:
# a physical dimension;
# a measured value or physical property of a material, manufactured object, system, or service;
# other measured values (such as temperature, hum ...
s of different parts of an assembly are treated as independent noise, they can be combined using a Pythagorean sum. In
experimental science
An experiment is a procedure carried out to support or refute a hypothesis, or determine the efficacy or likelihood of something previously untried. Experiments provide insight into cause-and-effect by demonstrating what outcome occurs when ...
s such as
physics
Physics is the scientific study of matter, its Elementary particle, fundamental constituents, its motion and behavior through space and time, and the related entities of energy and force. "Physical science is that department of knowledge whi ...
, addition in quadrature is often used to combine different sources of
measurement uncertainty
In metrology, measurement uncertainty is the expression of the statistical dispersion of the values attributed to a quantity measured on an interval or ratio scale.
All measurements are subject to uncertainty and a measurement result is complet ...
. However, this method of
propagation of uncertainty
In statistics, propagation of uncertainty (or propagation of error) is the effect of variables' uncertainties (or errors, more specifically random errors) on the uncertainty of a function based on them. When the variables are the values of ex ...
applies only when there is no correlation between sources of uncertainty, and it has been criticized for conflating experimental noise with
systematic error
Observational error (or measurement error) is the difference between a measurement, measured value of a physical quantity, quantity and its unknown true value.Dodge, Y. (2003) ''The Oxford Dictionary of Statistical Terms'', OUP. Such errors are ...
s.
Other

The
energy-momentum relation in
physics
Physics is the scientific study of matter, its Elementary particle, fundamental constituents, its motion and behavior through space and time, and the related entities of energy and force. "Physical science is that department of knowledge whi ...
, describing the energy of a moving particle, can be expressed as the Pythagorean sum
where
is the
rest mass
The invariant mass, rest mass, intrinsic mass, proper mass, or in the case of bound systems simply mass, is the portion of the total mass of an object or system of objects that is independent of the overall motion of the system. More precisely, ...
of a particle,
is its
momentum
In Newtonian mechanics, momentum (: momenta or momentums; more specifically linear momentum or translational momentum) is the product of the mass and velocity of an object. It is a vector quantity, possessing a magnitude and a direction. ...
,
is the
speed of light
The speed of light in vacuum, commonly denoted , is a universal physical constant exactly equal to ). It is exact because, by international agreement, a metre is defined as the length of the path travelled by light in vacuum during a time i ...
, and
is the particle's resulting
relativistic energy.
When combining signals, it can be a useful design technique to arrange for the combined signals to be
orthogonal
In mathematics, orthogonality (mathematics), orthogonality is the generalization of the geometric notion of ''perpendicularity''. Although many authors use the two terms ''perpendicular'' and ''orthogonal'' interchangeably, the term ''perpendic ...
in
polarization or
phase
Phase or phases may refer to:
Science
*State of matter, or phase, one of the distinct forms in which matter can exist
*Phase (matter), a region of space throughout which all physical properties are essentially uniform
*Phase space, a mathematica ...
, so that they add in quadrature. In early
radio engineering
Broadcast engineering or radio engineering is the field of electrical engineering, and now to some extent computer engineering and information technology, which deals with radio and television broadcasting. Audio engineering and RF engineering ...
, this idea was used to design
directional antenna
A directional antenna or beam antenna is an antenna that radiates or receives greater radio wave power in specific directions. Directional antennas can radiate radio waves in beams, when greater concentration of radiation in a certain directio ...
s, allowing signals to be received while nullifying the interference from signals coming from other directions. When the same technique is applied in software to obtain a directional signal from a radio or
ultrasound
Ultrasound is sound with frequency, frequencies greater than 20 Hertz, kilohertz. This frequency is the approximate upper audible hearing range, limit of human hearing in healthy young adults. The physical principles of acoustic waves apply ...
phased array
In antenna (radio), antenna theory, a phased array usually means an electronically scanned array, a computer-controlled Antenna array, array of antennas which creates a radio beam, beam of radio waves that can be electronically steered to point ...
, Pythagorean addition may be used to combine the signals. Other recent applications of this idea include improved efficiency in the
frequency conversion of
laser
A laser is a device that emits light through a process of optical amplification based on the stimulated emission of electromagnetic radiation. The word ''laser'' originated as an acronym for light amplification by stimulated emission of radi ...
s.
In the
psychophysics
Psychophysics is the field of psychology which quantitatively investigates the relationship between physical stimulus (physiology), stimuli and the sensation (psychology), sensations and perceptions they produce. Psychophysics has been described ...
of
haptic perception
Haptic perception ( "palpable", ''haptikόs'' "suitable for touch") means literally the ability "to grasp something", and is also known as stereognosis. Perception in this case is achieved through the active exploration of surfaces and objects by a ...
, Pythagorean addition has been proposed as a model for the perceived intensity of
vibration
Vibration () is a mechanical phenomenon whereby oscillations occur about an equilibrium point. Vibration may be deterministic if the oscillations can be characterised precisely (e.g. the periodic motion of a pendulum), or random if the os ...
when two kinds of vibration are combined.
In
image processing
An image or picture is a visual representation. An image can be two-dimensional, such as a drawing, painting, or photograph, or three-dimensional, such as a carving or sculpture. Images may be displayed through other media, including a pr ...
, the
Sobel operator for
edge detection
Edge or EDGE may refer to:
Technology Computing
* Edge computing, a network load-balancing system
* Edge device, an entry point to a computer network
* Adobe Edge, a graphical development application
* Microsoft Edge, a web browser developed b ...
consists of a
convolution
In mathematics (in particular, functional analysis), convolution is a operation (mathematics), mathematical operation on two function (mathematics), functions f and g that produces a third function f*g, as the integral of the product of the two ...
step to determine the
gradient
In vector calculus, the gradient of a scalar-valued differentiable function f of several variables is the vector field (or vector-valued function) \nabla f whose value at a point p gives the direction and the rate of fastest increase. The g ...
of an image followed by a Pythagorean sum at each pixel to determine the magnitude of the gradient.
Implementation
In a 1983 paper,
Cleve Moler
Cleve Barry Moler (born August 17, 1939) is an American mathematician and computer programmer specializing in numerical analysis. In the mid to late 1970s, he was one of the authors of LINPACK and EISPACK, Fortran libraries for numerical compu ...
and Donald Morrison described an
iterative method
In computational mathematics, an iterative method is a Algorithm, mathematical procedure that uses an initial value to generate a sequence of improving approximate solutions for a class of problems, in which the ''i''-th approximation (called an " ...
for computing Pythagorean sums, without taking square roots. This was soon recognized to be an instance of
Halley's method
In numerical analysis, Halley's method is a root-finding algorithm used for functions of one real variable with a continuous second derivative. Edmond Halley was an English mathematician and astronomer who introduced the method now called by his ...
, and extended to analogous operations on
matrices
Matrix (: matrices or matrixes) or MATRIX may refer to:
Science and mathematics
* Matrix (mathematics), a rectangular array of numbers, symbols or expressions
* Matrix (logic), part of a formula in prenex normal form
* Matrix (biology), the ...
.
Although many modern implementations of this operation instead compute Pythagorean sums by reducing the problem to the
square root
In mathematics, a square root of a number is a number such that y^2 = x; in other words, a number whose ''square'' (the result of multiplying the number by itself, or y \cdot y) is . For example, 4 and −4 are square roots of 16 because 4 ...
function,
they do so in a way that has been designed to avoid errors arising from the limited-precision calculations performed on computers. If calculated using the natural formula,
the squares of very large or small values of
and
may exceed the range of
machine precision when calculated on a computer. This may to an inaccurate result caused by
arithmetic underflow
The term arithmetic underflow (also floating-point underflow, or just underflow) is a condition in a computer program where the result of a calculation is a number of more precise absolute value than the computer can actually represent in memory ...
and
overflow, although when overflow and underflow do not occur the output is within two
ulp of the exact result. Common implementations of the
hypot
function rearrange this calculation in a way that avoids the problem of overflow and underflow and are even more precise.
If either input to
hypot
is infinite, the result is infinite. Because this is true for all possible values of the other input, the
IEEE 754
The IEEE Standard for Floating-Point Arithmetic (IEEE 754) is a technical standard for floating-point arithmetic originally established in 1985 by the Institute of Electrical and Electronics Engineers (IEEE). The standard #Design rationale, add ...
floating-point standard requires that this remains true even when the other input is
not a number (NaN).
Calculation order
The difficulty with the naive implementation is that
may overflow or underflow, unless the intermediate result is computed with
extended precision
Extended precision refers to floating-point number formats that provide greater precision than the basic floating-point formats. Extended-precision formats support a basic format by minimizing roundoff and overflow errors in intermediate value ...
. A common implementation technique is to exchange the values, if necessary, so that
, and then to use the equivalent form
The computation of
cannot overflow unless both
and
are zero. If
underflows, the final result is equal to
, which is correct within the precision of the calculation. The square root is computed of a value between 1 and 2. Finally, the multiplication by
cannot underflow, and overflows only when the result is too large to represent.
One drawback of this rearrangement is the additional division by
, which increases both the time and inaccuracy of the computation.
More complex implementations avoid these costs by dividing the inputs into more cases:
* When
is much larger than
,
, to within
machine precision.
* When
overflows, multiply both
and
by a small scaling factor (e.g. 2
−64 for IEEE single precision), use the naive algorithm which will now not overflow, and multiply the result by the (large) inverse (e.g. 2
64).
* When
underflows, scale as above but reverse the scaling factors to scale up the intermediate values.
* Otherwise, the naive algorithm is safe to use.
Additional techniques allow the result to be computed more accurately than the naive algorithm, e.g. to less than one
ulp. Researchers have also developed analogous algorithms for computing Pythagorean sums of more than two values.
Fast approximation
The
alpha max plus beta min algorithm is a high-speed approximation of Pythagorean addition using only comparison, multiplication, and addition, producing a value whose error is less than 4% of the correct result. It is computed as
for a careful choice of parameters
and
.
Programming language support
Pythagorean addition function is present as the
hypot
function in many
programming language
A programming language is a system of notation for writing computer programs.
Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
s and their libraries. These include:
CSS,
D,
Fortran,
Go,
JavaScript
JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior.
Web browsers have ...
(since ES2015),
Julia,
MATLAB
MATLAB (an abbreviation of "MATrix LABoratory") is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementat ...
,
PHP
PHP is a general-purpose scripting language geared towards web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995. The PHP reference implementation is now produced by the PHP Group. ...
, and
Python.
C++11
C++11 is a version of a joint technical standard, ISO/IEC 14882, by the International Organization for Standardization (ISO) and International Electrotechnical Commission (IEC), for the C++ programming language. C++11 replaced the prior vers ...
includes a two-argument version of
hypot
, and a three-argument version for
has been included since
C++17
C17, C-17 or C.17 may refer to:
Transportation
* , a 1917 British C-class submarine
Air
* Boeing C-17 Globemaster III, a military transport aircraft
* Lockheed Y1C-17 Vega, a six-passenger monoplane
* Cierva C.17, a 1928 English experimental ...
.
The
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
implementation of
hypot
can be used by its interoperable JVM-based languages including
Apache Groovy
Apache Groovy is a Java-syntax-compatible object-oriented programming language for the Java platform. It is both a static and dynamic language with features similar to those of Python, Ruby, and Smalltalk. It can be used as both a programming l ...
,
Clojure
Clojure (, like ''closure'') is a dynamic programming language, dynamic and functional programming, functional dialect (computing), dialect of the programming language Lisp (programming language), Lisp on the Java (software platform), Java platfo ...
,
Kotlin, and
Scala.
Similarly, the version of
hypot
included with
Ruby
Ruby is a pinkish-red-to-blood-red-colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sapph ...
extends to Ruby-based
domain-specific language
A domain-specific language (DSL) is a computer language specialized to a particular application domain. This is in contrast to a general-purpose language (GPL), which is broadly applicable across domains. There are a wide variety of DSLs, ranging ...
s such as
Progress Chef. In
Rust
Rust is an iron oxide, a usually reddish-brown oxide formed by the reaction of iron and oxygen in the catalytic presence of water or air moisture. Rust consists of hydrous iron(III) oxides (Fe2O3·nH2O) and iron(III) oxide-hydroxide (FeO(OH) ...
,
hypot
is implemented as a
method
Method (, methodos, from μετά/meta "in pursuit or quest of" + ὁδός/hodos "a method, system; a way or manner" of doing, saying, etc.), literally means a pursuit of knowledge, investigation, mode of prosecuting such inquiry, or system. In re ...
of
floating point
In computing, floating-point arithmetic (FP) is arithmetic on subsets of real numbers formed by a ''significand'' (a signed sequence of a fixed number of digits in some base) multiplied by an integer power of that base.
Numbers of this form ...
objects rather than as a two-argument function.
Metafont
Metafont is a page description language, description language used to define raster fonts. It is also the name of the interpreter (computer software), interpreter that executes Metafont code, generating the bitmap fonts that can be embedded into ...
has Pythagorean addition and
subtraction
Subtraction (which is signified by the minus sign, –) is one of the four Arithmetic#Arithmetic operations, arithmetic operations along with addition, multiplication and Division (mathematics), division. Subtraction is an operation that repre ...
as built-in operations, under the symbols
++
and
+-+
respectively.
History
The
Pythagorean theorem
In mathematics, the Pythagorean theorem or Pythagoras' theorem is a fundamental relation in Euclidean geometry between the three sides of a right triangle. It states that the area of the square whose side is the hypotenuse (the side opposite t ...
on which this operation is based was studied in ancient
Greek mathematics
Ancient Greek mathematics refers to the history of mathematical ideas and texts in Ancient Greece during Classical antiquity, classical and late antiquity, mostly from the 5th century BC to the 6th century AD. Greek mathematicians lived in cities ...
, and may have been known earlier in
Egyptian mathematics
Ancient Egyptian mathematics is the mathematics that was developed and used in Ancient Egypt 3000 to c. , from the Old Kingdom of Egypt until roughly the beginning of Hellenistic Egypt. The ancient Egyptians utilized a numeral system for counti ...
and
Babylonian mathematics
Babylonian mathematics (also known as Assyro-Babylonian mathematics) is the mathematics developed or practiced by the people of Mesopotamia, as attested by sources mainly surviving from the Old Babylonian period (1830–1531 BC) to the Seleucid ...
; see . However, its use for computing distances in Cartesian coordinates could not come until after
René Descartes
René Descartes ( , ; ; 31 March 1596 – 11 February 1650) was a French philosopher, scientist, and mathematician, widely considered a seminal figure in the emergence of modern philosophy and Modern science, science. Mathematics was paramou ...
invented these coordinates in 1637; the formula for distance from these coordinates was published by
Alexis Clairaut
Alexis Claude Clairaut (; ; 13 May 1713 – 17 May 1765) was a French mathematician, astronomer, and geophysicist. He was a prominent Newtonian whose work helped to establish the validity of the principles and results that Isaac Newton, Sir Isaa ...
in 1731.
The terms "Pythagorean addition" and "Pythagorean sum" for this operation have been used at least since the 1950s, and its use in signal processing as "addition in quadrature" goes back at least to 1919.
From the 1920s to the 1940s, before the widespread use of computers, multiple designers of
slide rule
A slide rule is a hand-operated mechanical calculator consisting of slidable rulers for conducting mathematical operations such as multiplication, division, exponents, roots, logarithms, and trigonometry. It is one of the simplest analog ...
s included square-root scales in their devices, allowing Pythagorean sums to be calculated mechanically. Researchers have also investigated
analog circuit
Analogue electronics () are electronic systems with a continuously variable signal, in contrast to digital electronics where signals usually take only two levels. The term ''analogue'' describes the proportional relationship between a signal ...
s for approximating the value of Pythagorean sums.
References
{{reflist, refs=
[{{cite conference, contribution=Systematic errors: facts and fictions, first=Roger, last=Barlow, arxiv=hep-ex/0207026, title=Conference on Advanced Statistical Techniques in Particle Physics, location=Durham, UK, date=March 22, 2002, pages=134–144]
[{{cite book, title=Learning Modern C++ for Finance, first=Daniel, last=Hanson, publisher=O'Reilly, year=2024, isbn=9781098100773, page=25, url=https://books.google.com/books?id=8EQvEQAAQBAJ&pg=PA25]
[{{Cite web, url=https://www.zdnet.com/article/css-to-get-support-for-trigonometry-functions/, title=CSS to get support for trigonometry functions, last=Cimpanu, first=Catalin, website=ZDNet, language=en, date=March 10, 2019, access-date=2019-11-01]
[{{Cite book, contribution-url=https://dlang.org/phobos/std_math_algebraic.html, contribution=std.math.algebraic, title=Phobos Runtime Library Reference, version 2.109.1, publisher=D Language Foundation, access-date=2025-02-21]
[{{cite journal
, last = Dawson , first = Bernhard H.
, date = July 1946
, doi = 10.1126/science.104.2688.18.c
, issue = 2688
, journal = Science
, jstor = 1675936
, page = 18
, title = An improved slide rule for the addition of squares
, volume = 104]
[{{cite journal
, last = Dempster , first = J. R.
, date = April 1946
, doi = 10.1126/science.103.2677.488.b
, issue = 2677
, journal = Science
, jstor = 1671874
, page = 488
, title = A circular slide rule
, volume = 103]
[{{cite book
, last1 = Deza , first1 = Michel Marie , author1-link = Michel Deza
, last2 = Deza , first2 = Elena , author2-link = Elena Deza
, doi = 10.1007/978-3-662-44342-2
, isbn = 9783662443422
, page = 100
, publisher = Springer
, title = Encyclopedia of Distances
, year = 2014]
[{{cite book
, last = Drosg , first = Manfred
, contribution = Dealing with Internal Uncertainties
, doi = 10.1007/978-3-642-01384-3_8
, isbn = 9783642013843
, pages = 151–172
, publisher = Springer Berlin Heidelberg
, title = Dealing with Uncertainties
, year = 2009]
[{{cite journal , first=Augustin A. , last=Dubrulle , title=A class of numerical methods for the computation of Pythagorean sums , journal=IBM Journal of Research and Development , volume=27 , issue=6 , pages=582–589 , year=1983 , url=https://scholar.archive.org/work/24dboinszvcq5e6xb54awaeb3u , doi=10.1147/rd.276.0582 , citeseerx = 10.1.1.94.3443 ]
[{{cite journal
, last = Eimerl , first = D.
, date = August 1987
, doi = 10.1109/jqe.1987.1073521
, issue = 8
, journal = IEEE Journal of Quantum Electronics
, pages = 1361–1371
, title = Quadrature frequency conversion
, volume = 23, bibcode =
]
[{{cite journal
, last1 = Ellis , first1 = Mark W.
, last2 = Pagni , first2 = David
, date = May 2008
, doi = 10.5951/mtms.13.9.0520
, issue = 9
, journal = Mathematics Teaching in the Middle School
, jstor = 41182606
, pages = 520–525
, publisher = National Council of Teachers of Mathematics
, title = Exploring segment lengths on the Geoboard
, volume = 13]
[{{Cite report, url=https://wg5-fortran.org/N1851-N1900/N1891.pdf, title=The new features of Fortran 2008, contribution=9.6 Error and gamma functions, page=20, first=John, last=Reid, date=March 13, 2014, publisher=]ISO/IEC JTC 1/SC 22
ISO/IEC JTC 1/SC 22 Programming languages, their environments and system software interfaces is a standardization subcommittee of the Joint Technical Committee ISO/IEC JTC 1 of the International Organization for Standardization (ISO) and the Intern ...
, WG5 international Fortran standards committee, type=Report N1891
[{{cite book, title=Programming in Go: Creating Applications for the 21st Century, first=Mark, last=Summerfield, publisher=Pearson Education, year=2012, isbn=9780321774637, page=66, url=https://books.google.com/books?id=CR0dBAAAQBAJ&pg=PA66]
[{{cite book
, last = Grieser , first = Daniel
, contribution = 6.2 The diagonal of a cuboid
, contribution-url = https://books.google.com/books?id=UIlcDwAAQBAJ&pg=PA143
, doi = 10.1007/978-3-319-90321-7
, isbn = 9783319903217
, pages = 143–145
, publisher = Springer International Publishing
, series = Springer Undergraduate Mathematics Series
, title = Exploring Mathematics: Problem-Solving and Proof
, year = 2018]
[{{cite journal
, last = Hicks , first = Charles R.
, date = March 1955
, doi = 10.5951/mt.48.3.0130
, issue = 3
, journal = The Mathematics Teacher
, jstor = 27954826
, pages = 130–132
, publisher = National Council of Teachers of Mathematics
, title = Two problems illustrating the use of mathematics in modern industry
, url = https://scholar.archive.org/work/rpcuqkbefnfy7bgq6hmux7vwhy
, volume = 48]
[{{cite book, title=Statistical Tools for the Comprehensive Practice of Industrial Hygiene and Environmental Health Sciences, first=David L., last=Johnson , publisher=John Wiley & Sons, year=2017 , isbn= 9781119143017 , contribution=12.2.3 Addition in Quadrature, contribution-url=https://books.google.com/books?id=tRWuDQAAQBAJ&pg=PA289 , page=289]
[{{cite journal
, last = Borges , first = Carlos F.
, arxiv = 1904.09481
, doi = 10.1145/3428446
, issue = 1
, journal = ACM Transactions on Mathematical Software
, pages = 9:1–9:12
, title = Algorithm 1014: An Improved Algorithm for hypot(x, y)
, volume = 47
, year = 2021, s2cid = 230588285
]
[{{cite journal
, last = Incertis , first = F.
, date = March 1985
, doi = 10.1109/tac.1985.1103937
, issue = 3
, journal = IEEE Transactions on Automatic Control
, pages = 273–275
, title = A faster method of computing matrix pythagorean sums
, volume = 30]
[{{cite book, title=Ivor Horton's Beginning Java 2, first=Ivor, last=Horton, publisher=John Wiley & Sons, year=2005, isbn=9780764568749, page=57, url=https://books.google.com/books?id=h0Uhz4lBoF8C&pg=PA57]
[{{cite conference
, last1 = Jeannerod , first1 = Claude-Pierre
, last2 = Muller , first2 = Jean-Michel
, last3 = Plet , first3 = Antoine
, editor1-last = Burgess , editor1-first = Neil
, editor2-last = Bruguera , editor2-first = Javier D.
, editor3-last = de Dinechin , editor3-first = Florent
, contribution = The classical relative error bounds for computing and in binary floating-point arithmetic are asymptotically optimal
, doi = 10.1109/ARITH.2017.40
, pages = 66–73
, publisher = IEEE Computer Society
, title = 24th IEEE Symposium on Computer Arithmetic, ARITH 2017, London, United Kingdom, July 24–26, 2017
, year = 2017]
[{{cite book, title=Beginning Julia Programming: For Engineers and Scientists, first=Sandeep, last=Nagar, publisher=Apress, year=2017, isbn=9781484231715, page=105, url=https://books.google.com/books?id=KmRADwAAQBAJ&pg=PA105]
[{{cite book
, last = Knuth , first = Donald E. , author-link = Donald Knuth
, page = 80
, publisher = Addison-Wesley
, title = The METAFONTbook
, year = 1986]
[{{cite book
, last = Kuehn , first = Kerry
, doi = 10.1007/978-1-4939-1366-4
, isbn = 9781493913664
, series = Undergraduate Lecture Notes in Physics
, page = 372
, publisher = Springer New York
, title = A Student's Guide Through the Great Physics Texts: Volume II: Space, Time and Motion
, url = https://books.google.com/books?id=SfuJBAAAQBAJ&pg=PA372
, year = 2015]
[{{cite book
, last = Lyons , first = Richard G.
, contribution = 13.2 High-speed vector magnitude approximation
, contribution-url = https://books.google.com/books?id=UBU7Y2tpwWUC&pg=PT858
, edition = 3rd
, pages = 13-6 – 13-8
, publisher = Pearson
, title = Understanding Digital Signal Processing
, year = 2010]
[{{cite book, title=Java Script Notes for Professionals, first=Rohit, last=Manglik, publisher=EduGorilla, year=2024, isbn=9789367840320, contribution=Section 14.22: Math.hypot, page=144, contribution-url=https://books.google.com/books?id=jwU6EQAAQBAJ&pg=PA144]
[{{Cite book , last= Maor , first=Eli , title=The Pythagorean Theorem: A 4,000-Year History , location=Princeton, New Jersey , publisher=Princeton University Press , url=https://books.google.com/books?id=Z5VoBGy3AoAC , year=2007 , isbn=978-0-691-12526-8 , pages=4–15]
[{{cite book, title=The Mathematical-Function Computation Handbook: Programming Using the MathCW Portable Software Library, first=Nelson H. F., last=Beebe, publisher=Springer, year=2017, isbn=9783319641102, page=70, url=https://books.google.com/books?id=OjUyDwAAQBAJ&pg=PA70]
[{{cite book
, last1 = Higham , first1 = Desmond J. , author1-link = Desmond Higham
, last2 = Higham , first2 = Nicholas J. , author2-link = Nicholas Higham
, contribution = 26.9 Pythagorean sum
, contribution-url = https://books.google.com/books?id=8c_ZDQAAQBAJ&pg=PA430
, edition = 3rd
, isbn = 9781611974669
, pages = 430–432
, publisher = ]Society for Industrial and Applied Mathematics
Society for Industrial and Applied Mathematics (SIAM) is a professional society dedicated to applied mathematics, computational science, and data science through research, publications, and community. SIAM is the world's largest scientific soci ...
, title = MATLAB Guide
, year = 2016
[{{cite journal , last = Falmagne , first = Jean-Claude , author-link = Jean-Claude Falmagne , doi = 10.1007/s00010-015-0339-1 , issue = 2 , journal = ]Aequationes Mathematicae
''Aequationes Mathematicae'' is a mathematical journal. It is primarily devoted to functional equations, but also publishes papers in dynamical systems, combinatorics, and geometry. As well as publishing regular journal submissions on these topics ...
, mr = 3340218 , pages = 393–435 , title = Deriving meaningful scientific laws from abstract, "gedanken" type, axioms: five examples , volume = 89 , year = 2015, s2cid = 121424613
[D. B. Schneider]
''Error Analysis in Measuring Systems''
Proceedings of the 1962 Standards Laboratory Conference, page 94
[{{cite book, title=Easy Lessons in Mechanical Drawing & Machine Design: Arranged for Self-instruction, Vol. I, first=J. G. A., last=Meyer, publisher=Industrial Publication Company, year=1902, contribution=225. – To find the diagonal of a rectangle when its length and breadth are given, page=133, contribution-url=https://books.google.com/books?id=cVlFAQAAMAAJ&pg=PA133]
[{{cite journal
, last = Morrell , first = William E.
, date = January 1946
, doi = 10.1126/science.103.2665.113
, issue = 2665
, journal = Science
, jstor = 1673946
, pages = 113–114
, title = A slide rule for the addition of squares
, volume = 103, pmid =
, bibcode =
]
[{{cite arXiv
, last1 = Muller , first1 = Jean-Michel
, last2 = Salvy , first2 = Bruno
, eprint = 2405.03588
, title = Effective quadratic error bounds for floating-point algorithms computing the hypotenuse function
, year = 2024, class = math.NA
]
[{{cite web
, title=Floating point exception tracking and NAN propagation
, first=Agner , last=Fog , authorlink=Agner Fog
, date=2020-04-27 , page=6
, url=https://www.agner.org/optimize/nan_propagation.pdf#page=6
]
[{{citation
, last1 = Lefèvre , first1 = Vincent
, last2 = Louvet , first2 = Nicolas
, last3 = Muller , first3 = Jean-Michel
, last4 = Picot , first4 = Joris
, last5 = Rideau , first5 = Laurence
, article-number = 1
, doi = 10.1145/3568672
, issue = 1
, journal = ACM Transactions on Mathematical Software
, mr = 4567887
, pages = 1–34
, title = Accurate calculation of Euclidean norms using double-word arithmetic
, volume = 49
, year = 2023, url = https://hal.science/hal-03482567v2/file/NormsandDW%20HaLV2.pdf
]
[{{cite book, title=Discrete Mathematics: Proof Techniques and Mathematical Structures, first=R. C., last=Penner, publisher=World Scientific, year=1999, isbn=9789810240882, url=https://books.google.com/books?id=t5r79vZ9ogoC&pg=PA417, pages=417–418]
[{{cite book, title=Core PHP Programming, first1=Leon, last1=Atkinson, first2=Zeev, last2=Suraski, publisher=Prentice Hall, year=2004, isbn=9780130463463, page=504, contribution=Listing 13.17: hypot, contribution-url=https://books.google.com/books?id=e7D-mITABmEC&pg=PA504]
[{{cite book
, last1 = Powers , first1 = J. E.
, last2 = Phillips , first2 = D. J.
, last3 = Brandestini , first3 = M.
, last4 = Ferraro , first4 = R.
, last5 = Baker , first5 = D. W.
, editor-last = Wang , editor-first = Keith Y.
, contribution = Quadrature sampling for phased array application
, doi = 10.1007/978-1-4684-3755-3_18
, isbn = 9781468437553
, pages = 263–273
, publisher = Springer
, title = Acoustical Imaging: Visualization and Characterization
, volume = 9
, year = 1980]
[{{cite book, title=Learning Scientific Programming with Python, first=Christian, last=Hill, edition=2nd, publisher=Cambridge University Press, year=2020, isbn=9781108787468, page=14, url=https://books.google.com/books?id=XAIHEAAAQBAJ&pg=PA14]
[{{cite journal , last1 = Moler , first1 = Cleve , author1-link = Cleve Moler , last2 = Morrison , first2 = Donald , citeseerx = 10.1.1.90.5651 , doi = 10.1147/rd.276.0577 , issue = 6 , journal = IBM Journal of Research and Development , pages = 577–581 , title = Replacing square roots by Pythagorean sums , url = https://scholar.archive.org/work/vn5a4l3fhfbkzomjj4dypacw7q , volume = 27 , year = 1983]
[{{cite book, title=Learning Chef: A Guide to Configuration Management and Automation, first1=Mischa, last1=Taylor, first2=Seth, last2=Vargo, publisher=O'Reilly Media, year=2014, isbn=9781491945117, contribution=Mathematical operations, page=40, contribution-url=https://books.google.com/books?id=LpY8BQAAQBAJ&pg=PA40]
[{{Cite web, url=https://doc.rust-lang.org/std/primitive.f64.html, title=Primitive Type f64, work=The Rust Standard Library, date=February 17, 2025, access-date=2025-02-22]
[{{cite book, title=Introduction to JVM Languages: Java, Scala, Clojure, Kotlin, and Groovy, first=Vincent, last=van der Leun, publisher=Packt Publishing Ltd, year=2017, isbn=9781787126589, pages=10–11, contribution=Java Class Library, contribution-url=https://books.google.com/books?id=7Hc5DwAAQBAJ&pg=PA10]
[{{cite journal
, last1 = Kanopoulos , first1 = N.
, last2 = Vasanthavada , first2 = N.
, last3 = Baker , first3 = R.L.
, date = April 1988
, doi = 10.1109/4.996
, issue = 2
, journal = IEEE Journal of Solid-State Circuits
, pages = 358–367
, title = Design of an image edge detection filter using the Sobel operator
, volume = 23, bibcode =
]
[{{cite journal
, last1 = Stern , first1 = T. E.
, last2 = Lerner , first2 = R. M.
, date = April 1963
, doi = 10.1109/proc.1963.2206
, issue = 4
, journal = Proceedings of the IEEE
, pages = 593–596
, title = A circuit for the square root of the sum of the squares
, volume = 51]
[{{cite book, title=Unix Programmer's Manual: Reference Guide, edition=4.3 Berkeley Software Distribution Virtual VAX-11 Version, date=April 1986, publisher=Department of Electrical Engineering and Computer Science, University of California, Berkeley, contribution=SIN (3M): Trigonometric functions and their inverses, contribution-url=https://archive.org/details/upm-ref-4.3bsd/page/n257]
[{{cite journal
, last = van Dantzig , first = D.
, journal = Nieuw Archief voor Wiskunde
, mr = 56872
, pages = 129–145
, series = 3rd ser.
, title = Another form of the weak law of large numbers
, url = https://ir.cwi.nl/pub/8252/8252D.pdf
, volume = 1
, year = 1953]
[{{cite journal
, last1 = Yoo , first1 = Yongjae
, last2 = Hwang , first2 = Inwook
, last3 = Choi , first3 = Seungmoon
, date = April 2022
, doi = 10.1109/toh.2022.3144290
, issue = 2
, journal = IEEE Transactions on Haptics
, pages = 405–415
, title = Perceived intensity model of dual-frequency superimposed vibration: Pythagorean sum
, volume = 15, pmid =
]
[{{cite journal
, last = Weagant , first = R. A. , author-link = Roy Alexander Weagant
, date = June 1919
, doi = 10.1109/jrproc.1919.217434
, issue = 3
, journal = Proceedings of the IRE
, pages = 207–244
, title = Reception thru static and interference
, url = https://scholar.archive.org/work/5hvr463fczblfe4fdd2bu4vrze
, volume = 7 See p. 232.]
[{{cite book, title=Central Tendency and Variability, volume=83, first=Herbert F., last=Weisberg, series=Quantitative Applications in the Social Sciences, publisher=Sage, year=1992, isbn=9780803940079, page]
45
52–53
}
[{{cite book, title=Experimental Physics: Principles and Practice for the Laboratory, first=Walter F., last=Smith, publisher=CRC Press, year=2020, isbn=9781498778688, pages=40–41, url=https://books.google.com/books?id=9LrZDwAAQBAJ&pg=PA40]
[{{cite journal
, last = Ziv , first = Abraham
, doi = 10.1090/S0025-5718-99-01103-5
, issue = 227
, journal = Mathematics of Computation
, jstor = 2584955
, mr = 1648423
, pages = 1143–1148
, title = Sharp ULP rounding error bound for the hypotenuse function
, volume = 68
, year = 1999]
Operations on numbers
Addition
Addition (usually signified by the Plus and minus signs#Plus sign, plus symbol, +) is one of the four basic Operation (mathematics), operations of arithmetic, the other three being subtraction, multiplication, and Division (mathematics), divis ...
Numerical analysis