\log \left(\sqrt{re \cdot re + im \cdot im}\right)\log \left(\mathsf{hypot}\left(re, im\right)\right)double code(double re, double im) {
return log(sqrt(((re * re) + (im * im))));
}
double code(double re, double im) {
return log(hypot(re, im));
}



Bits error versus re



Bits error versus im
Results
Initial program 31.8
rmApplied hypot-def0
Final simplification0
herbie shell --seed 2020057 +o rules:numerics
(FPCore (re im)
:name "math.log/1 on complex, real part"
:precision binary64
(log (sqrt (+ (* re re) (* im im)))))