-
Notifications
You must be signed in to change notification settings - Fork 70
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
Floating-point precision error in calculating angles #324
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
When using
qcel.util.measure_coordinates
to measure an angle between coordinates, an angle of 180° can cause anan
value to be returned. The bug is caused by a floating-point precision error in calculating the cosine of the angle; if the cosine is greater than1.0
due to noise thennp.arccos
will returnnan
.To Reproduce
The first prints
180.0
as expected, the second returns anan
(calculated cosine is1.0000000000000002
).Using qcelemental 0.25.0
Expected behavior
The calculated cosine should be properly bounded within [-1, 1].
Additional context
The text was updated successfully, but these errors were encountered: