1

When using R I noticed that dividing a number by zero returns infinity.

From a mathematical prospective that is not very accurate and it should be equal to undefined. Now I understand R is a statistical programming language and is not pure mathematics, but I was wondering if NaN (Not a Number) should be a better way to describe a/0 where a is a real number.

In other terms, can someone explain to me in simple terms why in R

> 5/0
[1] Inf

while

> 0/0
[1] NaN

Apologies if this was already discussed somewhere else but I could not find it a satisfactory answer.

mck
  • 40,932
  • 13
  • 35
  • 50
Ni-Ar
  • 146
  • 14
  • 1
    As far as I know, mathematically, the limit of 5/x given x -> 0 is infinite. Where the limit of 0/x is undefined. – Stefan Sep 29 '18 at 12:33
  • 1
    *lim (x -> 0) 5/x* is clearly +Inf. – jogo Sep 29 '18 at 12:35
  • @Stefan IMHO for *0/0* it is not clear which part tends to 0. If both parts of the fraction tends to 0, one need the *rule of Hospital* to decide in terms of mathematics - that is too much for a number crunching tool like `R`. Or in other words: in this case much more information about the generating process is needed (much more than a simple evaluation of one expression). So the result can be anything. This it was `R` expresses by `NaN` – jogo Sep 29 '18 at 12:40
  • @jogo: yes, and 0/0 cannot be `l'Hôpital-ed`, since both the derivative's stay's 0 all the time. ... although... the math is a bit rusty on my end ;-) – Stefan Sep 29 '18 at 12:53
  • 1
    Suppose we interpet x/0 = z as x = 0 * z. Now if x is 0 the latter equation is satisfied for every z but if x is non-zero it is satisfied by no z so the two cases are different. – G. Grothendieck Sep 29 '18 at 13:00

0 Answers0