3 ms·
>I tried replacing exp(x) - 1 with expm1(x). This made no difference. Interestingly, in Rust, all four q(x) are non-zero, using f32::exp / f64::exp in e(x) con
by Arnavion 7y ago
>I tried replacing exp(x) - 1 with expm1(x). This made no difference.
Interestingly, in Rust, all four q(x) are non-zero, using f32::exp / f64::exp in e(x) consistently gives 0, and using f32::exp_m1 / f64::exp_m1 consistently gives 1. (Given non-zero q(x), this is to be expected.) Both f32::exp_m1 and f64::exp_m1 are implemented using libm's expm1 [1], so I wonder what the author's C++ compiler is doing instead.
https://play.rust-lang.org/?version=stable&mode=release&edition=2018&gist=9b93c17e9effed0f0fe88ca206c02d23 https://play.rust-lang.org/?version=stable&mode=release&edit...
[1]: https://doc.rust-lang.org/src/std/f64.rs.html#724-726 https://doc.rust-lang.org/src/std/f64.rs.html#724-726 + https://github.com/rust-lang/rust/blob/bc0e288ad02ef362b5a6c42aaf61f2901c9b46db/src/libstd/sys/unix/cmath.rs#L19-L20 https://github.com/rust-lang/rust/blob/bc0e288ad02ef362b5a6c...
Edit: Actually, I can't reproduce the author's situation on godbolt. The expm1 method consistenly returns 1. https://gcc.godbolt.org/z/RvsdHU https://gcc.godbolt.org/z/RvsdHU