calc: are decimal correct calculations possible?

… continued …
I think you can not! prove that there is no way to achieve such better results with less effort … if you can prove it I will gladly follow it, but the wikipedia article is not enough,
I have practically proved the above claim and correctly calculated all fp-precision complaints I could trace back to cancellation, as well as a lot of random numbers, but you have so far mentioned one! special case, a special treatment of irrational values like pi(), this may be a useful thing although it exceeds the definition frame of ‘15 decimal digits’, but it could be possible? to ‘spare’ these values and to round away the occurring fp-artefacts for other values - which occur much more often - if one can distinguish the values,
… continued …

… continued …
spontaneously I would suggest / like to try: 16th significant decimal 0 → round, 16th sig. decimal != 0 → not round (better: shrink the range that xy91 to x(y+1)09 will be rounded while xy10 to xy90 won’t or similar),
more common: make a decision if to round a result acc. to it’s deviation to what the rounded value will be, this would eliminate (most?) fp-artefacts, and spare most (90 percent) irrational values, and those it would harm would be affected only in the 17th significant decimal place, and what can be extracted from the 17th place of doubles is questionable anyway,
besides the understanding that the 17th digit of pi() has 4 times better quality than the 17th digit in the range 8,0 to 9,99~,
i don’t bother that what i’m presenting up to now is ‘less or similar’ to former clue, alone i need to get it working correctly in calc to have better tools to prove my ‘better idea’ …

You just ignore everything.

One more time. I didn’t tell you that that article claims “something is impossible” (although it is impossible to “improve” a single floating-point operation accuracy; it is often possible to improve a chain of calculations). What I wrote above is that to work on that, and to understand what you are doing, you need first to learn. You do not learn. Try to read proofs of Ryū algorithm. Until you manage to provide a proof of comparable quality, you will only be an illiterate amateur. Stubbornness is not a substitute for education.

@newbie-02: your suggestion for rounding xy91 to x(y+1)09 to x(y+1)00 assumes that all “digits” in range 91-09are the result of computation errors and that the result should be exactly decimal number w(y+1)00. This is what I consider a flaw in your reasoning.

Setting apart the issue of converting between external (human-readable) and internal representation, the only way to estimate the magnitude of computation error is to conduct all your computations through “interval arithmetic” (upper and lower bounds) with specific IEEE-754 rounding on each bound. This means you have twice as many operations (does not really matter) and a very careful elaboration of your formulae.

These “precautions” are extensively covered by Numerical analysis. This science was very important in paper & pencil era. I was initially educated with slide rules (no pocket calculator then) and this made you aware of many issues.

Computers are no different though faster with more digits.

@ajlittoz: :slight_smile:
no, the suggestion tries balancing between two evils, one is to leave ‘cancellation’ 'unprocessed, the other is to damage by rounding ‘finer values’ like irrational numbers,
according to my understanding pi() has no claim to be represented better than 15 digits, but if you want to do it, or my understanding is wrong, there might be a middle way where rounding is used to remove deviations from cancellation, but only so carefully that the damage to e.g. pi() is limited to the 17th decimal place and thus becomes marginal compared to the better subtraction results … old wisdom about wars, pandemics, other dangers: the greatest evil should be fought first, the greatest danger eliminated first, the greatest success sought first,
i don’t see that respected in calcs handling of cancellation,
and don’t worry, i’m not wasting your and my time to exchange nonsense, i have a good idea in my quiver for whose validity check i need calc to get a bit closer to correct results

let me try another approach to explain …
i can’t! prove to calculate 100percent correctly, just as little as ‘you’ or calc, but i show in the sheet on the basis of 1000 random! examples with up to 15 decimal digits - and of course you can do the same for other distributions of digits on ‘integer’ and fractional part - that calc makes errors with the simple calculation ‘=A-(A-C)’ not resulting in C, and not only a few but about 715 of 1000 tries are completely wrong → result zero (imho resulting from the previously mentioned ‘untargeted roundings’), and the rest have smaller errors, none! result is correct while all! ‘my’ results are absolutely correct (columns K, L and M),
where is your motivation to accept or defend such blatant errors within the 15-digit-definition-range to avoid an error of a complex calculation that ‘overuses’ the 15-bit range,
that’s like not rescuing a child from a creek because his sweater could get damaged … ???
‘quality’ - compare col. F-G K-L,

i can’t! prove to calculate 100percent correctly

Ok. But you could try to provide some evidence to at least some of numerous claims that you do.

on the basis of 1000 random! examples

Wrong. They all use the same first part.

calc makes errors with the simple calculation ‘=A-(A-C)’

