2

For the basic math operations addition, subtraction, multiplication, fractions and negate using integers is the following always true,

If any part of an operation is indeterminate the result is indeterminate?

TL;DR

I am creating a symbolic math simplifier/evaluator in Prolog and am now working on fractions. I know the rule that if zero is in the denominator then the result is undefined. After a bit of research I found that 0/0 is not undefined but indeterminate. So the obvious way to add the indeterminate rules are to copy the rules for undefined and check if both the numerator and denominator are zero and then define the result as indeterminate. So far so good, I reached the rules such as adding, subtracting, multiplying and negating undefined which say that if any part of an operation is undefined the result is undefined and was not sure that the same rules apply for indeterminate.

The simplification rules are almost a direct translation of standard math rules but sometime require a guard

e.g. Mathword Fraction Rules

% simplify 21
% -X/-Y -> X/Y
simplify([op(frac),[[op(neg),X],[op(neg),Y]]], R) :-
    X \= [number(0)],
    Y \= [number(0)],
    simplify([op(frac),[X,Y]], R),
    !.

% simplify 22
% X/1 -> X
simplify([op(frac),[[number(X)],[number(1)]]], [number(X)]) :-
    !.

As you can see these are term rewriting rules done in Prolog.

In the comments David K made a nice reference to NaN for which I am very familiar, (35+ years of programming). If this were using numerical methods I would find that acceptable, however this should only return answers that would be acceptable in a math course, such as undefined or indeterminate.

An example of a simple case that has me thinking

1/0 * 0/0 
-> undefined * indeterminate
-> indeterminate, undefined or other?

as opposed to

1/0 * 4
-> undefined * 4
-> undefined

or

0/0 * 4
-> indeterminate * 4
-> indeterminate

If any of my statements are also wrong please let me know.

Latter on I will be adding reals, limits, etc., so if there is a different answer for those I don't expect an elaboration, just a simple note and I will ask the same question later when I get to those domains.

I tried to find where this is documented as in by definition, but could not find it.

Guy Coder
  • 179

1 Answers1

1

For your purposes I think it is reasonable for you to want to be able to prove any facts that you use, using only pure mathematics in your proofs and not depending on any conclusions the IEEE-754 standards committee or other such bodies. So the question is how to go about that.

One simple scheme is that whenever you make a calculation using real numbers for which you have a proof that the answer is a particular real number, and your proof says which number it is, then the result is that number; otherwise the result is X. The result of any arithmetic operation with an X operand is also X. The meaning of X in this system is that the proof system failed to prove that the result should be a particular real number; it isn't a proof that the value of the result cannot be determined. I believe this is mathematically sound, in that any numeric result that the system returns (not X) is provably correct.

What is possibly unattractive about this system is that both $1/0$ and $0/0$ evaluate to X, whereas you have expressed an interest in distinguishing those two values. That's what brought to mind IEEE-754, in which $1/+0 = +\infty$ and $1/-0 = -\infty,$ while $+0/+0 = \mathrm{NaN}.$

The thing is, mathematically, I'm not sure how to justify treating undefined and indeterminate as distinct possible outcomes of an arithmetic operation. In fact, the link you gave for the word "indeterminate" is actually a link to an article about indeterminate forms, which (strictly speaking) do not apply to arithmetic operations, but only to some situations that can arise in the intermediate steps that are taken in the evaluation of the limit of a function.

Now the difference between $\frac00$ and $\lim_{x\to a}\frac{f(x)}{g(x)},$ where $f(a) = g(a) = 0,$ is that there is no good way to evaluate the former to any real number (or even to "infinity"), whereas the latter may very well be provably equal to $1$ or $2$ or some other real number (or may tend to infinity in a well-defined way). We say the form is "indeterminate" only because we cannot evaluate it simply by plugging in $f(a)$ and $g(a)$ directly.

So I'm inclined to say that you should evaluate both $1/0$ and $0/0$ as undefined (that is, the same as the result X that I suggested earlier), and wait until you get to limits to use the word indeterminate--but even then, indeterminate is not the result of a calculation, but is only a signal or status value that you might use to indicate that a particular solution method does not work and that an alternative method should be tried.

David K
  • 98,388
  • Thanks. One of my thoughts was that indeterminate does not apply as I have not yet reached limits and you have agreed with that one. While I like your answer I would like to see the responses of others before giving the accept vote. I was hoping for more of a reference that covers the case of what to do when both 0/0 and 1/0 are in the same expression. – Guy Coder Feb 13 '17 at 12:16
  • I'm not quite satisfied with the answer either. I agree you should wait a while for other answers, or perhaps while we're waiting I'll think of something better to say (at least deal with (1/0)*(0/0) and so forth). – David K Feb 13 '17 at 15:02
  • I appreciate your responses and effort on this, having been on SO for some time I know how discoursing it is to work on an answer and not get any response, likewise ask a question and not get any feedback. I saw your SO Unsung hero badge and see that as an honor. :) – Guy Coder Feb 13 '17 at 15:50