Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dividing by zero

0 views
Skip to first unread message

Mike Machuidel

unread,
Nov 8, 2002, 12:44:38 PM11/8/02
to
Hello,

I've been busy lately finding some solutions on some math issues,
like for example: why not being able to divide by zero. Haven't checked
if this already had been solved, but just cause I like to try things out
myself I put out the following C code and like to share it with you:

/* System includes */
#include<stdio.h>
#include<stdlib.h>

#define LVAL_START -3
#define LVAL_END 3
#define RVAL_START -3
#define RVAL_END 3

/* Divide callback structure */
typedef struct {

char *name;
float (*function)(float lvalf, float rvalf);

} divide_func_t;

/* Divide function (Standard) */
float divide0(float lvalf, float rvalf)
{
/* Check for division by zero */
if(rvalf == 0)

/* Return unsuccessfull */
return(0);

/* Return plain division */
return(lvalf / rvalf);
}

/* Divide function (Solution 1) */
float divide1(float lvalf, float rvalf)
{
/* Right handed value is above zero */
if(rvalf >= 0)
return(lvalf / (rvalf+1));

/* Right handed value is below zero */
if(rvalf <= 0)
return(lvalf / (rvalf-1));
}

/* Divide function (Solution 2) */
float divide2(float lvalf, float rvalf)
{
/* Left handed value is below zero, right handed value is above zero */
if(lvalf <= 0 && rvalf >= 0)
return(lvalf * (rvalf+1));

/* Left handed value is above zero, right handed value is below zero */
if(lvalf >= 0 && rvalf <= 0)
return(lvalf * (-rvalf+1));

/* Left handed value is above zero, right handed value is above zero */
if(lvalf >= 0 && rvalf >= 0)
return(lvalf / (rvalf+1));

/* Left handed value is below zero, right handed value is below zero */
if(lvalf <= 0 && rvalf <= 0)
return(lvalf / (-rvalf+1));
}

/* Fill callback structure */
divide_func_t divide_func[] = {
{"Standard division", divide0},
{"Division solution 1", divide1},
{"Division solution 2", divide2},
{0, 0}
};

/* Main routine */
int main(int argc, char **argv)
{
/* Declare variables */
int alg = 0;
int lval = 0;
int rval = 0;

/* Iterate through all algorithms */
printf("\n");
while(divide_func[alg].name != 0) {

/* Create division tabular for algorithm */
printf("%s:\n", divide_func[alg].name);
for(lval = LVAL_START-1; lval <= RVAL_END; lval++) {
for(rval = RVAL_START-1; rval <= RVAL_END; rval++) {
if((lval == LVAL_START-1) && (rval == RVAL_START-1))
printf("\t");
else if(lval == LVAL_START-1)
printf("%d|\t", rval);
else if(rval == RVAL_START-1)
printf("%d|\t", lval);
else
printf("%.2g\t", divide_func[alg].function((float)lval,
(float)rval));
}
printf("\n");
}

/* Next algorithm */
printf("\n");
alg++;

}

/* Exit successfull */
exit(1);
}

This program will print out 3 different division tables using
different divide functions, explanation as follows:

- The first one is just the one divide function we always use (or at
least learn on primaryschool). The zeroes in the middle are "Division
by zero" errors, I was just too lazy to implement good error handling ;)

0 / 0 = Division by zero error
1 / 0 = Division by zero error
0 / 1 = 0
1 / 1 = 1
-1 / 1 = -1
1 / -1 = -1
-1 / -1 = 1

