Skip to content

compensated sum was not compensating - #1127

Merged
VincentVanlaer merged 1 commit into
mainfrom
MZ/compensated_sum
Nov 19, 2026
Merged

VincentVanlaer merged 1 commit into
mainfrom
MZ/compensated_sum

Conversation

@zingale

@zingale zingale commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

If you do: 1.e40 + 1 - 1.e40, the current compensated sum (both the quad precision and autodiff version) gives 0, when it should give 1.

This fixes this behavior by properly grouping the compensated terms in parentheses and adding a unit test.

@zingale zingale added the numerics issues with math/num/mtx modules label Nov 19, 2026
@VincentVanlaer

Copy link
Copy Markdown
Member

Seems like this was the case this code was introduced. Unfortunate that it did not receive proper testing the meantime.

Is this PR [WIP] to see whether something falls out of the test suite, or do you plan to add something else?

@zingale

zingale commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

just wanted to get the tests run. Otherwise it is done. I'll remove WIP

@zingale zingale changed the title [WIP] compensated sum was not compensating compensated sum was not compensating Nov 19, 2026
@zingale

zingale commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

it seems that the ppisn test fails with this fix.

@VincentVanlaer

Copy link
Copy Markdown
Member

I suspect this is caused by #1115 (which has been reverted in the meantime)

@VincentVanlaer
VincentVanlaer merged commit 703aa83 into main Nov 19, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

numerics issues with math/num/mtx modules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants