Average Error: 30.9 → 0.4
Time: 5.5s
Precision: binary64
\[\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
\[\tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\log base}\]
\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0}{\log base \cdot \log base + 0 \cdot 0}
\tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\log base}
(FPCore (re im base)
 :precision binary64
 (/
  (- (* (atan2 im re) (log base)) (* (log (sqrt (+ (* re re) (* im im)))) 0.0))
  (+ (* (log base) (log base)) (* 0.0 0.0))))
(FPCore (re im base) :precision binary64 (* (atan2 im re) (/ 1.0 (log base))))
double code(double re, double im, double base) {
	return (((double) (((double) (((double) atan2(im, re)) * ((double) log(base)))) - ((double) (((double) log(((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im)))))))) * 0.0)))) / ((double) (((double) (((double) log(base)) * ((double) log(base)))) + ((double) (0.0 * 0.0)))));
}
double code(double re, double im, double base) {
	return ((double) (((double) atan2(im, re)) * (1.0 / ((double) 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 Error: 30.9 bits

    \[\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
  2. Taylor expanded around 0 Error: 0.3 bits

    \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re}}{\log 1 + \log base}}\]
  3. SimplifiedError: 0.3 bits

    \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re}}{\log base}}\]
  4. Using strategy rm
  5. Applied div-invError: 0.4 bits

    \[\leadsto \color{blue}{\tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\log base}}\]
  6. Final simplificationError: 0.4 bits

    \[\leadsto \tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\log base}\]

Reproduce

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