- The second one is a new divide function I made up that cannot
(shouldn't) cause a division by zero error:

0 / 0 = 0
1 / 0 = 1
0 / 1 = 0
1 / 1 = 0.5
-1 / 1 = -0.5
1 / -1 = -0.5
-1 / -1 = 0.5

- The third one is the same as the second one, but also takes negatives
in account, this should be the final solution to get rid of the dividing
errors:

0 / 0 = 0
1 / 0 = 1
0 / 1 = 0
1 / 1 = 0.5
-1 / 1 = -2
1 / -1 = 2
-1 / -1 = -0.5

May be I'm just reinventing the wheel, but hey I like to do it,
that's all that matters, right? So please let me know what you think?

Greetings,
Mike Machuidel

A N Neil

unread,
Nov 8, 2002, 2:57:30 PM11/8/02
to
In article <aKSy9.34$B.1...@amsnews03.chello.com>, Mike Machuidel
<mach...@yahoo.com> wrote:

> May be I'm just reinventing the wheel, but hey I like to do it,
> that's all that matters, right? So please let me know what you think?

I think the rule (a/b)*b=a is too important to give up.

Mike Machuidel

unread,
Nov 8, 2002, 3:11:45 PM11/8/02
to
A N Neil wrote:

You are so right, nice try anyway :P


David W. Cantrell

unread,
Nov 8, 2002, 3:50:27 PM11/8/02
to

How can you complain about giving up something you never had in the first
place? If your number system includes 0 (which must surely be appropriate
for this thread), then the rule (a/b)*b=a is not valid in general,
regardless of whether that number system is an extension in which division
by zero is allowed or is one in which such division is disallowed.

Of course, there are useful number systems (e.g., the positive reals) in
which (a/b)*b=a is always valid. But if one wishes to have 0 in a number
system, then one must understand that that rule no longer holds in general.

David

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service

Popsicleman05

unread,
Nov 9, 2002, 2:02:15 AM11/9/02
to
im not sure about all the technical things u wrote but if u wanna know
why u cant divide by zero u hafta think of what dividing means. it
means if u have x amount of something and y groups, how many of the
things that u have will be in each group. ie if u had 10 oranges and u
wanted to evenly put it into 5 groups u represent it as 10/5 or 2
oranges in each group. now try applying this to 0. 10 oranges in 0
groups, how many r in each group? there aren't any groups to have an
orange in so it doesn't work. while u can have 0 oranges in 10 groups,
u cannot have 10 oranges in 0 groups.

another way of thinking about dividing by 0 is 1/0 (or x/0) is
equivilant to infinity (or negative infinity). take the function 1/x,
a hyperbola. at the x-coordinate 0 u get 1/0 which is undefined. there
is no point in which the function crosses the y-axis. except infinity.
it is very important to relize that infinity is a concept not a
number. u cannot say x=infinity u can only say as x approaches
inifity, and in the particular function 1/x as x approaches 0 the
function approach infinity. if u want what i just said in termanoligy
it would be
f(x)=1/x
lim as x-->0 of f(x)=infinity
therefore 1/0 "equals" infinity

infinity is a hard concept to grasp, and has a lot of different
qualities that i dont know of and that i couldn't fit on this most
likely, for further information u would probably want to check a book
from the library.
popsicleman05

Sonoman

unread,
Nov 10, 2002, 11:40:48 AM11/10/02
to
Agree, just try taking the limit as x-->0 of 1/x so you can see it better.

"Popsicleman05" <popsic...@hotmail.com> wrote in message
news:b86b0381.02110...@posting.google.com...

David W. Cantrell

unread,
Nov 21, 2002, 11:10:20 AM11/21/02
to
popsic...@hotmail.com (Popsicleman05) wrote:
> if u wanna know
> why u cant divide by zero u hafta think of what dividing means. it
> means if u have x amount of something and y groups, how many of the
> things that u have will be in each group. ie if u had 10 oranges and u
> wanted to evenly put it into 5 groups u represent it as 10/5 or 2
> oranges in each group. now try applying this to 0. 10 oranges in 0
> groups, how many r in each group? there aren't any groups to have an
> orange in so it doesn't work. while u can have 0 oranges in 10 groups,
> u cannot have 10 oranges in 0 groups.

The above argument can be modified nicely to give an answer when the
divisor is zero. In the copy of a response of mine from a month or two ago,
I use an interval, instead of oranges. {It's less messy. No sticky orange
juice.}

[Copy]
"Joe" <joe...@joebrunner.com> wrote:
> But doesn't division have to satisfy the
> "reverse" of multiplication. In other words:
>
> (x * y = z) and (z / y = x)
> (2 * 3 = 6) and (6 / 3 = 2)
>
> Is there some mathematical magic that
> would enable one to violate this?

It is true that the notion of division is normally
linked with the notion of multiplicative inversion. That works beautifully
if you restrict yourself to, say, the real number system and avoid
division of zero. However, if we wish to be able to speak reasonably of
dividing a nonzero value by zero, then we cannot restrict ourselves to
the notion of multiplicative inversion (since zero cannot have a
multiplicative inverse).

Consider this very simple idea. Take a nondegenerate interval A on the
real line. Say, A = [0, 36].
How many intervals of length 18 are contained in A? 2

N.B. Here and below, I am thinking of _distinct_ closed intervals,
pairs of which would have at most one point in common. So, for the
above example, the two intervals are [0, 18] and [18, 36].

How many intervals of length 12 are contained in A? 3
How many intervals of length 1 are contained in A? 36
How many intervals of length 1/2 are contained in A? 72
How many intervals of length 1/100 are contained in A? 3600
How many intervals of length 1/1000000 are contained in A? 36000000
How many intervals of length 0 (which are, of course then, degenerate
intervals) are contained in A? This is essentially the same as asking
how many points are in A. The answer, clearly, is that there are
infinitely many, oo.

Just as the second example above corresponds with 36/12 = 3,
the last example corresponds with 36/0 = oo. Very simple, and not
based on the notion of multiplicative inversion. (But I wouldn't call it
"mathematical magic" either. :-)

Note that, despite what is often said, taking x/0 = oo for nonzero x
does not lead to contradictions -- that is, _if_ you know what you're
doing. Of course, for those who don't know what they're doing, all sorts
of things can seem to lead to paradoxes.
[End copy]

> another way of thinking about dividing by 0 is 1/0 (or x/0) is
> equivilant to infinity (or negative infinity). take the function 1/x,
> a hyperbola. at the x-coordinate 0 u get 1/0 which is undefined. there
> is no point in which the function crosses the y-axis. except infinity.
> it is very important to relize that infinity is a concept not a
> number. u cannot say x=infinity u can only say as x approaches
> inifity, and in the particular function 1/x as x approaches 0 the
> function approach infinity. if u want what i just said in termanoligy
> it would be
> f(x)=1/x
> lim as x-->0 of f(x)=infinity
> therefore 1/0 "equals" infinity

There are several inaccuracies above. For example, in a suitable extension
of the real numbers, 1/0 can be defined and you can, correctly, say
x = Infinity. You might be interested in
<http://mathworld.wolfram.com/ProjectivelyExtendedRealNumbers.html>.

Cheers,
David

--
-------------------- http://NewsReader.Com/ --------------------

Usenet Newsgroup Service New Rate! $9.95/Month 50GB

Roger Beresford

unread,
Nov 23, 2002, 9:46:58 AM11/23/02
to
Mike Machuidel <mach...@yahoo.com> wrote in message news:<aKSy9.34$B.1...@amsnews03.chello.com>...

> Hello,
>
> I've been busy lately finding some solutions on some math issues,
> like for example: why not being able to divide by zero (snip)

Division by zero is often possible when using vectors, rather than
ordinary numbers, but "zero" has to be defined as "a vector that gives
a determinant of zero when mapped onto the (Cayley) multiplication
table"
Most of my "Hoop algebras" have meaningful "division-by-zero". They
multiply m-vectors, lists containing "m" numbers from a field such as
R or C. Each vector has a "shape" in an m-algebra. This is a list of
conserved "sizes" (factors of the determinant of the multiplication
table) with the Frobenius conservation property, Det[A] Det[B] =
Det[AB] (up to a sign). Cramer's rule provides a multiplicative
inverse of a vector, and makes the shape (i.e. the determinant) a
divisor in the expression for this inverse. So you would expect
infinite results on trying to divide by a vector with a zero
determinant. In most cases, however, the zero can be "factored-out",
and useful results are obtained by interpreting this as a restriction
to a sub-algebra.

This does not work in "ordinary" algebra", because there is only one
factor. Real, complex, quaternion, and octonion algebras have shapes
that are the sum of the squares of the vector elements. (E.g. the
shape of a quaternion with real elements {t, x, y, z} is the single
size t^2 + x^2 + y^2 + z^2; it can only be zero in the trivial case t
= x = y = z = 0.) They have a single factor that can only be zero in
the trivial case. This makes them the "real algebras without divisors
of zero", a very small and unusual type of algebra.

In contrast, the vast majority of Hoop algebras (including many of
physical importance) have shapes with several different sizes, so the
multiplicative inverse splits into partial fractions and each factor
becomes a numerator. If the determinant is zero, a factor is zero,
giving an infinite partial fraction. The other factors, and partial
fractions, are still significant. The zero factor can be ignored
(renormalized) by working in a sub-algebra in which that factor is
constrained to zero. Factoring the zero allows
"partial-division-by-zero".

The symmetry of the algebra is reduced by renormalization. Consider
the symmetry of the bi-cone, intersected by a plane. Restricting the
distance from the plane to zero gives the "conic sections" - the
circle, ellipse, parabola, hyperbolae, two straight lies, or a single
point. The bi-cone is a supersymmetric version of all these
lower-symmetry objects.

Another type of hoop algebra has a single size with non-trivial
zeroes. The shape of the Pauli algebra is t^2 - x^2 - y^2 - z^2, so
real values (such as t = 5, x = 4,y = 3, z = 0) can have a size of
zero, and an infinite inverse that cannot be factored out. The
sub-algebra with t=0 has no divisors of zero, and is "the light cone"
in physics; it is the home of the photon.

Roger Beresford.

Felix qui potuit rerum cognoscere causa. (Virgil)

Bob Pease

unread,
Nov 23, 2002, 10:01:50 AM11/23/02
to

"Roger Beresford" <ma...@beresford22.freeserve.co.uk> wrote in message
news:39bdd0ce.02112...@posting.google.com...

I bet the Seventh Graders will really go for that!!

RJ P


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.419 / Virus Database: 235 - Release Date: 11/13/02


0 new messages