Wrong. What you calculate is not “=A-(A-C)”, but double closest to A minus double closest to result of subtraction of a double closest to C from a double closest to A. And here is utterly important to realize what @Ajlittoz told you: “once you computed A2, you can no longer compensate”. On the other hand, as I told you, it’s often possible to improve a series of calculations; Kahan would improve the “SUM(A; C; -A)”.

all! ‘my’ results are absolutely correct

Wrong. They are not correct, they just match your expectations. In fact, all they are wrong, because they give result of a different operation than subtraction of two cells.

old wisdom about wars, pandemics, other dangers: the greatest evil should be fought first …

This is the claim that Calc should only target users of calculators? and any scientist, and user who calculates financial stuff like mortgage etc. using advanced arithmetic is second-class user?

One person in one of the bugs wanted Casio precision. You do the same. The hand calculators count with some greater precision, then round to 8 digits. As @ajlittoz told you, “your suggestion for rounding … assumes that all “digits” in range 91-09are the result of computation errors”. You are not “solving some greater evils first”, you are making the tool absolutely unusable for anything other than adding/subtracting manually entered round decimal numbers, and so make it a tool for simple user only. There is no way to “solve” the other part (that you broke this way) later, other than remove your change.

The problem with your suggested fix is you decompose a high-level sequence of operations into elementary dyadic operations and want to apply “improved rounding” on each. All known algorithms tend to keep in mind the ultimate goal so that the sequence can be reordered for minimal harm. Playing with the elementary operations increases both method and truncation errors. The algorithms focus on the method part first (and then the longer the sequence of interest the better so that minimal information about it is lost). Acting on truncation only is much more difficult. From the FPU point of view, all numbers are equally likely. Your claim is based on a set of specific numbers YOU know to possess some property. The FPU does not and can’t take it into account. The only way is obviously to manually include this property into the sequence of operations, but this makes this computation unique to the set and can’t be generalized. In a way, you’re defining an algorithm over the set.

hello @mikekaganski, and thanks that you still bear with me …
Wrong. They all use the same first part.
no, they calculate six digit random integer (A), plus 9 dig random decimal fraction (B), result in (C), and work on with that somewhat random value, showing that as well col. C minus col. E is odd in calc C-(C-E)!=E, as C minus ‘dec-ULP’: C-(C-J)!=J,
double closest to A
yes, there is no other chance in calc, but - imho - calc should try to simulate the correct ‘real world’ calculation, it IS! done in other cases, see ‘by scaling to 2^-48 and thus …’,
once you computed A2, you can no longer ...
yes, for that reason a correct result in each step! is neccessary,
"SUM(A; C; -A)"
fails - in calc - to produce school math output for school math operands as well as ‘-’,
give result of a different operation
they give the result of the subtraction of the real values the cells should represent, acc. users input, that’s somehow meaningful, isn’t it?
… continued …

They all use the 1,100000001 (E25).

As I said, they use the same part. (I agree that using word “first” was misleading, since I meant that E25 was above the other numbers, but it indeed was “last” in the formula.)

And that part was carefully chosen.

I see that you consider pi as “abnormal” case. Fine then. Let me use 1/3. Is it that much abnormal?

Put =1,1+1/3*10^-8 into E25 and tell me your observations. Then let’s continue discussing your claims about your method giving better result for a general case.

I wonder how substantiated is your claim that performing calculations with numbers having significant digits in the range of 10^5 to 10^-9 (as in your summation of 285932.xxx and 1.100000001) is typical to users who only care about decimal precision, opposed to users who need most out of the number range, where most numbers are not “regular” decimals.

biggest issue first
let’s think of engineering use,
astromonic: calculate two star positions with 17 digit accuracy and then having 35% fail in their relative position by ‘not correcting cancellation’ is worse than having 15 digit accuracy for position and appr. precision in subtraction,
length calculation: subtracting two distances with a cancellation fail of 0,005% is a bigger fail than measuring it with a roller of which the circumference is miscalculated by a factor of 10^-17,
see: i don’t argue against being able to keep accuracy for special values, i’d like to try to combine,
see: i don’t argue for things which haven’t been done in calc in a much more brutal style (scale to 48 …), i argue to pull that out as it clutters precision and replace it with something meaningful, targeted rounding,

