I read this and having admired sauoq's cleverness, got to thinking about a minor bug bear of mine down the years in various programming languages, namely the question on the title of this post.
I've long held the belief that as ^{X}/_{X} is 1 for any other value of X, including (I believe) such exotics as ^{infinity} /_{infinity} in those weird equations that theoretical physicists love to throw around, shouldn't computer languages like Perl (the obligatory tenuous link:^) treat ^{0} /_{0} as a special case and resolve it to 1?
At least that would give correct meaning to the currently misleading message Perl issues: "Illegal division by zero at...". I mean, doesn't saying that imply that at least one case of division by zero isn't illegal?
Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hallo, Mister ladeda. ... Like yer ring!
Re: What is zero divided by zero anyway? by Aristotle (Chancellor) on Oct 05, 2002 at 13:20 UTC 
Even 0 / 0 cannot really be defined. Think about it: how many times does "nothing" fit into "no space"? inf / inf isn't any defined value either since 2 * inf = 3 * inf = 12098341 * inf. I won't claim to be a math wiz, but I have a certain talent for it and I've played with the concepts a bit in my spare time out of curiosity. Zero and infinity both are deep voodoo.
I wish tilly was around to answer this one.
Makeshifts last the longest.
 [reply] 

my $value = get_numeric_value_from_somewhere();
print 'Will always be printed' if ($value/$value) == 1;
# Except for zero!!
the above is true, for 1/1; 1/1; .1/.1; .1/.1; etc. etc. all the way down to the smallest values on either side of zero that any given machine can represent.
Out of interest, after I posted I did a quick google on the net and discovered that at least one computer langauge treats 0/0 as 1. Namely APL, which as its a language essentially designed for mathematical problem solving, at least makes me feel a little better regarding the notion, even if ultimately 0/0=1 isn't correct in the pure math sense.
Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hallo, Mister ladeda. ... Like yer ring!  [reply] [d/l] 

my $value= get_numeric_value_from_somewhere();
eval { print 'Will never be printed' if ($value/0) }
# except for zero, you want?!
The result is true for .1/0, .0001/0, etc. etc. all the way down to the smallest values on either side of zero that any given machine can represent.
Why should it be different for zero itself?
 [reply] [d/l] 

 [reply] 

