Average Error: 31.8 → 0.3
Time: 19.4s
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 r109403 = im;
        double r109404 = re;
        double r109405 = atan2(r109403, r109404);
        double r109406 = base;
        double r109407 = log(r109406);
        double r109408 = r109405 * r109407;
        double r109409 = r109404 * r109404;
        double r109410 = r109403 * r109403;
        double r109411 = r109409 + r109410;
        double r109412 = sqrt(r109411);
        double r109413 = log(r109412);
        double r109414 = 0.0;
        double r109415 = r109413 * r109414;
        double r109416 = r109408 - r109415;
        double r109417 = r109407 * r109407;
        double r109418 = r109414 * r109414;
        double r109419 = r109417 + r109418;
        double r109420 = r109416 / r109419;
        return r109420;
}

double f(double re, double im, double base) {
        double r109421 = im;
        double r109422 = re;
        double r109423 = atan2(r109421, r109422);
        double r109424 = base;
        double r109425 = log(r109424);
        double r109426 = -r109425;
        double r109427 = r109423 / r109426;
        double r109428 = -r109427;
        return r109428;
}

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

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