Average Error: 32.3 → 0.3
Time: 12.3s
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 r49342 = im;
        double r49343 = re;
        double r49344 = atan2(r49342, r49343);
        double r49345 = base;
        double r49346 = log(r49345);
        double r49347 = r49344 * r49346;
        double r49348 = r49343 * r49343;
        double r49349 = r49342 * r49342;
        double r49350 = r49348 + r49349;
        double r49351 = sqrt(r49350);
        double r49352 = log(r49351);
        double r49353 = 0.0;
        double r49354 = r49352 * r49353;
        double r49355 = r49347 - r49354;
        double r49356 = r49346 * r49346;
        double r49357 = r49353 * r49353;
        double r49358 = r49356 + r49357;
        double r49359 = r49355 / r49358;
        return r49359;
}

double f(double re, double im, double base) {
        double r49360 = im;
        double r49361 = re;
        double r49362 = atan2(r49360, r49361);
        double r49363 = base;
        double r49364 = log(r49363);
        double r49365 = -r49364;
        double r49366 = r49362 / r49365;
        double r49367 = -r49366;
        return r49367;
}

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.3

    \[\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 2019350 +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))))