Division by zero

Graph showing the diagrammatic representation of limits approaching infinity
The function y = 1/x. As x approaches 0 from the right, y approaches infinity. As x approaches 0 from the left, y approaches negative infinity.

In mathematics, division by zero, division where the divisor (denominator) is zero, is a unique and problematic special case. Using fraction notation, the general example can be written as , where is the dividend (numerator).

The usual definition of the quotient in elementary arithmetic is the number which yields the dividend when multiplied by the divisor. That is, is equivalent to By this definition, the quotient is nonsensical, as the product is always rather than some other number Following the ordinary rules of elementary algebra while allowing division by zero can create a mathematical fallacy, a subtle mistake leading to absurd results. To prevent this, the arithmetic of real numbers and more general numerical structures called fields leaves division by zero undefined, and situations where division by zero might occur must be treated with care. Since any number multiplied by zero is zero, the expression is also undefined.

Calculus studies the behavior of functions in the limit as their input tends to some value. When a real function involves division by a quantity tending to zero, the output of the function becomes arbitrarily large, and is said to "tend to infinity", a type of mathematical singularity. For example, the reciprocal function, tends to infinity as tends to from above. When a function involves the quotient of two functions which both tend to zero at the same input, it is called an indeterminate form, as the resulting behavior depends on which functions are being considered.

As an alternative to the common convention of working with fields such as the real numbers and leaving division by zero undefined, it is possible to define the result of division by zero in other ways, resulting in different number systems. For example, the quotient can be defined to equal zero; it can be defined to equal a new explicit point at infinity, sometimes denoted by the infinity symbol ; or it can be defined to result in signed infinity, with positive or negative sign depending on the sign of the dividend. In these number systems division by zero is no longer a special exception per se, but the point or points at infinity involve their own new types of exceptional behavior.

In computing, an error may result from an attempt to divide by zero. Depending on the context and the type of number involved, dividing by zero may output positive or negative infinity or a special not-a-number value, generate an exception, display an error message, or crash the program.

Elementary arithmetic

The meaning of division

When division is explained at the elementary arithmetic level, it is often considered as splitting a set of objects into equal parts. As an example, consider having ten cookies, and these cookies are to be distributed equally to five people at a table. Each person would receive cookies. Similarly, if there are ten cookies, and only one person at the table, that person would receive cookies. So, "dividing by zero" would mean finding the number of cookies that each person receives when 10 cookies are evenly distributed among 0 people at a table. But there is no way to distribute 10 cookies to nobody. Therefore, —at least in elementary arithmetic—is said to be either meaningless or undefined.

Division is the inverse of multiplication. For example,

since 2 is the value for which the unknown quantity in is true. But the expression requires a value to be found for the unknown quantity in But any number multiplied by 0 is 0 and so there is no number that solves the equation. Likewise, considering the 10/0 example above, setting x = 10/0, if x equals ten divided by zero, then x times zero equals ten, but there is no x that, when multiplied by zero, gives ten (or any number other than zero). If, instead of x = 10/0, x = 0/0, then every x satisfies the question "what number x, multiplied by zero, gives zero?"

The expression

requires a value to be found for the unknown quantity in Again, any number multiplied by 0 is 0 and so this time every number solves the equation instead of there being a single number that can be taken as the value of 0/0.

In general, a single value cannot be assigned to a fraction where the denominator is 0, so the value remains undefined. Said another way, it follows from the properties of ordinary arithmetic that if b ≠ 0, then the equation a/b = c is equivalent to a = b × c. If we allowed a zero denominator, we would arrive at either a contradiction, or an equation that was true no matter what value we assigned the "fraction". If a/0 were a number c, then it would follow that a = 0 × c = 0. However, the single number c would then have to be determined by the equation 0 = 0 × c, which is satisfied by every number. We cannot assign a numerical value to 0/0 and instead say that division by zero is not allowed.

Fallacies

A compelling reason for not allowing division by zero is that, if it were allowed, many absurd results (i.e., fallacies) would arise. When working with numerical quantities it is easy to determine when an illegal attempt to divide by zero is being made. For example, consider the following computation.

With the assumptions:

the following is true:

Dividing both sides by zero gives:

