Difference is the result of subtracting one number from another. How much one number differs from another. Example: The difference between 8 and 3 is 5.
In arithmetic, subtraction
is one of the four basic binary operations; it is the inverse of addition, meaning that if we start with any number and add any number and then subtract the same number we added, we return to the number we started with. Subtraction is denoted by a minus sign in infix notation, in contrast to the use of the plus sign for addition.
Since subtraction is not a commutative operator, the two operands are named. The traditional names for the parts of the formula
) − subtrahend
) = difference
Subtraction is used to model four related processes:
In mathematics, it is often useful to view or even define subtraction as a kind of addition, the addition of the additive inverse. We can view 7 − 3 = 4 as the sum of two terms: 7 and -3. This perspective allows us to apply to subtraction all of the familiar rules and nomenclature of addition. Subtraction is not associative or commutative—in fact, it is anticommutative and left-associative—but addition of signed numbers is both.
Imagine a line segment of length b
with the left end labeled a
and the right end labeled c
. Starting from a
, it takes b
steps to the right to reach c
. This movement to the right is modeled mathematically by addition:
, it takes b
steps to the left
to get back to a
. This movement to the left is modeled by subtraction:
Now, a line segment labeled with the numbers 1, 2, and 3. From position 3, it takes no steps to the left to stay at 3, so 3 − 0 = 3. It takes 2 steps to the left to get to position 1, so 3 − 2 = 1. This picture is inadequate to describe what would happen after going 3 steps to the left of position 3. To represent such an operation, the line must be extended.
To subtract arbitrary natural numbers, one begins with a line containing every natural number (0, 1, 2, 3, 4, 5, 6, ...). From 3, it takes 3 steps to the left to get to 0, so 3 − 3 = 0. But 3 − 4 is still invalid since it again leaves the line. The natural numbers are not a useful context for subtraction.
The solution is to consider the integer number line (..., −3, −2, −1, 0, 1, 2, 3, ...). From 3, it takes 4 steps to the left to get to −1:
There are some cases where subtraction as a separate operation becomes problematic. For example, 3 − (−2) (i.e. subtract −2 from 3) is not immediately obvious from either a natural number view or a number line view, because it is not immediately clear what it means to move −2 steps to the left or to take away −2 apples. One solution is to view subtraction as addition of signed numbers. Extra minus signs simply denote additive inversion. Then we have 3 − (−2) = 3 + 2 = 5. This also helps to keep the ring of integers "simple" by avoiding the introduction of "new" operators such as subtraction. Ordinarily a ring only has two operations defined on it; in the case of the integers, these are addition and multiplication. A ring already has the concept of additive inverses, but it does not have any notion of a separate subtraction operation, so the use of signed addition as subtraction allows us to apply the ring axioms to subtraction without needing to prove anything.
There are various algorithms for subtraction, and they differ in their suitability for various applications. A number of methods are adapted to hand calculation; for example, when making change, no actual subtraction is performed, but rather the change-maker counts forward.
For machine calculation, the method of complements is preferred, whereby the subtraction is replaced by an addition in a modular arithmetic.
Methods used to teach subtraction to elementary school varies from country to country, and within a country, different methods are in fashion at different times. In what is, in the U.S., called traditional mathematics, a specific process is taught to students at the end of the 1st year or during the 2nd year for use with multi-digit whole numbers, and is extended in either the fourth or fifth grade to include decimal representations of fractional numbers.
Some American schools currently teach a method of subtraction using borrowing and a system of markings called crutches]
[. Although a method of borrowing had been known and published in textbooks prior, apparently the crutches are the invention of William A. Brownell who used them in a study in November 1937]
[. This system caught on rapidly, displacing the other methods of subtraction in use in America at that time.
Some European schools employ a method of subtraction called the Austrian method, also known as the additions method. There is no borrowing in this method. There are also crutches (markings to aid memory), which vary by country]
Both these methods break up the subtraction as a process of one digit subtractions by place value. Starting with a least significant digit, a subtraction of subtrahend:
where each si
is a digit, proceeds by writing down m1
, and so forth, as long as si
does not exceed mi
. Otherwise, mi
is increased by 10 and some other digit is modified to correct for this increase. The American method corrects by attempting to decrease the minuend digit mi+1
by one (or continuing the borrow leftwards until there is a non-zero digit from which to borrow). The European method corrects by increasing the subtrahend digit si+1
704 − 512. The minuend is 704, the subtrahend is 512. The minuend digits are m3
= 7, m2
= 0 and m1
= 4. The subtrahend digits are s3
= 5, s2
= 1 and s1
= 2. Beginning at the one's place, 4 is not less than 2 so the difference 2 is written down in the result's one place. In the ten's place, 0 is less than 1, so the 0 is increased to 10, and the difference with 1, which is 9, is written down in the ten's place. The American method corrects for the increase of ten by reducing the digit in the minuend's hundreds place by one. That is, the 7 is struck through and replaced by a 6. The subtraction then proceeds in the hundreds place, where 6 is not less than 5, so the difference is written down in the result's hundred's place. We are now done, the result is 192.
The Austrian method does not reduce the 7 to 6. Rather it increases the subtrahend hundred's digit by one. A small mark is made near or below this digit (depending on the school). Then the subtraction proceeds by asking what number when increased by 1, and 5 is added to it, makes 7. The answer is 1, and is written down in the result's hundred's place.
There is an additional subtlety in that the student always employs a mental subtraction table in the American method. The Austrian method often encourages the student to mentally use the addition table in reverse. In the example above, rather than adding 1 to 5, getting 6, and subtracting that from 7, the student is asked to consider what number, when increased by 1, and 5 is added to it, makes 7.
When subtracting two numbers with units, they must have the same unit. In most cases the difference will have the same unit as the original numbers. One exception is when subtracting two numbers with percentage as unit. In this case, the difference will have percentage points as unit.
In mathematics, the difference of two squares
, or the difference of perfect squares, is a squared (multiplied by itself) number subtracted from another squared number. It refers to the identity
in elementary algebra.
The proof is straightforward. Starting from the right-hand side, apply the distributive law to get
as an application of the commutative law. The resulting identity is one of the most commonly used in mathematics. Among many uses, it gives a simple proof of the AM–GM inequality in two variables.
The proof just given indicates the scope of the identity in abstract algebra: it will hold in any commutative ring R
Conversely, if this identity holds in a ring R
for all pairs of elements a
of the ring, then R
is commutative. To see this, we apply the distributive law to the right-hand side of the original equation and get
and for this to be equal to
, we must have
for all pairs a
of elements of R
, so the ring R
The difference of two squares can also be illustrated geometrically as the difference of two square areas in a plane. In the diagram, the shaded part represents the difference between the areas of the two squares, i.e.
. The area of the shaded part can be found by adding the areas of the two rectangles;
, which can be factorized to
Another geometric proof proceeds as follows: We start with the figure shown in the first diagram below, a large square with a smaller square removed from it. The side of the entire square is a, and the side of the small removed square is b. The area of the shaded region is
. A cut is made, splitting the region into two rectangular pieces, as shown in the second diagram. The larger piece, at the top, has width a and height a-b. The smaller piece, at the bottom, has width a-b and height b. Now the smaller piece can be detached, rotated, and placed to the right of the larger piece. In this new arrangement, shown in the last diagram below, the two pieces together form a rectangle, whose width is
and whose height is
. This rectangle's area is
. Since this rectangle came from rearranging the original figure, it must have the same area as the original figure. Therefore,
.Any odd number can be expressed as difference of two squares.
The difference of two squares is used to find the linear factors of the sum
of two squares, using complex number coefficients.
For example, the root of
can be found using difference of two squares:
Therefore the linear factors are
Since the two factors found by this method are Complex conjugates, we can use this in reverse as a method of multiplying a complex number to get a real number. This is used to get real denominators in complex fractions.
The difference of two squares can also be used in the rationalising of irrational denominators. This is a method for removing surds from expressions (or at least moving them), applying to division by some combinations involving square roots.
For example: The denominator of
can be rationalised as follows:
Here, the irrational denominator
has been rationalised to
. Any odd number can be expressed as difference of two squares.
The difference of two squares can also be used as an arithmetical short cut. If you are multiplying two numbers whose average is a number which is easily squared the difference of two squares can be used to give you the product of the original two numbers.
Which means using the difference of two squares
can be restated as
The identity also holds in inner product spaces over the field of real numbers, such as for dot product of Euclidean vectors:
The proof is identical. By the way, assuming that and have equal norms (which means that their dot squares are equal), it demonstrates analytically the fact that two diagonals of a rhombus are perpendicular.
In mathematics, especially in elementary arithmetic, division
(÷) is an arithmetic operation. Specifically, if b
is not zero, then a
divided by b
In the expression a ÷ b = c, a
is called the dividend
and the result c
is called the quotient
Conceptually, division describes two distinct but related settings. Partitioning
involves taking a set of size a
and forming b
groups that are equal in size. The size of each group formed, c
, is the quotient of a
division involves taking a set of size a
and forming groups of size c
. The number of groups of this size that can be formed, b
, is the quotient of a
Teaching division usually leads to the concept of fractions being introduced to students. Unlike addition, subtraction, and multiplication, the set of all integers is not closed under division. Dividing two integers may result in a remainder. To complete the division of the remainder, the number system is extended to include fractions or rational numbers as they are more generally called.
Division is often shown in algebra and science by placing the dividend
over the divisor
with a horizontal line, also called a vinculum or fraction bar, between them. For example, a
divided by b
This can be read out loud as "a divided by b", "a by b" or "a over b". A way to express division all on one line is to write the dividend
(or numerator), then a slash, then the divisor
(or denominator), like this:
This is the usual way to specify division in most computer programming languages since it can easily be typed as a simple sequence of ASCII characters.
A typographical variation halfway between these two forms uses a solidus (fraction slash) but elevates the dividend, and lowers the divisor:
Any of these forms can be used to display a fraction. A fraction is a division expression where both dividend and divisor are integers (although typically called the numerator
), and there is no implication that the division must be evaluated further. A second way to show division is to use the obelus (or division sign), common in arithmetic, in this manner:
This form is infrequent except in elementary arithmetic. ISO 80000-2-9.6 states it should not be used. The obelus is also used alone to represent the division operation itself, as for instance as a label on a key of a calculator.
In some non-English-speaking cultures, "a divided by b" is written a
. This notation was introduced in 1631 by William Oughtred in his Clavis Mathematicae
and later popularized by Gottfried Wilhelm Leibniz. However, in English usage the colon is restricted to expressing the related concept of ratios (then "a is to b").
In elementary mathematics the notation
is used to denote a
divided by b
. This notation was first introduced by Michael Stifel in Arithmetica integra
, published in 1544.
Division is often introduced through the notion of "sharing out" a set of objects, for example a pile of sweets, into a number of equal portions. Distributing the objects several at a time in each round of sharing to each portion leads to the idea of "chunking", i.e., division by repeated subtraction.
More systematic and more efficient (but also more formalised and more rule-based, and more removed from an overall holistic picture of what division is achieving), a person who knows the multiplication tables can divide two integers using pencil and paper using the method of short division, if the divisor is simple. Long division is used for larger integer divisors. If the dividend has a fractional part (expressed as a decimal fraction), one can continue the algorithm past the ones place as far as desired. If the divisor has a fractional part, we can restate the problem by moving the decimal to the right in both numbers until the divisor has no fraction.
A person can calculate division with an abacus by repeatedly placing the dividend on the abacus, and then subtracting the divisor the offset of each digit in the result, counting the number of divisions possible at each offset.
A person can use logarithm tables to divide two numbers, by subtracting the two numbers' logarithms, then looking up the antilogarithm of the result.
A person can calculate division with a slide rule by aligning the divisor on the C scale with the dividend on the D scale. The quotient can be found on the D scale where it is aligned with the left index on the C scale. The user is responsible, however, for mentally keeping track of the decimal point.
Modern computers compute division by methods that are faster than long division: see Division algorithm.
In modular arithmetic, some numbers have a multiplicative inverse with respect to the modulus. We can calculate division by multiplication in such a case. This approach is useful in computers that do not have a fast division instruction.
The division algorithm is a mathematical theorem that precisely expresses the outcome of the usual process of division of integers. In particular, the theorem asserts that integers called the quotient q
and remainder r
always exist and that they are uniquely determined by the dividend a
and divisor d
, with d
≠ 0. Formally, the theorem is stated as follows: There exist unique integers q
such that a
and 0 ≤ r
< | d
|, where | d
| denotes the absolute value of d
Division of integers is not closed. Apart from division by zero being undefined, the quotient is not an integer unless the dividend is an integer multiple of the divisor. For example 26 cannot be divided by 11 to give an integer. Such a case uses one of five approaches:
Dividing integers in a computer program requires special care. Some programming languages, such as C, treat integer division as in case 5 above, so the answer is an integer. Other languages, such as MATLAB and every computer algebra system return a rational number as the answer, as in case 3 above. These languages provide also functions to get the results of the other cases, either directly of from the result of case 3.
Names and symbols used for integer division include div, /, \, and %. Definitions vary regarding integer division when the dividend or the divisor is negative: rounding may be toward zero (so called T-division) or toward −∞ (F-division); rarer styles can occur – see Modulo operation for the details.
Divisibility rules can sometimes be used to quickly determine whether one integer divides exactly into another.
The result of dividing two rational numbers is another rational number when the divisor is not 0. We may define division of two rational numbers p
All four quantities are integers, and only p
may be 0. This definition ensures that division is the inverse operation of multiplication.
Division of two real numbers results in another real number when the divisor is not 0. It is defined such a
if and only if a
Division of any number by zero (where the divisor is zero) is undefined. This is because zero multiplied by any finite number always results in a product of zero. Entry of such an expression into most calculators produces an error message.
Dividing two complex numbers results in another complex number when the divisor is not 0, defined thus:
All four quantities are real numbers. r
may not both be 0.
Division for complex numbers expressed in polar form is simpler than the definition above:
Again all four quantities are real numbers. r
may not be 0.
One can define the division operation for polynomials in one variable over a field. Then, as in the case of integers, one has a remainder. See Euclidean division of polynomials, and, for hand-written computation, polynomial long division or synthetic division.
One can define a division operation for matrices. The usual way to do this is to define , where denotes the inverse of B
, but it is far more common to write out explicitly to avoid confusion.
Because matrix multiplication is not commutative, one can also define a left division or so-called backslash-division
as . For this to be well defined, need not exist, however does need to exist. To avoid confusion, division as defined by is sometimes called right division
in this context.
Note that with left and right division defined this way, is in general not the same as and nor is the same as , but and .
To avoid problems when and/or do not exist, division can also be defined as multiplication with the pseudoinverse, i.e., and , where and denote the pseudoinverse of A
In abstract algebras such as matrix algebras and quaternion algebras, fractions such as
are typically defined as
is presumed an invertible element (i.e., there exists a multiplicative inverse
is the multiplicative identity). In an integral domain where such elements may not exist, division
can still be performed on equations of the form
by left or right cancellation, respectively. More generally "division" in the sense of "cancellation" can be done in any ring with the aforementioned cancellation properties. If such a ring is finite, then by an application of the pigeonhole principle, every nonzero element of the ring is invertible, so division
by any nonzero element is possible in such a ring. To learn about when algebras
(in the technical sense) have a division operation, refer to the page on division algebras. In particular Bott periodicity can be used to show that any real normed division algebra must be isomorphic to either the real numbers R
, the complex numbers C
, the quaternions H
, or the octonions O
The derivative of the quotient of two functions is given by the quotient rule:
There is no general method to integrate the quotient of two functions.
The symmetric difference is
the union without the intersection:
In mathematics, the symmetric difference
of two sets is the set of elements which are in either of the sets and not in their intersection. The symmetric difference of the sets A
is commonly denoted by
For example, the symmetric difference of the sets
. The symmetric difference of the set of all students and the set of all females consists of all male students together with all female non-students.
The power set of any set becomes an abelian group under the operation of symmetric difference, with the empty set as the neutral element of the group and every element in this group being its own inverse. The power set of any set becomes a Boolean ring with symmetric difference as the addition of the ring and intersection as the multiplication of the ring.
The symmetric difference is equivalent to the union of both relative complements, that is:
and it can also be expressed as the union of the two sets, minus their intersection:
or with the XOR operation:
The symmetric difference is commutative and associative:
Thus, the repeated symmetric difference is an operation on a multiset of sets giving the set of elements which are in an odd number of sets.
The symmetric difference of two repeated symmetric differences is the repeated symmetric difference of the join of the two multisets, where for each double set both can be removed. In particular:
This implies a sort of triangle inequality: the symmetric difference of A
is contained in the union of the symmetric difference of A
and that of B
. (But note that for the diameter of the symmetric difference the triangle inequality does not hold.)
The empty set is neutral, and every set is its own inverse:
Taken together, we see that the power set of any set X
becomes an abelian group if we use the symmetric difference as operation. Because every element in this group is its own inverse, this is in fact a vector space over the field with 2 elements Z2
. If X
is finite, then the singletons form a basis of this vector space, and its dimension is therefore equal to the number of elements of X
. This construction is used in graph theory, to define the cycle space of a graph.
Intersection distributes over symmetric difference:
and this shows that the power set of X
becomes a ring with symmetric difference as addition and intersection as multiplication. This is the prototypical example of a Boolean ring.
Further properties of the symmetric difference:
The symmetric difference can be defined in any Boolean algebra, by writing
This operation has the same properties as the symmetric difference of sets.
As above, the symmetric difference of a collection of sets contains just elements which are in an odd number of the sets in the collection:
Evidently, this is well-defined only when each element of the union
is contributed by a finite number of elements of
is a multiset and
. Then there is a formula for
, the number of elements in
, given solely in terms of intersections of elements of
is meant to indicate that
is a subset of distinct elements of
, of which there are
As long as there is a notion of "how big" a set is, the symmetric difference between two sets can be considered a measure of how "far apart" they are. Formally, if μ is a σ-finite measure defined on a σ-algebra Σ, the function,
is a pseudometric on Σ. d
becomes a metric if Σ is considered modulo the equivalence relation X
if and only if
. The resulting metric space is separable if and only if (μ)2L is separable.
be some measure space and let
Symmetric difference is measurable:
. The relation "
" is an equivalence relation on the
iff to each
. The relation "
" is a partial order on the family of subsets of
. The relation "
" is an equivalence relationship between the subsets of
The "symmetric closure" of
is the collection of all
-measurable sets that are
. The symmetric closure of
is a sub-
, so is the symmetric closure of
is a mathematical operation that represents the total amount of objects together in a collection. It is signified by the plus sign (+). For example, in the picture on the right, there are 3 + 2 apples—meaning three apples and two apples together, which is a total of 5 apples. Therefore, 3 + 2 = 5. Besides counting fruits, addition can also represent combining other physical and abstract quantities using different kinds of objects: negative numbers, fractions, irrational numbers, vectors, decimals, functions, matrices and more.
Addition follows several important patterns. It is commutative, meaning that order does not matter, and it is associative, meaning that when one adds more than two numbers, order in which addition is performed does not matter (see Summation
). Repeated addition of 1 is the same as counting; addition of 0 does not change a number. Addition also obeys predictable rules concerning related operations such as subtraction and multiplication. All of these rules can be proven, starting with the addition of natural numbers and generalizing up through the real numbers and beyond. General binary operations that continue these patterns are studied in abstract algebra.
Performing addition is one of the simplest numerical tasks. Addition of very small numbers is accessible to toddlers; the most basic task, 1 + 1, can be performed by infants as young as five months and even some animals. In primary education, students are taught to add numbers in the decimal system, starting with single digits and progressively tackling more difficult problems. Mechanical aids range from the ancient abacus to the modern computer, where research on the most efficient implementations of addition continues to this day.
Addition is written using the plus sign "+" between the terms; that is, in infix notation. The result is expressed with an equals sign. For example,
There are also situations where addition is "understood" even though no symbol appears:
The sum of a series of related numbers can be expressed through capital sigma notation, which compactly denotes iteration. For example,
The numbers or the objects to be added in general addition are called the terms
, the addends
, or the summands
; this terminology carries over to the summation of multiple terms. This is to be distinguished from factors
, which are multiplied. Some authors call the first addend the augend
. In fact, during the Renaissance, many authors did not consider the first addend an "addend" at all. Today, due to the commutative property of addition, "augend" is rarely used, and both terms are generally called addends.
All of this terminology derives from Latin. "Addition" and "add" are English words derived from the Latin verb addere
, which is in turn a compound of ad
"to" and dare
"to give", from the Proto-Indo-European root "to give"; thus to add
is to give to
. Using the gerundive suffix -nd
results in "addend", "thing to be added". Likewise from augere
"to increase", one gets "augend", "thing to be increased".
"Sum" and "summand" derive from the Latin noun summa
"the highest, the top" and associated verb summare
. This is appropriate not only because the sum of two positive numbers is greater than either, but because it was once common to add upward, contrary to the modern practice of adding downward, so that a sum was literally higher than the addends. Addere
date back at least to Boethius, if not to earlier Roman writers such as Vitruvius and Frontinus; Boethius also used several other terms for the addition operation. The later Middle English terms "adden" and "adding" were popularized by Chaucer.
Addition is used to model countless physical processes. Even for the simple case of adding natural numbers, there are many possible interpretations and even more visual representations.
Possibly the most fundamental interpretation of addition lies in combining sets:
This interpretation is easy to visualize, with little danger of ambiguity. It is also useful in higher mathematics; for the rigorous definition it inspires, see Natural numbers
below. However, it is not obvious how one should extend this version of addition to include fractional numbers or negative numbers.
One possible fix is to consider collections of objects that can be easily divided, such as pies or, still better, segmented rods. Rather than just combining collections of segments, rods can be joined end-to-end, which illustrates another conception of addition: adding not the rods but the lengths of the rods.
A second interpretation of addition comes from extending an initial length by a given length:
The sum a
can be interpreted as a binary operation that combines a
, in an algebraic sense, or it can be interpreted as the addition of b
more units to a
. Under the latter interpretation, the parts of a sum a
play asymmetric roles, and the operation a
is viewed as applying the unary operation +b
. Instead of calling both a
addends, it is more appropriate to call a
in this case, since a
plays a passive role. The unary view is also useful when discussing subtraction, because each unary addition operation has an inverse unary subtraction operation, and vice versa.
Addition is commutative, meaning that one can reverse the terms in a sum left-to-right, and the result is the same as the last one. Symbolically, if a
are any two numbers, then
The fact that addition is commutative is known as the "commutative law of addition". This phrase suggests that there are other commutative laws: for example, there is a commutative law of multiplication. However, many binary operations are not commutative, such as subtraction and division, so it is misleading to speak of an unqualified "commutative law".
A somewhat subtler property of addition is associativity, which comes up when one tries to define repeated addition. Should the expression
be defined to mean (a
) + c
)? That addition is associative tells us that the choice of definition is irrelevant. For any three numbers a
, and c
, it is true that
For example, (1 + 2) + 3 = 3 + 3 = 6 = 1 + 5 = 1 + (2 + 3). Not all operations are associative, so in expressions with other operations like subtraction, it is important to specify the order of operations.
When adding zero to any number, the quantity does not change; zero is the identity element for addition, also known as the additive identity. In symbols, for any a
This law was first identified in Brahmagupta's Brahmasphutasiddhanta
in 628 AD, although he wrote it as three separate laws, depending on whether a
is negative, positive, or zero itself, and he used words rather than algebraic symbols. Later Indian mathematicians refined the concept; around the year 830, Mahavira wrote, "zero becomes the same as what is added to it", corresponding to the unary statement 0 + a
. In the 12th century, Bhaskara wrote, "In the addition of cipher, or subtraction of it, the quantity, positive or negative, remains the same", corresponding to the unary statement a
+ 0 = a
In the context of integers, addition of one also plays a special role: for any integer a
, the integer (a
+ 1) is the least integer greater than a
, also known as the successor of a
. Because of this succession, the value of some a
can also be seen as the
successor of a
, making addition iterated succession.
To numerically add physical quantities with units, they must first be expressed with common units. For example, if a measure of 5 feet is extended by 2 inches, the sum is 62 inches, since 60 inches is synonymous with 5 feet. On the other hand, it is usually meaningless to try to add 3 meters and 4 square meters, since those units are incomparable; this sort of consideration is fundamental in dimensional analysis.
Studies on mathematical development starting around the 1980s have exploited the phenomenon of habituation: infants look longer at situations that are unexpected. A seminal experiment by Karen Wynn in 1992 involving Mickey Mouse dolls manipulated behind a screen demonstrated that five-month-old infants expect
1 + 1 to be 2, and they are comparatively surprised when a physical situation seems to imply that 1 + 1 is either 1 or 3. This finding has since been affirmed by a variety of laboratories using different methodologies. Another 1992 experiment with older toddlers, between 18 to 35 months, exploited their development of motor control by allowing them to retrieve ping-pong balls from a box; the youngest responded well for small numbers, while older subjects were able to compute sums up to 5.
Even some nonhuman animals show a limited ability to add, particularly primates. In a 1995 experiment imitating Wynn's 1992 result (but using eggplants instead of dolls), rhesus macaques and cottontop tamarins performed similarly to human infants. More dramatically, after being taught the meanings of the Arabic numerals 0 through 4, one chimpanzee was able to compute the sum of two numerals without further training.
Typically, children first master counting. When given a problem that requires that two items and three items be combined, young children model the situation with physical objects, often fingers or a drawing, and then count the total. As they gain experience, they learn or discover the strategy of "counting-on": asked to find two plus three, children count three past two, saying "three, four, five
" (usually ticking off fingers), and arriving at five. This strategy seems almost universal; children can easily pick it up from peers or teachers. Most discover it independently. With additional experience, children learn to add more quickly by exploiting the commutativity of addition by counting up from the larger number, in this case starting with three and counting "four, five
." Eventually children begin to recall certain addition facts ("number bonds"), either through experience or rote memorization. Once some facts are committed to memory, children begin to derive unknown facts from known ones. For example, a child asked to add six and seven may know that 6+6=12 and then reason that 6+7 is one more, or 13. Such derived facts can be found very quickly and most elementary school student eventually rely on a mixture of memorized and derived facts to add fluently.
The prerequisite to addition in the decimal system is the fluent recall or derivation of the 100 single-digit "addition facts". One could memorize all the facts by rote, but pattern-based strategies are more enlightening and, for most people, more efficient:
As students grow older, they commit more facts to memory, and learn to derive other facts rapidly and fluently. Many students never commit all the facts to memory, but can still find any basic fact quickly.
The standard algorithm for adding multidigit numbers is to align the addends vertically and add the columns, starting from the ones column on the right. If a column exceeds ten, the extra digit is "carried" into the next column. An alternate strategy starts adding from the most significant digit on the left; this route makes carrying a little clumsier, but it is faster at getting a rough estimate of the sum. There are many other alternative methods.
Analog computers work directly with physical quantities, so their addition mechanisms depend on the form of the addends. A mechanical adder might represent two addends as the positions of sliding blocks, in which case they can be added with an averaging lever. If the addends are the rotation speeds of two shafts, they can be added with a differential. A hydraulic adder can add the pressures in two chambers by exploiting Newton's second law to balance forces on an assembly of pistons. The most common situation for a general-purpose analog computer is to add two voltages (referenced to ground); this can be accomplished roughly with a resistor network, but a better design exploits an operational amplifier.
Addition is also fundamental to the operation of digital computers, where the efficiency of addition, in particular the carry mechanism, is an important limitation to overall performance.
Blaise Pascal invented the mechanical calculator in 1642, it was the first operational adding machine. It made use of an ingenious gravity-assisted carry mechanism. It was the only operational mechanical calculator in the 17th century and the earliest automatic, digital computers. Pascal's calculator was limited by its carry mechanism which forced its wheels to only turn one way, so it could add but, to subtract, the operator had to use of the method of complements which required as many steps as an addition. Pascal was followed by Giovanni Poleni who built the second functional mechanical calculator in 1709, a calculating clock, which was made of wood and which could, once setup, multiply two numbers automatically.
Adders execute integer addition in electronic digital computers, usually using binary arithmetic. The simplest architecture is the ripple carry adder, which follows the standard multi-digit algorithm. One slight improvement is the carry skip design, again following human intuition; one does not perform all the carries in computing 999 + 1, but one bypasses the group of 9s and skips to the answer.
Since they compute digits one at a time, the above methods are too slow for most modern purposes. In modern digital computers, integer addition is typically the fastest arithmetic instruction, yet it has the largest impact on performance, since it underlies all the floating-point operations as well as such basic tasks as address generation during memory access and fetching instructions during branching. To increase speed, modern designs calculate digits in parallel; these schemes go by such names as carry select, carry lookahead, and the Ling pseudocarry. Almost all modern implementations are, in fact, hybrids of these last three designs.
Unlike addition on paper, addition on a computer often changes the addends. On the ancient abacus and adding board, both addends are destroyed, leaving only the sum. The influence of the abacus on mathematical thinking was strong enough that early Latin texts often claimed that in the process of adding "a number to a number", both numbers vanish. In modern times, the ADD instruction of a microprocessor replaces the augend with the sum but preserves the addend. In a high-level programming language, evaluating a
does not change either a
; if the goal is to replace a
with the sum this must be explicitly requested, typically with the statement a
. Some languages such as C or C++ allow this to be abbreviated as a
To prove the usual properties of addition, one must first define
addition for the context in question. Addition is first defined on the natural numbers. In set theory, addition is then extended to progressively larger sets that include the natural numbers: the integers, the rational numbers, and the real numbers. (In mathematics education, positive fractions are added before negative numbers are even considered; this is also the historical route)
There are two popular ways to define the sum of two natural numbers a
. If one defines natural numbers to be the cardinalities of finite sets, (the cardinality of a set is the number of elements in the set), then it is appropriate to define their sum as follows:
is the union of A
. An alternate version of this definition allows A
to possibly overlap and then takes their disjoint union, a mechanism that allows common elements to be separated out and therefore counted twice.
The other popular definition is recursive:
Again, there are minor variations upon this definition in the literature. Taken literally, the above definition is an application of the Recursion Theorem on the poset N
2. On the other hand, some sources prefer to use a restricted Recursion Theorem that applies only to the set of natural numbers. One then considers a
to be temporarily "fixed", applies recursion on b
to define a function "a
+ ", and pastes these unary operations for all a
together to form the full binary operation.
This recursive formulation of addition was developed by Dedekind as early as 1854, and he would expand upon it in the following decades. He proved the associative and commutative properties, among others, through mathematical induction; for examples of such inductive proofs, see Addition of natural numbers
The simplest conception of an integer is that it consists of an absolute value (which is a natural number) and a sign (generally either positive or negative). The integer zero is a special third case, being neither positive nor negative. The corresponding definition of addition must proceed by cases:
Although this definition can be useful for concrete problems, it is far too complicated to produce elegant general proofs; there are too many cases to consider.
A much more convenient conception of the integers is the Grothendieck group construction. The essential observation is that every integer can be expressed (not uniquely) as the difference of two natural numbers, so we may as well define
an integer as the difference of two natural numbers. Addition is then defined to be compatible with subtraction:
Addition of rational numbers can be computed using the least common denominator, but a conceptually simpler definition involves only integer addition and multiplication:
The commutativity and associativity of rational addition is an easy consequence of the laws of integer arithmetic. For a more rigorous and general discussion, see field of fractions
A common construction of the set of real numbers is the Dedekind completion of the set of rational numbers. A real number is defined to be a Dedekind cut of rationals: a non-empty set of rationals that is closed downward and has no greatest element. The sum of real numbers a
is defined element by element:
This definition was first published, in a slightly modified form, by Richard Dedekind in 1872. The commutativity and associativity of real addition are immediate; defining the real number 0 to be the set of negative rationals, it is easily seen to be the additive identity. Probably the trickiest part of this construction pertaining to addition is the definition of additive inverses.
Unfortunately, dealing with multiplication of Dedekind cuts is a case-by-case nightmare similar to the addition of signed integers. Another approach is the metric completion of the rational numbers. A real number is essentially defined to be the a limit of a Cauchy sequence of rationals, lim an
. Addition is defined term by term:
This definition was first published by Georg Cantor, also in 1872, although his formalism was slightly different. One must prove that this operation is well-defined, dealing with co-Cauchy sequences. Once that task is done, all the properties of real addition follow immediately from the properties of rational numbers. Furthermore, the other arithmetic operations, including multiplication, have straightforward, analogous definitions.
There are many binary operations that can be viewed as generalizations of the addition operation on the real numbers. The field of abstract algebra is centrally concerned with such generalized operations, and they also appear in set theory and category theory.
In linear algebra, a vector space is an algebraic structure that allows for adding any two vectors and for scaling vectors. A familiar vector space is the set of all ordered pairs of real numbers; the ordered pair (a
) is interpreted as a vector from the origin in the Euclidean plane to the point (a
) in the plane. The sum of two vectors is obtained by adding their individual coordinates:
This addition operation is central to classical mechanics, in which vectors are interpreted as forces.
In modular arithmetic, the set of integers modulo 12 has twelve elements; it inherits an addition operation from the integers that is central to musical set theory. The set of integers modulo 2 has just two elements; the addition operation it inherits is known in Boolean logic as the "exclusive or" function. In geometry, the sum of two angle measures is often taken to be their sum as real numbers modulo 2π. This amounts to an addition operation on the circle, which in turn generalizes to addition operations on many-dimensional tori.
The general theory of abstract algebra allows an "addition" operation to be any associative and commutative operation on a set. Basic algebraic structures with such an addition operation include commutative monoids and abelian groups.
A far-reaching generalization of addition of natural numbers is the addition of ordinal numbers and cardinal numbers in set theory. These give two different generalizations of addition of natural numbers to the transfinite. Unlike most addition operations, addition of ordinal numbers is not commutative. Addition of cardinal numbers, however, is a commutative operation closely related to the disjoint union operation.
In category theory, disjoint union is seen as a particular case of the coproduct operation, and general coproducts are perhaps the most abstract of all the generalizations of addition. Some coproducts, such as Direct sum
and Wedge sum
, are named to evoke their connection with addition.
can be thought of as a kind of addition—that is, the addition of an additive inverse. Subtraction is itself a sort of inverse to addition, in that adding x
and subtracting x
are inverse functions.
Given a set with an addition operation, one cannot always define a corresponding subtraction operation on that set; the set of natural numbers is a simple example. On the other hand, a subtraction operation uniquely determines an addition operation, an additive inverse operation, and an additive identity; for this reason, an additive group can be described as a set that is closed under subtraction.
can be thought of as repeated addition. If a single term x
appears in a sum n
times, then the sum is the product of n
. If n
is not a natural number, the product may still make sense; for example, multiplication by −1 yields the additive inverse of a number.
In the real and complex numbers, addition and multiplication can be interchanged by the exponential function:
This identity allows multiplication to be carried out by consulting a table of logarithms and computing addition by hand; it also enables multiplication on a slide rule. The formula is still a good first-order approximation in the broad context of Lie groups, where it relates multiplication of infinitesimal group elements with addition of vectors in the associated Lie algebra.
There are even more generalizations of multiplication than addition. In general, multiplication operations always distribute over addition; this requirement is formalized in the definition of a ring. In some contexts, such as the integers, distributivity over addition and the existence of a multiplicative identity is enough to uniquely determine the multiplication operation. The distributive property also provides information about addition; by expanding the product (1 + 1)(a
) in both ways, one concludes that addition is forced to be commutative. For this reason, ring addition is commutative in general.
is an arithmetic operation remotely related to addition. Since a
−1), division is right distributive over addition: (a
) / c
. However, division is not left distributive over addition; 1/ (2 + 2) is not the same as 1/2 + 1/2.
The maximum operation
)" is a binary operation similar to addition. In fact, if two nonnegative numbers a
are of different orders of magnitude, then their sum is approximately equal to their maximum. This approximation is extremely useful in the applications of mathematics, for example in truncating Taylor series. However, it presents a perpetual difficulty in numerical analysis, essentially since "max" is not invertible. If b
is much greater than a
, then a straightforward calculation of (a
) − b
can accumulate an unacceptable round-off error, perhaps even returning zero. See also Loss of significance
The approximation becomes exact in a kind of infinite limit; if either a
is an infinite cardinal number, their cardinal sum is exactly equal to the greater of the two. Accordingly, there is no subtraction operation for infinite cardinals.
Maximization is commutative and associative, like addition. Furthermore, since addition preserves the ordering of real numbers, addition distributes over "max" in the same way that multiplication distributes over addition:
For these reasons, in tropical geometry one replaces multiplication with addition and addition with maximization. In this context, addition is called "tropical multiplication", maximization is called "tropical addition", and the tropical "additive identity" is negative infinity. Some authors prefer to replace addition with minimization; then the additive identity is positive infinity.
Tying these observations together, tropical addition is approximately related to regular addition through the logarithm:
which becomes more accurate as the base of the logarithm increases. The approximation can be made exact by extracting a constant h
, named by analogy with Planck's constant from quantum mechanics, and taking the "classical limit" as h
tends to zero:
In this sense, the maximum operation is a dequantized
version of addition.
, also known as the successor operation, is the addition of 1 to a number.
describes the addition of arbitrarily many numbers, usually more than just two. It includes the idea of the sum of a single number, which is itself, and the empty sum, which is zero. An infinite summation is a delicate procedure known as a series.
a finite set is equivalent to summing 1 over the set.
is a kind of "summation" over a continuum, or more precisely and generally, over a differentiable manifold. Integration over a zero-dimensional manifold reduces to summation.
combine multiplication and summation; they are sums in which each term has a multiplier, usually a real or complex number. Linear combinations are especially useful in contexts where straightforward addition would violate some normalization rule, such as mixing of strategies in game theory or superposition of states in quantum mechanics.
is used to add two independent random variables defined by distribution functions. Its usual definition combines integration, subtraction, and multiplication. In general, convolution is useful as a kind of domain-side addition; by contrast, vector addition is a kind of range-side addition.
The ones' complement of a binary number is defined as the value obtained by inverting all the bits in the binary representation of the number (swapping 0's for 1's and vice-versa). The ones' complement of the number then behaves like the negative of the original number in some arithmetic operations. To within a constant (of −1), the ones' complement behaves like the negative of the original number with binary addition. However, unlike two's complement, these numbers have not seen widespread use because of issues such as the offset of −1, that negating zero results in a distinct negative zero bit pattern, less simplicity with arithmetic borrowing, etc.
A ones' complement system or ones' complement arithmetic is a system in which negative numbers are represented by the arithmetic negative of the value. In such a system, a number is negated (converted from positive to negative or vice versa) by computing its ones' complement. An N-bit ones' complement numeral system can only represent integers in the range −(2N−1−1) to 2N−1−1 while two's complement can express −2N−1 to 2N−1−1.
The ones' complement binary numeral system is characterized by the bit complement of any integer value being the arithmetic negative of the value. That is, inverting all of the bits of a number (the logical complement) produces the same result as subtracting the value from 0.
The early days of digital computing were marked by a lot of competing ideas about both hardware technology and mathematics technology (numbering systems). One of the great debates was the format of negative numbers, with some of the era's most expert people having very strong and different opinions][. One camp supported two's complement, the system that is dominant today. Another camp supported ones' complement, where any positive value is made into its negative equivalent by inverting all of the bits in a word. A third group supported "sign & magnitude" (sign-magnitude), where a value is changed from positive to negative simply by toggling the word's sign (high-order) bit.
There were arguments for and against each of the systems.][ Sign & magnitude allowed for easier tracing of memory dumps (a common process 40 years ago) as numeric values tended to use fewer 1 bits][. Internally, these systems did ones' complement math so numbers would have to be converted to ones' complement values when they were transmitted from a register to the math unit and then converted back to sign-magnitude when the result was transmitted back to the register][. The electronics required more gates than the other systems – a key concern when the cost and packaging of discrete transistors was critical. IBM was one of the early supporters of sign-magnitude, with their 7090 (709x series) computers perhaps the best known architecture to use it.
Ones' complement allowed for somewhat simpler hardware designs as there was no need to convert values when passed to and from the math unit. But it also shared an undesirable characteristic with sign-magnitude – the ability to represent negative zero (−0). Negative zero behaves exactly like positive zero; when used as an operand in any calculation, the result will be the same whether an operand is positive or negative zero. The disadvantage, however, is that the existence of two forms of the same value necessitates two rather than a single comparison when checking for equality with zero. Ones' complement subtraction can also result in an end-around borrow (described below). It can be argued that this makes the addition/subtraction logic more complicated or that it makes it simpler as a subtraction requires simply inverting the bits of the second operand as it is passed to the adder. The CDC 6000 series, UNIVAC 1100 series, and the LINC computer used ones' complement representation.
Two's complement is the easiest to implement in hardware, which may be the ultimate reason for its widespread popularity][. Processors on the early mainframes often consisted of thousands of transistors – eliminating a significant number of transistors was a significant cost savings. The architects of the early integrated circuit-based CPUs (Intel 8080, etc.) chose to use two's complement math. As IC technology advanced, virtually all adopted two's complement technology. Intel, AMD, and Power Architecture chips are all two's complement.][
Positive numbers are the same simple, binary system used by two's complement and sign-magnitude. Negative values are the bit complement of the corresponding positive value. The largest positive value is characterized by the sign (high-order) bit being off (0) and all other bits being on (1). The smallest negative value is characterized by the sign bit being 1, and all other bits being 0. The table below shows all possible values in a 4-bit system, from −7 to +7.
Adding two values is straight forward. Simply align the values on the least significant bit and add, propagating any carry to the bit one position left. If the carry extends past the end of the word it is said to have "wrapped around", a condition called an "end-around carry". When this occurs, the bit must be added back in at the right-most bit. This phenomenon does not occur in two's complement arithmetic.
Subtraction is similar, except that borrows, rather than carries, are propagated to the left. If the borrow extends past the end of the word it is said to have "wrapped around", a condition called an "end-around borrow". When this occurs, the bit must be subtracted from the right-most bit. This phenomenon does not occur in two's complement arithmetic.
It is easy to demonstrate that the bit complement of a positive value is the negative magnitude of the positive value. The computation of 19 + 3 produces the same result as 19 − (−3).
Add 3 to 19.
Subtract −3 from 19.
Negative zero is the condition where all bits in a signed word are 1. This follows the ones' complement rules that a value is negative when the left-most bit is 1, and that a negative number is the bit complement of the number's magnitude. The value also behaves as zero when computing. Adding or subtracting negative zero to/from another value produces the original value.
Adding negative zero:
Subtracting negative zero:
Negative zero is easily produced in a 1's complement adder. Simply add the positive and negative of the same magnitude.
Although the math always produces the correct results, a side effect of negative zero is that software must test for negative zero.
The generation of negative zero becomes a non-issue if addition is achieved with a complementing subtractor. The first operand is passed to the subtract unmodified, the second operand is complemented, and the subtraction generates the correct result, avoiding negative zero. The previous example added 22 and −22 and produced −0.
The interesting "corner cases" are when one or both operands are zero and/or negative zero.
Subtracting +0 is trivial (as shown above). If the second operand is negative zero it is inverted and the original value of the first operand is the result. Subtracting −0 is also trivial. The result can be only 1 of two cases. In case 1, operand 1 is −0 so the result is produced simply by subtracting 1 from 1 at every bit position. In case 2, the subtraction will generate a value that is 1 larger than operand 1 and an end around borrow. Completing the borrow generates the same value as operand 1.
The only really interesting case is when both operands are plus or minus zero. Look at this example:
This example shows that of the 4 possible conditions when adding only ±0, an adder will produce −0 in three of them. A complementing subtractor will produce −0 only when both operands are −0.
Donald Knuth: The Art of Computer Programming, Volume 2: Seminumerical Algorithms, chapter 4.1
Sum of absolute differences (SAD) is an algorithm for measuring the similarity between image blocks. It works by taking the absolute difference between each pixel in the original block and the corresponding pixel in the block being used for comparison. These differences are summed to create a simple metric of block similarity, the norm1L of the difference image or Manhattan distance between two image blocks.
The sum of absolute differences may be used for a variety of purposes, such as object recognition, the generation of disparity maps for stereo images, and motion estimation for video compression.
This example uses the sum of absolute differences to identify which part of a search image is most similar to a template image. In this example, the template image is 3 by 3 pixels in size, while the search image is 3 by 5 pixels in size. Each pixel is represented by a single integer from 0 to 9.
There are exactly three unique locations within the search image where the template may fit: the left side of the image, the center of the image, and the right side of the image. To calculate the SAD values, the absolute value of the difference between each corresponding pair of pixels is used: the difference between 2 and 2 is 0, 4 and 1 is 3, 7 and 8 is 1, and so forth.
Calculating the SAD values for each of these locations gives the following:
For each of these three image patches, the absolute differences are added together, giving a SAD value of 20, 25, and 17, respectively. From these SAD values, it is apparent that the right side of the search image is the most similar to the template image, because it has the least difference as compared to the other locations.
The sum of absolute differences provides a simple way to automate the searching for objects inside an image, but may be unreliable due to the effects of contextual factors such as changes in lighting, color, viewing direction, size, or shape. The SAD may be used in conjunction with other object recognition methods, such as edge detection, to improve the reliability of results.
SAD is an extremely fast metric due to its simplicity; it is effectively the simplest possible metric that takes into account every pixel in a block. Therefore it is very effective for a wide motion search of many different blocks. SAD is also easily parallelizable since it analyzes each pixel separately, making it easily implementable with such instructions as MMX and SSE2. For example, SSE has packed sum of absolute differences instruction (PSADBW) specifically for this purpose. Once candidate blocks are found, the final refinement of the motion estimation process is often done with other slower but more accurate metrics, which better take into account human perception. These include the sum of absolute transformed differences (SATD), the sum of squared differences (SSD), and rate-distortion optimization.
Strictly standardized mean difference
Casting out nines