trying 1/3 - yes, you are right, now you have choosen a value which is problematic for my formula, but! that value is intentional off from the range ‘15 digit decimals’, and that’s what is representable by IEEE 754 doubles, they are not! 16-digit safe, i had a case shortly where they had even been not 15-digit safe, but that might have been a fault from calcs rounding … will recheck later,
general case - what about talking about the ‘common case’ first,
my claim and 'range' - imho it would be good if calc would handle 15 digits correct and then extend to more where possible, i’m not targetting a special use,
sparing values spare / gut … i would have tried for a long time to round one decimal place less resp. tried to find a treshhold between ‘probably fp-artifact, can be rounded away’ and ‘too big for artifact, could be meaningful content’ which at the same time fulfills ‘if a finer - irrational - value is rounded then only very little’, ‘4-bit truncation’ blocks me …

1/3 - ‘fractional math’ … we don’t have that in decimals, decimals are a subset of fractionals, we don’t have that in binaries either, they are another subset of fractionals sharing some (few!) values with decimals,
fractional math or roots different from 2 would have been more powerful / correct, but had been to expensive some time ago and now we are stuck with a wide field of installed hard- and software limited to IEEE’s …
my first claim was - would be - use better datatypes, e.g. IEEE 2008, you said ‘no! - performance!’,
improving '754’s is only my ‘plan-B’, i think i have shown that there is room for such, would like to continue, for meaningful experiments i would have liked to switch off the 4-bit truncation,
ryū - remember, the man is good, but strange why it took that long until someone came around the corner with it …

but! that value is intentional off from the range ‘15 digit decimals’

I don’t know what you want to tell by that. And I don’t know why you imagine there’s “15 digit decimal” threshold to use. We use 53 bit mantissa. I don’t care about decimal digits (that’s just a representation, and people often confuse numbers and their representations, as you constantly do). When I have 1/3, I want it to be as precise as possible. You see cases when IEEE doubles introduce problems into “decimal” numbers. Yes, base-2 numbers can only correctly represent combinations of powers of 2, while base-10 may correctly represent combinations of powers of 2 and 5. Two times more representable numbers in the whole rational number range, right? And you ignore that combinations of powers of 2 and 5 represent a tiny fraction of all possible rational numbers (there are powers of 3, 7, 11, …); and the rational numbers constitute a tiny fraction of real numbers.

You try to improve something in “school math”, limiting “school math” to decimals. 1/7 is not a school math, according to you; not something feasible in a day-to-day math. You supply a sample of calculation of 10^5 plus 10^-9, and then talk about “common case” - something you have no idea about. Do you claim you know what “common” case is? please share the stats about cases.

Two times more representable numbers

Of course I’m wrong there; not two times. The specific quotient is of course much more. Yet, this doesn’t change things. The repertoire of numbers representable by base-10 is a tiny fraction of rationals.

1/3 - ‘fractional math’ … we don’t have that in decimals, decimals are a subset of fractionals, we don’t have that in binaries either, they are another subset of fractionals sharing some (few!) values with decimals

… and what you try to do is to make closest possible imperfect representation of those much worse. So the reasonable precision of dealing with those numbers present now will be destroyed. You seem to not understand that at all.

@mikekaganski: that’s the point, i understand humans and decimals they feed into a computer as ‘the thing’, and the computer and software … as a tool to help them solving their - mostly decimal - tasks, you understand the computer and the IEEE’s as their own world, and people have to learn to live with it, we won’t get this together, i have the feeling that plenty users, some devs and most people who complain about errors in calc do it from my pov,
15 decimal digits is the claimed ‘range’ where 64-bit doubles hold a series of decimal → binary - decimal conversions, thus the range where reliable math is possible, (it varies depending relation decimal to binary range, 15 digits is lower limit),
school math with fractions is more powerful than decimal math, but most humans use decimals after school, if calc could calculate better with fractions I would use and recommend this immediately, will provide the sheet with user chooseable ranges for the operands shortly …

@ajlittoz: ‘In a way, you’re defining an algorithm over the set.’ - yes, may be that describes my understanding and approach, IEEE doubles are a subset of values, and do have a math working inside them, except for a few spinoffs at underflow or overflow, NaN’s and so on, and at cancellation, of which cancellation causes most irritations for users,
if one now takes from this set the ‘subset’ which corresponds with ‘closest representation’ to decimal numbers with 15 significant digits, one can define a mathematics over it which computes somewhat less exactly with irrational values, but within its definition range by rounding artifacts from representation inaccuracies and operations and !cancellation can largely be eliminated, (limited to a ULP of the result!?),

this i would see as the right step to make calc a tool for users to solve everyday tasks instead of a binary adventure guessing and researching why - from the user’s point of view - obviously wrong results are called correct,

@mikekaganski: would you consider re-testing your ‘Pythagoras-pi()’ sample with factors of 3*pi() in col. B, and then re-think if this special case of a calculation with an irrational value holding ‘by chance!’ is a justifying argument to block out attempts to make all! calculations with qualified 16 digit decimal values correct?