-
Hi, We are wondering if there is a way to minimize the division numerical error between np and jnp, when the denominator and nummerator are almost 0. We have tried to cast the jax.numpy to use float64 so as to match with numpy, but it still cannot handle the following line as expected: numpy version: jnp version: The values being passed in to both lines are the same, but the results vary too much. Input:
Intermediate computation in cos_az:
Output:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi - thanks for the question! It would be much easier to diagnose what's happening and answer your question if you could create a minimal reproducible example: i.e a block of code that others could run to reproduce the results you're seeing. For example, I have no idea what |
Beta Was this translation helpful? Give feedback.
-
First, the original example in the issue and the provided reproducer are not related with respect to the source of numerical errors. While JAX and numpy apparently use different algorithms for arcsin (or these use different FTZ modes), the differences between results are within acceptable limits (less than or equal to 1 ULP). The example tries to evaluate I recommend splitting the evaluation of |
Beta Was this translation helpful? Give feedback.
First, the original example in the issue and the provided reproducer are not related with respect to the source of numerical errors. While JAX and numpy apparently use different algorithms for arcsin (or these use different FTZ modes), the differences between results are within acceptable limits (less than or equal to 1 ULP).
The example tries to evaluate
cos_az
close to (south?) pole where its expression is 0/0 indeterminate. It is not clear from the post which of the results is expected. So, when applying L’Hopital’s Rule for the limit process lat->-pi/2, I conclude that the expected result ofcos_az
approaches to 0. This matches with JAX results. On the other hand, I would not blame nu…