-
Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.
Description
The functions asinh and acosh for both f32 and f64 are quite inaccurate, both for very large inputs (because x * x overflows) and, for asinh, for very small inputs (due to kinda-complex cancellation).
I tried this code:
fn main() {
println!("{}", (600.0 as f64).sinh().asinh());
println!("{}", (1e-16 as f64).sinh().asinh());
println!("{}", (600.0 as f64).cosh().acosh());
println!("{}", (60.0 as f32).sinh().asinh());
println!("{}", (1e-8 as f32).sinh().asinh());
println!("{}", (60.0 as f32).cosh().acosh());
}This code evaluates asinh(sinh(x)) and acosh(cosh(x)). Naturally I expected the output to be x, but instead the output is inf and 0, indicating overflow and cancellation.
Meta
I ran this in the Rust Playground on both Stable (1.65.0) and Nightly (2022-11-16 e9493d63c2a57b91556d).
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.