Skip to content
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

Python: unexplained discrepancy in calculations with other languages #378

Open
cosinekitty opened this issue Jan 27, 2025 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@cosinekitty
Copy link
Owner

The other language pairs tested by generate/diffcalc all agree with each other within about 6.0e-15. However, Python suddenly lost precision. For now I'm going to patch diffcalc to have a larger error tolerance, but this needs to be investigated and fixed.

First  file: temp/c_check.txt
Second file: temp/py_check.txt
Tolerance = 4.000e-12

            lnum                 a_value                 b_value     factor       diff  name
  OK       22073  2.4668955106186205e-01  2.4668955106091364e-01    3.25733  3.089e-12  helio_x
  OK        5166  1.1953727682351487e-02  1.1953727681402368e-02    3.25733  3.092e-12  helio_y
  OK        5166  4.6053567996951844e-02  4.6053567996540354e-02    3.25733  1.340e-12  helio_z
  OK       81758  4.7416398275054599e+00  4.7416398274975968e+00    0.01730  1.360e-13  sky_j2000_ra
  OK      522326 -2.9618752903733236e-01 -2.9618752899582923e-01    0.00556  2.306e-13  sky_j2000_dec
  OK        5952  6.0769706688656411e-01  6.0769706688737724e-01    3.54610  2.883e-12  sky_j2000_dist
  OK       54701  3.4252017097808329e+02  3.4252017097859942e+02    0.00275  1.422e-12  sky_hor_az
  OK        7489 -4.9974625864690580e+01 -4.9974625864819728e+01    0.00556  7.175e-13  sky_hor_alt
  OK        2085  3.9813854037812494e-03  3.9813854037812502e-03  223.21429  1.936e-16  jm_x
  OK       61071 -2.2351447277631164e-03 -2.2351447277631155e-03  223.21429  1.936e-16  jm_y
  OK       61071 -1.1075179242594577e-03 -1.1075179242594573e-03  223.21429  9.680e-17  jm_z
  OK      243394 -7.1148311390774070e-03 -7.1148311390774087e-03  126.58228  2.196e-16  jm_vx
  OK       96772  3.0202250049769577e-03  3.0202250049769586e-03  212.76596  1.845e-16  jm_vy
  OK       15627  3.5037044145441172e-03  3.5037044145441181e-03  100.00000  8.674e-17  jm_vz
  OK        2871 -1.5575664421775793e+01 -1.5575664421775796e+01    0.10000  3.553e-16  psi
  OK      104284  5.5823579796157814e+00  5.5823579796157796e+00    0.10000  1.776e-16  eps
  OK      234263  4.3622390731197669e+00  4.3622390731197607e+00    0.00556  3.454e-17  moon_lat
  OK      447848  2.9698680233665476e+02  2.9698680233665470e+02    0.00275  1.564e-16  moon_lon
  OK      235220  2.6472641919042627e-03  2.6472641919042619e-03  333.33333  2.891e-16  moon_dist

Score = 3.092e-12
@cosinekitty cosinekitty added the bug Something isn't working label Jan 27, 2025
@cosinekitty cosinekitty self-assigned this Jan 27, 2025
cosinekitty added a commit that referenced this issue Jan 27, 2025
See issue #378 - suddenly newer versions of Python no longer
match C, C#, JavaScript, Kotlin, and Java in terms of calculations.
We only get about 12 decimal places of agreement instead of 15.

For now I'm going to relax the precision requirement so the unit
tests still run to completion. But I need to come back diagnose
where Python doesn't calculate things the same way as C.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant