Average Error: 32.7 → 0.4
Time: 34.8s
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{1}{\log base} \cdot \tan^{-1}_* \frac{im}{re}\]
\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{1}{\log base} \cdot \tan^{-1}_* \frac{im}{re}
double f(double re, double im, double base) {
        double r2061470 = im;
        double r2061471 = re;
        double r2061472 = atan2(r2061470, r2061471);
        double r2061473 = base;
        double r2061474 = log(r2061473);
        double r2061475 = r2061472 * r2061474;
        double r2061476 = r2061471 * r2061471;
        double r2061477 = r2061470 * r2061470;
        double r2061478 = r2061476 + r2061477;
        double r2061479 = sqrt(r2061478);
        double r2061480 = log(r2061479);
        double r2061481 = 0.0;
        double r2061482 = r2061480 * r2061481;
        double r2061483 = r2061475 - r2061482;
        double r2061484 = r2061474 * r2061474;
        double r2061485 = r2061481 * r2061481;
        double r2061486 = r2061484 + r2061485;
        double r2061487 = r2061483 / r2061486;
        return r2061487;
}

double f(double re, double im, double base) {
        double r2061488 = 1.0;
        double r2061489 = base;
        double r2061490 = log(r2061489);
        double r2061491 = r2061488 / r2061490;
        double r2061492 = im;
        double r2061493 = re;
        double r2061494 = atan2(r2061492, r2061493);
        double r2061495 = r2061491 * r2061494;
        return r2061495;
}

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.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{\log base \cdot \tan^{-1}_* \frac{im}{re} - 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 0 0.3

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

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

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

Reproduce

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