Average Error: 31.7 → 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 r93539 = im;
        double r93540 = re;
        double r93541 = atan2(r93539, r93540);
        double r93542 = base;
        double r93543 = log(r93542);
        double r93544 = r93541 * r93543;
        double r93545 = r93540 * r93540;
        double r93546 = r93539 * r93539;
        double r93547 = r93545 + r93546;
        double r93548 = sqrt(r93547);
        double r93549 = log(r93548);
        double r93550 = 0.0;
        double r93551 = r93549 * r93550;
        double r93552 = r93544 - r93551;
        double r93553 = r93543 * r93543;
        double r93554 = r93550 * r93550;
        double r93555 = r93553 + r93554;
        double r93556 = r93552 / r93555;
        return r93556;
}

double f(double re, double im, double base) {
        double r93557 = im;
        double r93558 = re;
        double r93559 = atan2(r93557, r93558);
        double r93560 = base;
        double r93561 = log(r93560);
        double r93562 = -r93561;
        double r93563 = r93559 / r93562;
        double r93564 = -r93563;
        return r93564;
}

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

    \[\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{\mathsf{fma}\left(\tan^{-1}_* \frac{im}{re}, \log base, -0.0 \cdot \log \left(\mathsf{hypot}\left(re, im\right)\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 2020042 +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))))