Average Error: 31.8 → 0
Time: 743.0ms
Precision: 64
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
\[\log \left(\mathsf{hypot}\left(re, im\right)\right)\]
\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));
}

Error

Bits error versus re

Bits error versus im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 31.8

    \[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
  2. Using strategy rm
  3. Applied hypot-def0

    \[\leadsto \log \color{blue}{\left(\mathsf{hypot}\left(re, im\right)\right)}\]
  4. Final simplification0

    \[\leadsto \log \left(\mathsf{hypot}\left(re, im\right)\right)\]

Reproduce

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)))))