Average Error: 31.5 → 0.3
Time: 21.6s
Precision: 64
\[\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
\[-\frac{\tan^{-1}_* \frac{im}{re}}{-\log base}\]
\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}
-\frac{\tan^{-1}_* \frac{im}{re}}{-\log base}
double f(double re, double im, double base) {
        double r100291 = im;
        double r100292 = re;
        double r100293 = atan2(r100291, r100292);
        double r100294 = base;
        double r100295 = log(r100294);
        double r100296 = r100293 * r100295;
        double r100297 = r100292 * r100292;
        double r100298 = r100291 * r100291;
        double r100299 = r100297 + r100298;
        double r100300 = sqrt(r100299);
        double r100301 = log(r100300);
        double r100302 = 0.0;
        double r100303 = r100301 * r100302;
        double r100304 = r100296 - r100303;
        double r100305 = r100295 * r100295;
        double r100306 = r100302 * r100302;
        double r100307 = r100305 + r100306;
        double r100308 = r100304 / r100307;
        return r100308;
}

double f(double re, double im, double base) {
        double r100309 = im;
        double r100310 = re;
        double r100311 = atan2(r100309, r100310);
        double r100312 = base;
        double r100313 = log(r100312);
        double r100314 = -r100313;
        double r100315 = r100311 / r100314;
        double r100316 = -r100315;
        return r100316;
}

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 31.5

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

    \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - 0.0 \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)}{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}\]
  3. Taylor expanded around inf 0.3

    \[\leadsto \color{blue}{-1 \cdot \frac{\tan^{-1}_* \frac{im}{re}}{\log \left(\frac{1}{base}\right)}}\]
  4. Simplified0.3

    \[\leadsto \color{blue}{-\frac{\tan^{-1}_* \frac{im}{re}}{-\log base}}\]
  5. Final simplification0.3

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

Reproduce

herbie shell --seed 2019306 +o rules:numerics
(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))))