Simplified, this yields:

The fallacy here is the assumption that dividing 0 by 0 is a legitimate operation with the same properties as dividing by any other number.

However, it is possible to disguise a division by zero in an algebraic argument, leading to invalid proofs that, for instance, 1 = 2 such as the following:

Let 1 = x.

Multiply by x to get

Subtract 1 from each side to get Divide both sides by x − 1 which simplifies to But, since x = 1, and therefore

The disguised division by zero occurs since x − 1 = 0 when x = 1.

Early attempts

The Brāhmasphuṭasiddhānta of Brahmagupta (c. 598–668) is the earliest text to treat zero as a number in its own right and to define operations involving zero. The author could not explain division by zero in his texts: his definition can be easily proven to lead to algebraic absurdities. According to Brahmagupta,

A positive or negative number when divided by zero is a fraction with the zero as denominator. Zero divided by a negative or positive number is either zero or is expressed as a fraction with zero as numerator and the finite quantity as denominator. Zero divided by zero is zero.

In 830, Mahāvīra unsuccessfully tried to correct the mistake Brahmagupta made in his book Ganita Sara Samgraha: "A number remains unchanged when divided by zero."

Historically, one of the earliest recorded references to the mathematical impossibility of assigning a value to is contained in Anglo-Irish philosopher George Berkeley's criticism of infinitesimal calculus in 1734 in The Analyst ("ghosts of departed quantities").

Calculus

Calculus studies the behavior of functions using the concept of a limit, the value to which a function's output tends as its input tends to some specific value. The limit is denoted meaning that the value of the function can be made arbitrarily close to by choosing sufficiently close to

In the case where the limit of the real function increases without bound as tends to the function is not defined at a type of mathematical singularity. Instead, the function is said to "tend to infinity", denoted While such a function is not formally defined for and the infinity symbol in this case does not represent any specific real number, such limits are informally said to "equal infinity". If the value of the function decreases without bound, the function is said to "tend to negative infinity", In some cases a function tends to two different values when tends to from above () and below (); such a function has two distinct one-sided limits.

A basic example of an infinite singularity is the reciprocal function, which tends to positive or negative infinity as tends to :

In most cases, the limit of a quotient of functions is equal to the quotient of the limits of each function separately,

However, when a function is constructed by dividing two functions whose separate limits are both equal to the limit of the result cannot be determined from the separate limits, so this is called an indeterminate form, informally written Such a limit may equal any real value, may tend to infinity, or may not converge at all, depending on the particular functions.

For example, consider the limit

This is an indeterminate form since the separate limits of the numerator and denominator are both equal to However, in this case the numerator can be factored with one factor equal to the denominator. Because whenever is well defined, the example can be simplified,

so the limit exists and is equal to

Alternative number systems

Extended real line

The extended real number line is obtained from the real number system by adding two infinity elements: and read as "positive infinity" and "negative infinity" respectively, which are treated as actual numbers. By adjoining the elements and to it enables a formulation of a "limit at infinity" that works like a limit at any real number. When dealing with both positive and negative extended real numbers, the expression is usually left undefined. However, in contexts where only non-negative values are considered, it is often convenient to define .

Projectively extended real line

The set is the projectively extended real line, which is a one-point compactification of the real line. Here means an unsigned infinity or point at infinity, an infinite quantity that is neither positive nor negative. This quantity satisfies , which is necessary in this context. In this structure, can be defined for nonzero a, and when a is not . It is the natural way to view the range of the tangent function and cotangent functions of trigonometry: tan(x) approaches the single point at infinity as x approaches either + π/2 or π/2 from either direction.

This definition leads to many interesting results. However, the resulting algebraic structure is not a field, and should not be expected to behave like one. For example, is undefined in this extension of the real line.

Riemann sphere

The subject of complex analysis applies the concepts of calculus in the complex numbers. Of major importance in this subject is the Riemann sphere, the set . Here represents complex infinity, which is also a point at infinity. This set is analogous to the projectively extended real line, except that it is based on the field of complex numbers. In the Riemann sphere, and , but , , and are undefined.

Higher mathematics

