1. Suggestion for 2.5
- Posted by rforno at tutopia.com Feb 18, 2003
- 450 views
Rob: When crunching numbers, sometimes one gets a "division by zero" error. In such cases, perhaps the useful thing to do is assign "infinite" to the result (I mean the IEEE standard infinite), so that if you use he result as a divisor, the new result will be zero. The following are the results for zero division I propose: 1 / 0 = inf -1 / 0 = -inf 0 / 0 = 1 inf / 0 = inf -inf / 0 = -inf inf / inf = 1 -inf / inf = -1 inf / -inf = -1 -inf / -inf = 1 1 / inf = 0 -1 / inf = 0 1 / -inf = 0 -1 / -inf = 0 and the logical results for addition, subtraction and multiplication. Please correct me if I'm wrong: I think you are checking for a zero divisor *before* you perform the actual division, and so this proposal wont add any overhead in the case of a divisor being zero. I don't know how are you handling the case of infinite IEEE numbers. In any case, I'd avoid getting a nan (not a number) result. In order to be alerted of an error as soon as possible, like Eu does now, it would be useful to enable or not this variation by means of a *with* or *without* option, lets say: without zero_division. Regards.
2. Re: Suggestion for 2.5
- Posted by Robert Craig <rds at RapidEuphoria.com> Feb 18, 2003
- 434 views
Ricardo Forno writes: > When crunching numbers, sometimes one gets a > "division by zero" error. In such cases, perhaps the > useful thing to do is assign "infinite" to the > result (I mean the IEEE standard infinite), ... OK. I might consider this for 2.5. If I made this an option, I would follow the IEEE rules for dividing by zero, i.e. I would simply let the floating-point unit produce +/- INF, rather than testing for zero, and reporting an error as I do now. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
3. Re: Suggestion for 2.5
- Posted by "Carl W." <euphoria at cyreksoft.yorks.com> Feb 18, 2003
- 452 views
rforno at tutopia.com wrote: > following are the results for zero division I propose: > 1 / 0 = inf > -1 / 0 = -inf > 0 / 0 = 1 > inf / 0 = inf > -inf / 0 = -inf > inf / inf = 1 > -inf / inf = -1 > inf / -inf = -1 > -inf / -inf = 1 > 1 / inf = 0 > -1 / inf = 0 > 1 / -inf = 0 > -1 / -inf = 0 There's some inconsistency here: What's inf * 0? By your axioms here the answer is 1, but Euphoria currently returns 0 - without causing an error - when this calculation is done. What's 2/0? If it's inf again then when you remultiply the zero you should get 2, but you'll get 1. Also what's (6/0)/(2/0)? Euphoria would return 1, but that's not right - surely the answer should be 3? I can't say I haven't wanted similar functionality in the past, but this could be the cause of some extremely difficult to trace bugs. -- [ Carl R White == aka () = The Domain of Cyrek = ] [ Cyrek the Illogical /\ www.cyreksoft.yorks.com ]
4. Re: Suggestion for 2.5
- Posted by Martin Stachon <martin.stachon at worldonline.cz> Feb 19, 2003
- 450 views
rforno wrote: > When crunching numbers, sometimes one gets a "division by zero" error. In > such cases, perhaps the useful thing to do is assign "infinite" to the > result (I mean the IEEE standard infinite), so that if you use he result as > a divisor, the new result will be zero. The following are the results for > zero division I propose: > 1 / 0 = inf > -1 / 0 = -inf Given that 1 / 0 = inf, some of these expressions are indeterminate: (They can have any value. Sometimes, the program might expect 1, somtimes 0 would fit in the algorithm better.) > 0 / 0 = 1 Because x * 0 = 0 for any x, 0 / 0 can be anything. > inf / 0 = inf > -inf / 0 = -inf That could be right. (I am not sure) > inf / inf = 1 > -inf / inf = -1 > inf / -inf = -1 > -inf / -inf = 1 x * inf = inf, so inf / inf can be anything. (Try to cut down an infinite long straight line into infinite number of parts - they can have any length) > 1 / inf = 0 > -1 / inf = 0 > 1 / -inf = 0 > -1 / -inf = 0 That's right. Some other indeterminate forms are : inf*0 0^0 (although MS Windows Calculator says 0^0=1, my Casio says "Math error"1^inf inf^0 I do not think we should play such high math agmes in our exact math machines. All "normal" applications would get screwed up with inf results anyway and those few math programs can handle this in its own way. Fun could begin with quatum based computers... Martin (does not have a math degree [yet])
5. Re: Suggestion for 2.5
- Posted by Christian.CUVIER at agriculture.gouv.fr Feb 20, 2003
- 422 views
Hi, all! Some thoughts on the topic: > Date: Wed, 19 Feb 2003 19:16:31 +0100 > From: Martin Stachon <martin.stachon at worldonline.cz> > Subject: Re: Suggestion for 2.5 > > rforno wrote: > > When crunching numbers, sometimes one gets a "division by zero" error. In > > such cases, perhaps the useful thing to do is assign "infinite" to the > > result (I mean the IEEE standard infinite), so that if you use he result as > > a divisor, the new result will be zero. The following are the results for > > zero division I propose: > > 1 / 0 = inf > > -1 / 0 = -inf > > Given that 1 / 0 = inf, some of these expressions are indeterminate: > (They can have any value. Sometimes, the program might expect 1, somtimes > 0 would fit in the algorithm better.) The problem is that 0 is both nonnegative and nonpositive. Actually, 1/epsilon is +inf, as well as -1/-epsilon, and 1/-epsilon=-inf (epsilon being as tiny a positive quantity as you wish). So the only thing I know then is abs(1/0)=+inf, because 1 is as close to +epsilon as to -epsilon. A possible workaround could be to introduce signed zeroes (0+ and 0-). Fior all ordinary operations, these behave like 0. But dividing by signed zeroes may yield determinate results. > > 0 / 0 = 1 > > Because x * 0 = 0 for any x, 0 / 0 can be anything. > > > inf / 0 = inf > > -inf / 0 = -inf > > That could be right. (I am not sure) Not determinate, for the same reason as above, and the same remedy works. > > inf / inf = 1 > > -inf / inf = -1 > > inf / -inf = -1 > > -inf / -inf = 1 > > x * inf = inf, so inf / inf can be anything. > (Try to cut down an infinite long straight line into > infinite number of parts - they can have any length) > > > 1 / inf = 0 > > -1 / inf = 0 > > 1 / -inf = 0 > > -1 / -inf = 0 > > That's right. And you can get more precise results with signed zeroes. > Some other indeterminate forms are : > > inf*0 n*(a/n) is always a. When n goes to +inf, n=+inf and a/n goes to 0. So inf*0 can be anything, and may not be at all. > 0^0 (although MS Windows Calculator says 0^0=1, my Casio says "Math error"1 is correct, because epsilon^0 is always 1. > 1^inf Not determinate, since its log is the indeterminate 0*inf. > inf^0 This also has inf*0 as its log, hence it is not determinate either.. > I do not think we should play such high math agmes in our exact > math machines. All "normal" applications would get screwed up > with inf results anyway and those few math programs can handle > this in its own way. > Fun could begin with quatum based computers... > > Martin (does not have a math degree [yet]) > CChris
6. Re: Suggestion for 2.5
- Posted by Juergen Luethje <eu.lue at gmx.de> Feb 20, 2003
- 415 views
Hi Christian, you wrote: > From: Martin Stachon <martin.stachon at worldonline.cz> [...] >> Some other indeterminate forms are : [...] >> 0^0 (although MS Windows Calculator says 0^0=1, my Casio says "Math error" >>> > 1 is correct, because epsilon^0 is always 1. [...] I disagree. It also could be said that 0^0 = 0, because 0^x = 0. It cannot be decided, which of both rules _generally_ is "better": "0^0 is undefined. Defining 0^0 = 1 allows some formulas to be expressed simply (Knuth 1997, p. 56), although the same could be said for the alternate definition 0^0 = 1 (Wells 1986, p. 26)." [http://mathworld.wolfram.com/Zero.html] > CChris Best regards, Juergen -- /"\ ASCII ribbon campain | while not asleep do \ / against HTML in | sheep += 1 X e-mail and news, | end while / \ and unneeded MIME |
7. Re: Suggestion for 2.5
- Posted by Juergen Luethje <eu.lue at gmx.de> Feb 20, 2003
- 423 views
Hi Christian, you wrote: > In the same vein, we could say that 0^0 is not determinate, since > (exp(-a^2/x^2))^(x^2) is exp(-a^2) always, whatever a is, and its limit > form is 0^0 as x goes to 0. > Anyway, a powerful argument in favor of 0^0=1 could be that, if x goes > to 0, x^x goes to 1. The principle of economy, which here translates as > "use one variable to resolve the indeterminacy, then 2 if you can't", > then backs up the case of 0^0=1. I don't know such a "principle of economy", that makes a contradiction simply disappear. > True, 0^x is always 0 if x is nonzero. It means that x +-->0^x is not > continuous at 0. Not really shocking IMO. > > CChris AFAIK shocking or not shocking wasn't the question here. Since I'm not a mathematician, all I can say is, that my teachers at school, the authors of my math textbooks, and the people at http://mathworld.wolfram.com/ say, that 0^0 is undefined. >> From: Juergen Luethje <eu.lue at gmx.de> <snip> >> "0^0 is undefined. Defining 0^0 = 1 allows some formulas to be expressed >> simply (Knuth 1997, p. 56), although the same could be said for the >> alternate definition 0^0 = 0 (Wells 1986, p. 26)." >> [http://mathworld.wolfram.com/Zero.html] <snip> Regards, Juergen -- Q: How many Microsoft engineers does Bill need to change a light bulb? A: None. He just declares darkness to be an industry standard.
8. Re: Suggestion for 2.5
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Feb 20, 2003
- 432 views
On Thu, 20 Feb 2003 17:57:17 +0100, Juergen Luethje <eu.lue at gmx.de> wrote: <snip> >Q: If 0=3D1 and 1=3D0 and -1!=3D1*(-1), why change the light bulb? >A: What? Please go and fight this one out in alt.math.irrelevant.number.theory Pretty pleasePete
9. Re: Suggestion for 2.5
- Posted by Juergen Luethje <eu.lue at gmx.de> Feb 21, 2003
- 428 views
Pete wrote: > On Thu, 20 Feb 2003 17:57:17 +0100, Juergen Luethje <eu.lue at gmx.de> > wrote: > > <snip> >> Q: If 0=1 and 1=0 and -1!=1*(-1), why change the light bulb? >> A: What? > > Please go and fight this one out in alt.math.irrelevant.number.theory LOL> Pretty please
> > Pete Regards, Juergen -- /"\ ASCII ribbon campain | while not asleep do \ / against HTML in | sheep += 1 X e-mail and news, | end while / \ and unneeded MIME |
10. Re: Suggestion for 2.5
- Posted by Martin Stachon <martin.stachon at worldonline.cz> Feb 21, 2003
- 419 views
Christian CUVIER wrote: > > Some other indeterminate forms are : > > 0^0 (although MS Windows Calculator says 0^0=1, my Casio says "Math error" > >> > 1 is correct, because epsilon^0 is always 1. Some problems arise when defining 0^0=1 : log(0^0) = 0*log(0) -- not defined (0^1)/(0^1) = 0^(1-1) = 0^0 = 1 -- but this is 0/0, indeterminate natural n-th power of a is defined as: a^n = a*a^(n-1) This way, 0^0=0*0^(-1)=0*inf -- indeterminate There is also a proof using the fact that : lim_(x->0) 0^x = 0 lim_(x->0) x^0 = 1 But I don't understand it (we haven't been taught using limits yet). Martin