Not only that, but "infinity" doesn't name one number. There are different infinities ...
For example, the set of natural numbers (0,1,2,3,...), aka N, is a *denumerable* infinity ('denumerable' meaning, 'can be put in a 1:1 correspondence with the members of N'  so N satisfies this definition trivially), as is the set of multiples of 10  EVEN THOUGH that set is a subset of N. The set of multiples of 10 is, intuitively, a tenth the size of N? But no, for every member of the set of multiples of 10, you can find a partner in N.
Moreover, there are nondenumerable infinities (memory gets fuzzy here): the power set (set of all subsets) of N is nondenumerable; and the set of real numbers is also nondenumerable  there are too many points on the real line to put in a 1:1 correspondence with N (intuitively: though with the case of multiples of 10, there is a way to figure out what the next number is, there's no way to find the "next point" given a specific point on the real line).
Isn't math fun?
If not P, what? Q maybe? "Sidney Morgenbesser"
 [reply] 

Yes, and it gets weirder than that if you think further along those lines. In sets beyond the natural numbers, among the real numbers f.ex, any two numbers are separated by an infinite set of numbers. In fact, because you can translate any set of reals delimited by two numbers (exclusive) to any other set of reals delimited by any two numbers (exclusive) with a single multiplication, this means that the distance between any two numbers is equally large.
F.ex, the set of numbers between 1.0 and 2.0 exclusive is inifinite. No matter how many members you assume, there are still more numbers between those. The same is true for the set of numbers between 2.0 and 10.0  it is infinite. But although the interval from 1.0 to 2.0 exclusive is of length 1, and that from 2.0 to 10.0 exclusive is of length 8, you can map the set { x ∈ R ; 1.0 < x < 2.0 } to set { x ∈ R ; 2.0 < x < 10.0 } by simply multiplying by 8.
As I said on the onset of this thread: zero and infinity are deep voodoo. Zero is deceptively so, it looks innocent at first, but it's still voodoo.
Makeshifts last the longest.
 [reply] 
Re: What is zero divided by zero anyway? by zentara (Archbishop) on Oct 05, 2002 at 14:42 UTC 
Well I remember from my math training that division by zero is
undefined. So just remember the simple rule: check for division by
0 and don't allow it. Why should perl try to override a mathematical
principle?  [reply] 
Re: What is zero divided by zero anyway? by abell (Chaplain) on Oct 05, 2002 at 15:24 UTC 
Actually, the result of 0/0 is indetermined, since any number times 0 is 0. Thus, making it 1 is not more "right" than making it 5 or pi.
The stupider the astronaut, the easier it is to win the trip to Vega  A. Tucket
 [reply] 

Actually, the result of 0/0 is indetermined, since any number times 0 is 0.
So true. Besides, if 0/0 is 1, then is 2*0/0 == 2, or 1?
There is no universal numerical solution for 0/0, which is something that is required for a computation not to produce an error.
The closest you can get to a universal solution is the rule of de l'Hopital (SP?), which said that with f(x) = u(x)/v(x) and u and v simultaniously approaching zero for x > x0, that then lim(x>x0)(f(x)) = lim(x>x0)(u/v) = u'(x0)/v'(x0), the ratio of derivative functions. The wanted numerical value depends entirely on the value of u'(x0) and v'(x0). Those can be the same, in which exceptional case the result would be 1, but it's far more likely that you should get something vastly different from 1. For example, for sin(x)/x in x==0, the ratio is cos(0)/1==1 (ooh what a coincidence!).
In short: if you don't want an error for 0/0, it's your responsibility for handling that exception, not perl's.
 [reply] 
(tye)Re: What is zero divided by zero anyway? by tye (Cardinal) on Oct 05, 2002 at 15:47 UTC 
The reason 0/0 is not usually defined to be 1 is that, "almost 0" / "nearly 0" is not always close to 1. This is expressed more precisely in calculus:
If for any error size, E, you can find an accuracy requirement, D, such that X and Y being within D of 0 means that X/Y will be within E of 1, then you could define 0/0 as 1.
There are cases where we can define some "edge case" calculation to have some specific value because doing so makes for a continuous function.
(Update) If you require X==Y (which is how you are thinking about it), then you do always get 1. But think of a 3dimensional space where you fill in points where Z = X/Y. Then the plane where X==Y intersects with our graph such that we get Z==1 everywhere except at (X,Y)==(0,0). Which makes you think that Z==1 makes sense there.
But if you look at it other ways, you get different results. For example, look at the plane 2*X==Y and you'll think Z should be 2 at (X,Y)==(0,0).
Now, think of a circle of radius E around (X,Y)==(0,0) and intersect the vertical cylinder that passes through that with our graph. You get two curves, each that goes to both negative infinity and positive infinity (for Z) while always staying at distance E from the vertical line (X,Y)==(0,0).
So (X,Y) being almost (0,0) means that X/Y could be any value at all. So mathematicians don't define a value for 0/0.
And finally, (a much simpler argument) if you define 0/0==1, then 0/Y would be 0 for all but Y==0, which is exactly the type of problem you are complaining about.
 tye (I'm nearly finished with almost explaining this)
 [reply] 

 [reply] [d/l] 

x/x = 1 ( x != 0 )
0/x = 0 ( x != 0 )
x/y = x * (1/y) ( y != 0 )
That's all there is to it. We disallow division by zero and dispense with long winded explanations.
Consider the following formulation that proves 2 = 1.
(1) a = b ( a != 0, b != 0 )
(2) aa = ab
(3) aa  bb = ab  bb
(4) (a  b)(a + b) = b(a  b)
(5) a + b = b
(6) b + b = b (from a = b, (1))
(7) 2b = b
(8) 2 = b/b
(9) 2 = 1
This flaw in this "proof"? To get to step 5 we divide
both sides by (a  b) (which, because a=b, (ab) = 0).
You could formulate step 5 as:
(5) ( ( a  b ) / ( a  b ) )( a + b ) = ( ( a  b ) / ( a  b ) )b
+
In which case, you'd be multiplying both sides by 1 if you allowed that 0/0 = 1. But, 0/0 doesn't = 1, x/0 is simply disallowed, always, even when x = 0.
 [reply] [d/l] [select] 

It doesn't matter. Sure, it doesn't "make sense" to divide by 0. But there are several cases where you can decide to define that some specific expression that doesn't really "make sense" should be considered to have a specific value because doing so would simplify having to deal with some edge cases.
For example, 0**0 is generally defined to be 1 even though 0**X is 0 for all values of X > 0. Also, 0! (factorial) is defined to be 1. Because these "conventions allow us to extend definitions in different areas of mathematics that would otherwise require treating 0 as a special case."
I wish I could remember cases where continuous functions were the complete justification for such conventions (I know there is at least one such, but I can't think of it).
 tye (but my friends call me... um... something)
 [reply] 



 
I hereby resolve to read to the end any given post before leaping to try and understand the details.
After scribbling lines and points over both sides of several sheets of paper trying to picture this, I then resorted (as any exMech.Eng. would) to a cardboard box, a pencil, a ruler and a pair of sissors.
I was going along great until I got to the bit about the cylinder. A loo roll center wasn't big enough (Have you ever tried to reroll a pile of loo paper? Take it from me, don't bother!).
So, out to the garage, a hacksaw to a discarded carpet roll tube that has been sitting on the rafters (cos I thought it might be useful) and a 1 foot section later. A few judicious snips on the cardboard box allowed me to roughly center this over one axis (a corner of the box to us laymen). A quick relabelling, lay the whole thing on its side. And the realisation dawns and finally it makes sense.
Those things that you mathematicians call curves, are (in this case) what any engineer would call straight lines. Now the description makes sense :^).
Then I read the last paragraph and "Ah! Now there's a good reason for not doing it".
Seriously though, thankyou for the excellent explanation!
Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hallo, Mister ladeda. ... Like yer ring!
 [reply] 
Re: What is zero divided by zero anyway? by moxliukas (Curate) on Oct 05, 2002 at 21:43 UTC 
I have always thought that there are three possible answers to the question what is 0 / 0:
 zero, since zero divided by anything is still zero;
 infinity, since anything divided by zero is infinity;
 one, since anything divided by itself is one.
Of course my thinking can be very wrong as zero is not just anything  it is a special case in itself. 0 / 0 may be equal to zero, one and infinity at the same time, but it is probably easier to say that it is undefined. Or even Mu.
 [reply] 

Yes, the answer is that the result of x/0 (including x=0) is every possible result at once. That is because x*0 is zero for any x. With x*a for any a != 0 the result set is exactly as large as the definition set (I hope these are the correct English terms). But for a = 0, the result set has only a single value, 0 itself.
x*a maps every x to one distinct y, except for a=0, so you can reverse it. But for a=0, it maps every x to the same y (that is, to 0), so by knowing a=0 and y=0 you still cannot tell which out of an infinite number of possible values for x led to this result.
Makeshifts last the longest.
 [reply] 
Re: What is zero divided by zero anyway? by Kage (Scribe) on Oct 06, 2002 at 02:09 UTC 
 [reply] 
Re: What is zero divided by zero anyway? ( 2=1 )? by gmpassos (Priest) on Oct 06, 2002 at 02:52 UTC 
 [reply] 
Re: What is zero divided by zero anyway? by Mr. Muskrat (Abbot) on Oct 07, 2002 at 15:00 UTC 
In Algebra II class in high school, I confused and confounded the class with a 2==1 problem (like those posted by jordanh or gmpassos). My class mates were saying stuff like "cool" and "wow". My teacher looked at for 2 or 3 minutes. Then a smile crossed her face and she said something like "Nice try! You had me going for a minute there. But you can't divide by zero."
Of course, someone asked why you can't divide by zero. After a brief explaination that it can't be done she moved on with the lesson plan. So like any good geek, I stayed after class to discuss my ideas with her.
I was not nearly so precise as you have explained it. I said something like "Any number multiplied by zero results in zero. So any number divided by zero results in an answer that contains the infinite series." I saw a light go on above her head; a sparkle appeared in her eye. It was then that I realized that I had taught my teacher something. That is one of the best feelings in the world!
 [reply] 
Re: What is zero divided by zero anyway? by petral (Curate) on Oct 07, 2002 at 23:37 UTC 
Zero divided by zero is zero.
 Brahmagupta, (who discovered zero in the first place)
This would be consistent with 0/n for all other n, which I suppose is as good as being consistent with n/n for all other n. (But "zero" later explorers followed him in this. :) )
p  [reply] 
Re: What is zero divided by zero anyway? by jynx (Priest) on Oct 08, 2002 at 17:28 UTC 
Maybe this will help, maybe it will add to the confusion that this post has become. Who knows...
The easy explanation comes from back when i first thought of this as well. i asked a teacher. According to her, zero does not meet the requirements to be in the denominator of any fraction so it should just be avoided. That's the easypeasy explanation, feel free to avoid the mathematics below if you want...
So, i've been thinking about this for a bit, and eventually i got back to the division algorithm. Let's first take the case of a/b, where a is nonzero and b is zero. According to the division algorithm, there are numbers q and r such that a = b*q + r
and
0 <= r <= b (where b in this case is zero).
But in the case of a/0, r will be a. So we havea = b*q + r
but not
r = 0
(which is required in this case) which is against the definition. So we can't divide most things by zero because at a fundamental level it breaks the rules.
Zero over zero is a special case of the above, because r will fall into the appropriate range (it will be zero) but the fraction is still not defined. Why is that? Let's take a closer look...
Let us take the fraction 0/0. Let us attempt to obtain a value for this fraction. It is of the form a/a so it is clearly not reduced (any fraction with common factors in the numerator and denominator can be reduced, and in the case of a/a the fraction is usually reduced by whatever the number a is). We then take some number d in the integers to reduce this fraction by, but we must choose d carefully. When we're done we want the fraction to be in it's most reduced state. So we want to find d such that d = gcd(0,0).
Note that no such number exists^{*}. You can continue using larger and larger numbers, but you will never find one (infinity is not a number but a useful concept; it is unusable except in limits). Since we cannot find a number to reduce this fraction by it is irreducable, but it is not reduced. This is a contradiction, so i am forced to conclude that there is no value for this fraction.
This may or may not be the proof,
but hopefully it will shed a little light (if nothing else, it's convinced me :)
jynx
^{*}: gcd is a function that takes two integer numbers and returns the greatest common divisor of those numbers.
update: put in some formatting and refined some of the definitions. Hopefully this will be readable by nonmathematicians as well...  [reply] [d/l] [select] 
Re: What is zero divided by zero anyway? by Mr. Muskrat (Abbot) on Oct 08, 2002 at 22:25 UTC 
 [reply] 
Re: What is zero divided by zero anyway? by John M. Dlugosz (Monsignor) on Oct 11, 2002 at 18:41 UTC 
As I recall, that is an "indeterminate form". A complex formula that crunches down to 0/0 might "really" be (using limits) 0, 1, infinity, or anything really. I've seen it be 2.
You beleive wrong: the exotic infinity/infinity is also the indeterminate form, and could be anything.
I'd sooner have it give "infinity" or "NaN" rather than 1 as a nonerror result.  [reply] 