The four basic operations – addition, subtraction, multiplication and division – as applied to whole numbers (positive integers), with some restrictions, in elementary arithmetic are used as a framework to support the extension of the realm of numbers to which they apply. For instance, to make it possible to subtract any whole number from another, the realm of numbers must be expanded to the entire set of integers in order to incorporate the negative integers. Similarly, to support division of any integer by any other, the realm of numbers must expand to the rational numbers. During this gradual expansion of the number system, care is taken to ensure that the "extended operations", when applied to the older numbers, do not produce different results. Loosely speaking, since division by zero has no meaning (is undefined) in the whole number setting, this remains true as the setting expands to the real or even complex numbers.

As the realm of numbers to which these operations can be applied expands there are also changes in how the operations are viewed. For instance, in the realm of integers, subtraction is no longer considered a basic operation since it can be replaced by addition of signed numbers. Similarly, when the realm of numbers expands to include the rational numbers, division is replaced by multiplication by certain rational numbers. In keeping with this change of viewpoint, the question, "Why can't we divide by zero?", becomes "Why can't a rational number have a zero denominator?". Answering this revised question precisely requires close examination of the definition of rational numbers.

In the modern approach to constructing the field of real numbers, the rational numbers appear as an intermediate step in the development that is founded on set theory. First, the natural numbers (including zero) are established on an axiomatic basis such as Peano's axiom system and then this is expanded to the ring of integers. The next step is to define the rational numbers keeping in mind that this must be done using only the sets and operations that have already been established, namely, addition, multiplication and the integers. Starting with the set of ordered pairs of integers, {(a, b)} with b ≠ 0, define a binary relation on this set by (a, b) ≃ (c, d) if and only if ad = bc. This relation is shown to be an equivalence relation and its equivalence classes are then defined to be the rational numbers. It is in the formal proof that this relation is an equivalence relation that the requirement that the second coordinate is not zero is needed (for verifying transitivity).

Although division by zero cannot be sensibly defined with real numbers and integers, it is possible to consistently define it, or similar operations, in other mathematical structures.

Non-standard analysis

In the hyperreal numbers, division by zero is still impossible, but division by non-zero infinitesimals is possible. The same holds true in the surreal numbers.

Distribution theory

In distribution theory one can extend the function to a distribution on the whole space of real numbers (in effect by using Cauchy principal values). It does not, however, make sense to ask for a "value" of this distribution at x = 0; a sophisticated answer refers to the singular support of the distribution.

Linear algebra

In matrix algebra, square or rectangular blocks of numbers are manipulated as though they were numbers themselves: matrices can be added and multiplied, and in some cases, a version of division also exists. Dividing by a matrix means, more precisely, multiplying by its inverse. Not all matrices have inverses. For example, a matrix containing only zeros is not invertible.

One can define a pseudo-division, by setting a/b = ab+, in which b+ represents the pseudoinverse of b. It can be proven that if b−1 exists, then b+ = b−1. If b equals 0, then b+ = 0.

Abstract algebra

In abstract algebra, the integers, the rational numbers, the real numbers, and the complex numbers can be abstracted to more general algebraic structures, such as a commutative ring, which is a mathematical structure where addition, subtraction, and multiplication behave as they do in the more familiar number systems, but division may not be defined. Adjoining a multiplicative inverses to a commutative ring is called localization. However, the localization of every commutative ring at zero is the trivial ring, where , so nontrivial commutative rings do not have inverses at zero, and thus division by zero is undefined for nontrivial commutative rings.

Nevertheless, any number system that forms a commutative ring can be extended to a seldom used structure called a wheel in which division by zero is always possible. However, the resulting mathematical structure is no longer a commutative ring, as multiplication no longer distributes over addition. Furthermore, in a wheel, division of an element by itself no longer results in the multiplicative identity element , and if the original system was an integral domain, the multiplication in the wheel no longer results in a cancellative semigroup.

The concepts applied to standard arithmetic are similar to those in more general algebraic structures, such as rings and fields. In a field, every nonzero element is invertible under multiplication; as above, division poses problems only when attempting to divide by zero. This is likewise true in a skew field (which for this reason is called a division ring). However, in other rings, division by nonzero elements may also pose problems. For example, the ring Z/6Z of integers mod 6. The meaning of the expression should be the solution x of the equation . But in the ring Z/6Z, 2 is a zero divisor. This equation has two distinct solutions, x = 1 and x = 4, so the expression is undefined.

