Dear p j: I know you are very frustrated with the responses you are getting, so I'll try not to add to it.
Computer arithmetic is a difficult area. Computers are set up for default behavior for what most people want most of the time, and for floating-point arithmetic, that means working with limited precision, not keeping track of the accuracy of intermediate results, and not knowing the accuracy of a final result. Like it or not, that's what's done most of the time. If you want a more accurate answer, or to be sure that the answer is correct, you need methods from numerical analysis. Great ingenuity has been applied to obtaining accurate answers within the limitiations of floating-point hardware, but it is not the default behavior. Your employee does not know the accuracy of any floating-point calculation, not just for square roots or other transcendental functions. Let me give a simple example. Suppose your computer has 3 decimal digits of precision. It uses 1.23 to represent any number in the interval [1.225,1.335] and 1.22 to represent any number in the interval [1.225,1.335]. When you ask it to calculate 1.23-1.22 it will say 0.01. However, the correct answer could be anywhere in the interval [0,0.02], and the answer given by the computer may not even be accurate to one significant digit. Your employee would be saying "I don't know" a lot. This loss of precision occurs in any calculation: subtracting two nearly equal numbers and dividing a big number by one close to zero are the easiest ways of making it worse. Computers do not keep track of these errors. Instead, if numerical precision is required you apply an algorithm that will guarantee a correct result even in the presence of rounding errors. Iterative algorithms are the easiest to understand from this point of view. If you have a function f which when applied to an approximate solution gives you a better approximation, you don't worry about slight loss of precision: you will still get a better estimate. Expecting J to know the accuracy of numerical calculations is not reasonable: J is geared to standard floating-point hardware for most numerical calculations. For software that does do this (and it is a relatively obscure approach because of the lack of hardware support), try searching for "interval arithmetic". Best wishes, John p j wrote: > I will give this one more shot, as there is an > exceptionally serious flaw here. > > To get this out of the way once again, I understand > that asking for a decimal expansion of an irrational > number does not entitle me to something the computer > can't answer. > > The computer should behave like an employee. > If I ask you as an employee for the 16th decimal > expansion of %: 2, I prefer an employee to say "I > don't know" rather than "just use 42. I like 42." > > Arguments for why 42 is good are irrelevant. Whether > 42 is best is irrelevant. It is irrelevant because I > do not wish to prevent anyone from continuing to bask > in the extacy that 42 brings them. If quick lies are > preferred by most, then that is all that matters in > determining what the DEFAULT behaviour should be. > > It would be widely useful even to those who prefer the > default behaviour, to have an additional mode. I am > better able to compensate for my deficiency of not > having memorized the 16th+ decimal expansions of %: 2 > if I am not told false expansions of that number. In > problem domains where greater precision is required, > it quickly becomes obvious that some other approach to > gaining extra precision is needed. I'm only asking > that the usefulness of this approach, which > incidentally has been favoured by every known > programming environment, be recognized as a validly > useful tool > > When programming, I sometimes make a mistake such that > the program I thought would solve a problem doesnt. I > guess this never happens for you. But verifying that > %:n calculated "correctly" is at the end of a very > long list of checks of the program. > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
