Average Error: 31.9 → 0.3
Time: 16.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 r34950 = im;
        double r34951 = re;
        double r34952 = atan2(r34950, r34951);
        double r34953 = base;
        double r34954 = log(r34953);
        double r34955 = r34952 * r34954;
        double r34956 = r34951 * r34951;
        double r34957 = r34950 * r34950;
        double r34958 = r34956 + r34957;
        double r34959 = sqrt(r34958);
        double r34960 = log(r34959);
        double r34961 = 0.0;
        double r34962 = r34960 * r34961;
        double r34963 = r34955 - r34962;
        double r34964 = r34954 * r34954;
        double r34965 = r34961 * r34961;
        double r34966 = r34964 + r34965;
        double r34967 = r34963 / r34966;
        return r34967;
}

double f(double re, double im, double base) {
        double r34968 = im;
        double r34969 = re;
        double r34970 = atan2(r34968, r34969);
        double r34971 = base;
        double r34972 = log(r34971);
        double r34973 = r34970 / r34972;
        return r34973;
}

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(-0.0, \log \left(\mathsf{hypot}\left(im, re\right)\right), \log base \cdot \tan^{-1}_* \frac{im}{re}\right)}{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt0.4

    \[\leadsto \frac{\mathsf{fma}\left(-0.0, \log \left(\mathsf{hypot}\left(im, re\right)\right), \log base \cdot \tan^{-1}_* \frac{im}{re}\right)}{\color{blue}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)} \cdot \sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}}\]
  5. Applied *-un-lft-identity0.4

    \[\leadsto \frac{\color{blue}{1 \cdot \mathsf{fma}\left(-0.0, \log \left(\mathsf{hypot}\left(im, re\right)\right), \log base \cdot \tan^{-1}_* \frac{im}{re}\right)}}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)} \cdot \sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}\]
  6. Applied times-frac0.4

    \[\leadsto \color{blue}{\frac{1}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}} \cdot \frac{\mathsf{fma}\left(-0.0, \log \left(\mathsf{hypot}\left(im, re\right)\right), \log base \cdot \tan^{-1}_* \frac{im}{re}\right)}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}}\]
  7. Simplified0.4

    \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(0.0, \log base\right)}} \cdot \frac{\mathsf{fma}\left(-0.0, \log \left(\mathsf{hypot}\left(im, re\right)\right), \log base \cdot \tan^{-1}_* \frac{im}{re}\right)}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}\]
  8. Simplified0.4

    \[\leadsto \frac{1}{\mathsf{hypot}\left(0.0, \log base\right)} \cdot \color{blue}{\frac{\mathsf{fma}\left(\log base, \tan^{-1}_* \frac{im}{re}, \log \left(\mathsf{hypot}\left(im, re\right)\right) \cdot \left(-0.0\right)\right)}{\mathsf{hypot}\left(0.0, \log base\right)}}\]
  9. Taylor expanded around 0 0.3

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

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

Reproduce

herbie shell --seed 2019194 +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))))