Comments (17)
Yes, but we should not just rely on what the current behavior is in stdlib, as the current behavior could be wrong. In this case, we need to consult the specification to ensure that our current atan
behavior adheres to IEEE 754 semantics.
In this case, it does. Which just means that our current atanf
implementation does not handle signed zero correctly.
from stdlib.
When you make patch, can you also add corresponding tests to atanf
?
from stdlib.
Great, I'll follow that. Thanks for clearing this out.
This can be a nice example for why we shouldn't rely on just one source, like cephes
.
from stdlib.
Indeed! And the importance of tests! We are apparently missing corresponding tests in atan
, as well. You can include those in your patch.
from stdlib.
I'd like to work on this.
from stdlib.
Hey @kgryte, while implementing this, I got to know that, since we require atanf
for this, and upon passing -infinity
to acotf
, or -0
to atanf
, our atanf
returns 0
, instead of -0
. This applies for both C and JavaScript implementations of atanf
.
This leads to the failure of one particular test case, which checks if the function returns "-0" if provided "-infinity"
.
from stdlib.
In the case of current acot
, this problem doesn't arise, but it does come up in case of acotf
.
from stdlib.
Which behavior is the correct behavior?
from stdlib.
The correct behavior is that of acot
, i.e, it returns -0
when provided -infinity
.
Applying the same implementation for acotf
, this fails.
from stdlib.
The question is more fundamental. Should atan
distinguish between signed zeros? This is a mathematical question.
from stdlib.
It's possible, e.g., that the tests for acot
are incorrect, but this gets back to what the behavior of atan
should be.
from stdlib.
We get our answer from http://www.dsc.ufcg.edu.br/~cnum/modulos/Modulo2/IEEE754_2008.pdf
For the functions expm1, exp2m1, exp10m1, logp1, log2p1, log10p1, sin, tan, sinPi, atanPi, asin, atan, sinh, tanh, asinh, and atanh, f (+0) is +0 and f (−0) is −0 with no exception.
Meaning, atanf
is incorrect here.
from stdlib.
When I checked logging the values with atan
, it returns:
atan( -0 ) = -0
atan( +0 ) = 0
from stdlib.
Yes, and also, upon doing the same for atanf
, it gives 0
in both cases.
We might need to modify our atanf
implementation.
from stdlib.
The reason it doesn't is pretty straightforward. We just need to make a small modification to atanf
which we can observe in atan
. Namely, the following
should be modified to
if ( isnanf( x ) ) {
+ if ( isnanf( x ) || x === 0.0 ) {
+ return x;
This is a bug in the original Cephes implementation. You'll want to fix in both our JS and C atanf
implementations.
from stdlib.
Sure, I'll do it. Should this be added in the same PR as that of acotf
, or a seperate one ?
from stdlib.
I suggest making a quick patch in a separate PR to keep things clean.
from stdlib.
Related Issues (20)
- [RFC]: Time Series Generation Module HOT 2
- [RFC]: Add C implementtation for `@stdlib/math/base/special/factorial` HOT 1
- [BUG]: test workflow is not running tests in nested test directories
- [RFC]: Add C implementation for `@stdlib/math/base/special/minmax` HOT 2
- [RFC]: add `math/base/special/acscf` HOT 1
- [RFC]: add type declarations to @stdlib/utils/compact-adjacency-matrix HOT 1
- [RFC]: add `fs/mkdir` HOT 5
- [RFC]: add `math/base/special/asecf` HOT 1
- [RFC]: add various physical constants (tracking issue) HOT 7
- `binding.gyp` not found in math-base-special-ln HOT 3
- [RFC]: add `math/base/special/rad2degf` HOT 2
- [RFC]: add `blas/base/zdotu` HOT 8
- [RFC]: add `math/base/special/asinhf` HOT 5
- [RFC]: add `help()` documentation pager in REPL HOT 1
- Binomcoef function evaluation is not memoized and can take very long to run given large n HOT 5
- [RFC]: automated/make recipe for generation of manifest files for C implementation of a package
- [RFC]: refactor `math/base/special/log2` to follow FreeBSD version 12.2.0 HOT 1
- [RFC]: add `blas/base/csscal`
- [RFC]: add stdlib ASCII art in REPL's default welcome message HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stdlib.