Average Error: 32.0 → 0.4
Time: 6.8s
Precision: binary64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0} \]
\[\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log base} \]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}
\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log base}
(FPCore (re im base)
 :precision binary64
 (/
  (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0.0))
  (+ (* (log base) (log base)) (* 0.0 0.0))))
(FPCore (re im base) :precision binary64 (/ (log (hypot re im)) (log base)))
double code(double re, double im, double base) {
	return ((log(sqrt((re * re) + (im * im))) * log(base)) + (atan2(im, re) * 0.0)) / ((log(base) * log(base)) + (0.0 * 0.0));
}
double code(double re, double im, double base) {
	return log(hypot(re, im)) / log(base);
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 32.0

    \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0} \]
  2. Simplified0.4

    \[\leadsto \color{blue}{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log base}} \]
  3. Using strategy rm
  4. Applied add-log-exp_binary640.7

    \[\leadsto \color{blue}{\log \left(e^{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log base}}\right)} \]
  5. Simplified0.7

    \[\leadsto \log \color{blue}{\left({\left(\mathsf{hypot}\left(im, re\right)\right)}^{\left(\frac{1}{\log base}\right)}\right)} \]
  6. Taylor expanded around -inf 64.0

    \[\leadsto \color{blue}{\log \left(e^{\frac{\log \left(\sqrt{{re}^{2} + {im}^{2}}\right)}{\log -1 - \log \left(\frac{-1}{base}\right)}}\right)} \]
  7. Simplified0.4

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

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

Reproduce

herbie shell --seed 2021211 
(FPCore (re im base)
  :name "math.log/2 on complex, real part"
  :precision binary64
  (/ (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))