Why is 0 divided by 0 an error?

前端 未结 18 790
耶瑟儿~
耶瑟儿~ 2021-02-05 07:20

I have come across this problem in a calculation I do in my code, where the divisor is 0 if the divident is 0 too. In my code I return 0 for that case. I am wondering, while div

相关标签:
18条回答
  • 2021-02-05 08:11

    0 means nothing, so if you have nothing, it does not imply towards anything to distribute to anything. Some Transit Facilities when they list out the number of trips of a particular line, trip number 0 is usually the special route that is routed in a different way. Typically, a good example would be in the Torrance Transit Systems where Line 2 has a trip before the first trip known as trip number 0 that operates on weekdays only, that trip in particular is trip number 0 because it is a specialized route that is routed differently from all the other routes.

    See the following web pages for details: http://transit.torrnet.com/PDF/Line-2_MAP.pdf http://transit.torrnet.com/PDF/Line-2_Time_PDF.pdf

    On the map, trip number 0 is the trip that is mapped in dotted line, the solid line maps the regular routing.

    Sometimes 0 can be used on numbering the trips a route takes where it is considered the "Express Service" route.

    0 讨论(0)
  • 2021-02-05 08:14

    How many times does 0 go into 0? 5. Yes - 5 * 0 = 0, 11. Yes - 11 * 0 = 0, 43. Yes - 43 * 0 = 0. Perhaps you can see why it's undefined now? :)

    0 讨论(0)
  • 2021-02-05 08:15

    (Was inspired by Tony Breyal's rather good answer to post one of my own)

    Zero is a tricky and subtle beast - it does not conform to the usual laws of algebra as we know them.

    Zero divided by any number (except zero itself) is zero. Put more mathematically:

     0/n = 0      for all non-zero numbers n.
    

    You get into the tricky realms when you try to divide by zero itself. It's not true that a number divided by 0 is always undefined. It depends on the problem. I'm going to give you an example from calculus where the number 0/0 is defined.

    Say we have two functions, f(x) and g(x). If you take their quotient, f(x)/g(x), you get another function. Let's call this h(x).

    You can also take limits of functions. For example, the limit of a function f(x) as x goes to 2 is the value that the function gets closest to as it takes on x's that approach 2. We would write this limit as:

     lim{x->2} f(x) 
    

    This is a pretty intuitive notion. Just draw a graph of your function, and move your pencil along it. As the x values approach 2, see where the function goes.

    Now for our example. Let:

     f(x) = 2x - 2
     g(x) = x - 1
    

    and consider their quotient:

     h(x) = f(x)/g(x)
    

    What if we want the lim{x->1} h(x)? There are theorems that say that

     lim{x->1} h(x) = lim{x->1} f(x) / g(x) 
                    = (lim{x->1} f(x)) / (lim{x->1} g(x))  
                    = (lim{x->1} 2x-2) / (lim{x->1} x-1)
                    =~ [2*(1) - 2] / [(1) - 1]  # informally speaking...
                    = 0 / 0 
                      (!!!)
    

    So we now have:

     lim{x->1} h(x) = 0/0
    

    But I can employ another theorem, called l'Hopital's rule, that tells me that this limit is also equal to 2. So in this case, 0/0 = 2 (didn't I tell you it was a strange beast?)

    Here's another bit of weirdness with 0. Let's say that 0/0 followed that old algebraic rule that anything divided by itself is 1. Then you can do the following proof:

    We're given that:

     0/0 = 1
    

    Now multiply both sides by any number n.

     n * (0/0) = n * 1
    

    Simplify both sides:

     (n*0)/0 = n 
     (0/0) = n 
    

    Again, use the assumption that 0/0 = 1:

     1 = n 
    

    So we just proved that all other numbers n are equal to 1! So 0/0 can't be equal to 1.

    walks on back to her home over at mathoverflow.com

    0 讨论(0)
  • 2021-02-05 08:17

    Look at division in reverse: if a/b = c then c*b = a. Now, if you substitute a=b=0, you end up with c*0 = 0. But ANYTHING multiplied by zero equals zero, so the result can be anything at all. You would like 0/0 to be 0, someone else might like it to be 1 (for example, the limiting value of sin(x)/x is 1 when x approaches 0). So the best solution is to leave it undefined and report an error.

    0 讨论(0)
  • 2021-02-05 08:18

    why not make an exception for this case?

    Because:

    • as others said, it's not that easy;)
    • there's no application for defining 0/0 - adding exception would complicate mathematics for no gains.
    0 讨论(0)
  • 2021-02-05 08:19

    The structure of modern math is set by mathematicians who think in terms of axioms. Having additional axioms that aren't productive and don't really allow one to do more stuff is against the ideal of having clear math.

    0 讨论(0)
提交回复
热议问题