dly wrote: > that one considers the actual algorithm and its actual ability and > limits and display and store numbers in the most precise form but in > no higher precision than it is capable of producing. Thus if there > or for example only 3 significant digits, store and display >
This is the programmer's job. As my example shows, adding 3 numbers in different orders can give 0, 1 or many significant digits. Are you suggesting J keep track of this? All calculations with floating-point numbers have errors. The principal sources are: 1. Approximation error: using finitely many floating-point numbers to represent uncountably many real numbers. 2. Truncation error: every calculation may result in loss of significance. 3. Algorithmic error: an algorithm only calculates an approximation to the result. These errors propogate, and the number of significant digits at any stage of the calculation is unknown to the computer. The interpretation of the meaning of the calculation has to be the programmer's responsibility. Of these errors, truncation error is the most insidious. Immediate remedies are: 1. Prefer algorithms with few steps. They not only run faster, they are less likely to accumulate truncation error. 2. Avoid the obvious pitfalls (e.g. don't take the difference of numbers that are almost equal, use scaling in matrix calculations). Don't use compilers or interpreters that "optimize" algebraic expressions. 3. Use iterative rather than direct algorithms. Numerical analysis, while less attractive than dreaming in colour, addresses all these issues. In particular, it obtains accurate answers within the confines of fixed-precision floating-point arithmetic. Best wishes, John ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
