-
Division by zero
Is there a formula such that n/d=0 where d=0? I was resolving some division by zero errors (which can easily be done in code by checking if the denominator is zero) and got to wondering whether there is a mathematical formula that replicates division such that a denomiator of zero returns zero. Is such a thing possible?
It seems like there should be a way to invert the calcaultion and use d/n to get zero (where d = 0) then do some type of multiplcation to get back to the same as n/d. I don;t know where I'm going with this. I doubt there is a practical use for this, but I just got curious if it is possible to do essentially the equivalent of n/d where d is never a denominator. Any thoughts? :ehh:
-
Re: Division by zero
Not quite sure what you're getting at, but no, you can't get a returned value of 0 when the denominator is 0, because division by 0 is undefined.
Reasons's easy....
if n/d = r (r for result)
then n=d * r
if d=0
then n=0 * r
no value of r, even infinity, will bring you the original n, because 0 * r = 0 for all r
-
Re: Division by zero
Programatically, it is possible to do this without if statements. Just self-defeatingly long :)
((sgn(d)+1) mod 2) --> returns 0 for positive or negative d, 1 for d=0
n/(d + (sgn(d)+1) mod 2)*n) - 1 * ((sgn(d)+1) mod 2)
This means that:
n/(d+0*n) - 1*0 for positive or negative numbers
n/(0+1*n) - 1*1 for 0.
Again, useless, but fun :)
I don't know of any way you could do this mathematically, without the odd functions used above. It seems so simple, to remove that odd little thing there, but I can't think of any way of doing it. You might be able to use limits and some odd infinite sums creatively, but still. Oh well
-
Re: Division by zero
There are a few specialized problems for which logic provides a valid answer for zero divisors.
Example: Calculation of angles using the Atn function. You want to know the angle given (X, Y), formally defined as Atn(Y/X)
It is valid to compare X & Y- X > Y: Result = Atn(Y/X)
Y > X: Result = pi/2 - Atn(X/Y) /// pi/2 when x = zero.
X = Y: Result = pi/4
Divison by zero is avoided. Note that for X = Y = 0, a pure mathematician would object, but assigning pi/4 is not unreasonable.