Average Error: 31.9 → 0.3
Time: 12.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{\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 r91965 = im;
        double r91966 = re;
        double r91967 = atan2(r91965, r91966);
        double r91968 = base;
        double r91969 = log(r91968);
        double r91970 = r91967 * r91969;
        double r91971 = r91966 * r91966;
        double r91972 = r91965 * r91965;
        double r91973 = r91971 + r91972;
        double r91974 = sqrt(r91973);
        double r91975 = log(r91974);
        double r91976 = 0.0;
        double r91977 = r91975 * r91976;
        double r91978 = r91970 - r91977;
        double r91979 = r91969 * r91969;
        double r91980 = r91976 * r91976;
        double r91981 = r91979 + r91980;
        double r91982 = r91978 / r91981;
        return r91982;
}

double f(double re, double im, double base) {
        double r91983 = im;
        double r91984 = re;
        double r91985 = atan2(r91983, r91984);
        double r91986 = base;
        double r91987 = log(r91986);
        double r91988 = -r91987;
        double r91989 = r91985 / r91988;
        double r91990 = -r91989;
        return r91990;
}

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

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