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).
The functions
asinhandacoshfor bothf32andf64are quite inaccurate, both for very large inputs (becausex * xoverflows) and, forasinh, for very small inputs (due to kinda-complex cancellation).I tried this code:
This code evaluates
asinh(sinh(x))andacosh(cosh(x)). Naturally I expected the output to bex, but instead the output isinfand0, indicating overflow and cancellation.Meta
I ran this in the Rust Playground on both Stable (1.65.0) and Nightly (
2022-11-16 e9493d63c2a57b91556d).