Average Error: 31.4 → 0.0
Time: 930.0ms
Precision: 64
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
\[\log \left(1 \cdot \mathsf{hypot}\left(re, im\right)\right)\]
\log \left(\sqrt{re \cdot re + im \cdot im}\right)
\log \left(1 \cdot \mathsf{hypot}\left(re, im\right)\right)
double code(double re, double im) {
	return ((double) log(((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im))))))));
}
double code(double re, double im) {
	return ((double) log(((double) (1.0 * ((double) 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.4

    \[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
  2. Using strategy rm
  3. Applied *-un-lft-identity31.4

    \[\leadsto \log \left(\sqrt{\color{blue}{1 \cdot \left(re \cdot re + im \cdot im\right)}}\right)\]
  4. Applied sqrt-prod31.4

    \[\leadsto \log \color{blue}{\left(\sqrt{1} \cdot \sqrt{re \cdot re + im \cdot im}\right)}\]
  5. Simplified31.4

    \[\leadsto \log \left(\color{blue}{1} \cdot \sqrt{re \cdot re + im \cdot im}\right)\]
  6. Simplified0.0

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

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

Reproduce

herbie shell --seed 2020114 +o rules:numerics
(FPCore (re im)
  :name "math.log/1 on complex, real part"
  :precision binary64
  (log (sqrt (+ (* re re) (* im im)))))