New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure to look at square of tolerances #14126
Conversation
/rebuild |
Please wait before merging this. It seems the test numbers support your interpretation, but I would like to ask your opinion on two questions first:
Did I miss something?
I would be in favor of erring on the side of a lax check. Then at least only models that make mistakes crash, and not models that use the code as intended. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, I think you are right. I had had in my head that we are comparing
if (x*x == y*y)
with a tolerance, for which the tolerance should be 1e-16*(x*x)
. But in reality, we are comparing
if ( (x-y)*(x-y) == 0)
and you are right that the tolerance in that case should be (1e-16*abs(x))**2
or something proportional.
I'll let @gassmoeller finish his thought, though.
Indeed, I agree with what @bangerth wrote. I would be happy with a lax check as well. If we are fine with tolerances around 1e-7/1e-8, I would be happy to just add the comment to the commit and keep the present numbers. |
You are right @bangerth, we are computing the square of the difference, not the difference of the square, my mistake. Ok, then go ahead. I still do not think it will matter in the end, but I am at least reasonably certain we are not going to break anything with this PR. |
Ensure to look at square of tolerances
@bangerth @gassmoeller regarding the tolerance topic I checked the numbers again and believe we should have squares. The reason is that we take the difference between two vertices (each component of which we expect to either satisfy a relative tolerance against the cell diameter or against the absolute tolerance), and then the square in
square()
orsquare_distance()
. As a result, the numbers should really be on the order ofmachine_epsilon^2
. I looked into prototype numbers of the test that was added in #14092 and can confirm that numbers are really in that order of magnitude: We see squares of around 1e-19, compared to numbers which are 1e13, all of them being squares of either size 1e6 or 1e-9, the roundoff accuracy around 1e6.