Average Error: 32.1 → 0.4
Time: 8.7s
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} \]
\[\begin{array}{l} t_0 := \sqrt{\mathsf{hypot}\left(re, im\right)}\\ \frac{\log \left(t_0 \cdot t_0\right)}{\log base} \end{array} \]
\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}
\begin{array}{l}
t_0 := \sqrt{\mathsf{hypot}\left(re, im\right)}\\
\frac{\log \left(t_0 \cdot t_0\right)}{\log base}
\end{array}
(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
 (let* ((t_0 (sqrt (hypot re im)))) (/ (log (* t_0 t_0)) (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) {
	double t_0 = sqrt(hypot(re, im));
	return log(t_0 * t_0) / 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.1

    \[\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. Applied add-sqr-sqrt_binary640.4

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

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

Reproduce

herbie shell --seed 2021357 
(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))))