Open
Description
I found that in version 0.4.5 for complex numbers close to 1 the implementation of the complex logarithm ln
looses many digits of precision:
use num::complex::Complex;
fn main() {
let z = Complex::new(0.999995168714454, -0.004396919500211628);
println!("z.ln() = {}", z.ln());
// result: 0.0000048351532916926595 - 0.0043969124079359465i
// expected result: 4.8351532916397e-6 - 0.0043969124079359465i
}
Link to rust playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d300b26da9fc5bed4304f52b99989386
To my knowledge there are algorithms to avoid such problems, for example by scaling the magnitude of the complex number accordingly.
Metadata
Metadata
Assignees
Labels
No labels