In field theory, the expression is only shorthand for the formal expression ab−1, where b−1 is the multiplicative inverse of b. Since the field axioms only guarantee the existence of such inverses for nonzero elements, this expression has no meaning when b is zero. Modern texts, that define fields as a special type of ring, include the axiom 0 ≠ 1 for fields (or its equivalent) so that the zero ring is excluded from being a field. In the zero ring, division by zero is possible, which shows that the other field axioms are not sufficient to exclude division by zero in a field.

Computer arithmetic

Floating-point arithmetic

In computing, most numerical calculations are done with floating-point arithmetic, which since the 1980s has been standardized by the IEEE 754 specification. In IEEE floating-point arithmetic, numbers are represented using a sign (positive or negative), a fixed-precision significand and an integer exponent. Numbers whose exponent is too large to represent instead "overflow" to positive or negative infinity (+∞ or −∞), while numbers whose exponent is too small to represent instead "underflow" to positive or negative zero (+0 or −0). A NaN (not a number) value represents undefined results.

In IEEE arithmetic, division of 0/0 or ∞/∞ results in NaN, but otherwise division always produces a well-defined result. Dividing any non-zero number by positive zero (+0) results in an infinity of the same sign as the dividend. Dividing any non-zero number by negative zero (−0) results in an infinity of the opposite sign as the dividend. This definition preserves the sign of the result in case of arithmetic underflow.

For example, using single-precision IEEE arithmetic, if x = −2−149, then x/2 underflows to −0, and dividing 1 by this result produces 1/(x/2) = −∞. The exact result −2150 is too large to represent as a single-precision number, so an infinity of the same sign is used instead to indicate overflow.

Integer arithmetic

Integer division by zero handling in various programming languages
Language Comment
Ada raise Constraint_Error
C, C++ Undefined behavior
C# throw DivideByZeroException
Java throw ArithmeticException
JavaScript Dividing the number 0 by 0 returns NaN, dividing a positive number by 0 returns Infinity, dividing a negative number by 0 returns -Infinity
Python raise ZeroDivisionError
Seed7 raise NUMERIC_ERROR
Zig Crashes with the message division by zero and a stack trace.
Coq, Lean Produces 0
Most handheld calculators, such as this Texas Instruments TI-86, will halt execution and display an error message when the user or a running program attempts to divide by zero.

Integer division by zero is usually handled differently from floating point since there is no integer representation for the result. Some processors generate an exception when an attempt is made to divide an integer by zero, although others will simply continue and generate an incorrect result for the division. The result depends on how division is implemented, and can either be zero, or sometimes the largest possible integer.

Because of the improper algebraic results of assigning any value to division by zero, many computer programming languages (including those used by calculators) explicitly forbid the execution of the operation and may prematurely halt a program that attempts it, sometimes reporting a "Divide by zero" error. In these cases, if some special behavior is desired for division by zero, the condition must be explicitly tested (for example, using an if statement). Some programs (especially those that use fixed-point arithmetic where no dedicated floating-point hardware is available) will use behavior similar to the IEEE standard, using large positive and negative numbers to approximate infinities. In some programming languages, an attempt to divide by zero results in undefined behavior.

In two's complement arithmetic, attempts to divide the smallest signed integer by −1 are attended by similar problems, and are handled with the same range of solutions, from explicit error conditions to undefined behavior.

Most calculators will either return an error or state that 1/0 is undefined. Maple and SageMath return an error message for 1/0.

Some modern calculators allow division by zero in special cases, where it will be useful to students and, presumably, understood in context by mathematicians. Some TI and HP graphing calculators will evaluate (1/0)2 to ∞, while Microsoft Math Solver and Wolfram Mathematica return ComplexInfinity for 1/0.

Historical accidents

  • On September 21, 1997, a division by zero error in the "Remote Data Base Manager" aboard USS Yorktown (CG-48) brought down all the machines on the network, causing the ship's propulsion system to fail.

See also