Average Error: 32.3 → 0.4
Time: 8.8s
Precision: 64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
\[\frac{\frac{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(re, im\right)\right), \log base, \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}{\mathsf{hypot}\left(\log base, 0.0\right) \cdot 1}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}
\frac{\frac{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(re, im\right)\right), \log base, \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}{\mathsf{hypot}\left(\log base, 0.0\right) \cdot 1}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}
double f(double re, double im, double base) {
        double r43943 = re;
        double r43944 = r43943 * r43943;
        double r43945 = im;
        double r43946 = r43945 * r43945;
        double r43947 = r43944 + r43946;
        double r43948 = sqrt(r43947);
        double r43949 = log(r43948);
        double r43950 = base;
        double r43951 = log(r43950);
        double r43952 = r43949 * r43951;
        double r43953 = atan2(r43945, r43943);
        double r43954 = 0.0;
        double r43955 = r43953 * r43954;
        double r43956 = r43952 + r43955;
        double r43957 = r43951 * r43951;
        double r43958 = r43954 * r43954;
        double r43959 = r43957 + r43958;
        double r43960 = r43956 / r43959;
        return r43960;
}

double f(double re, double im, double base) {
        double r43961 = re;
        double r43962 = im;
        double r43963 = hypot(r43961, r43962);
        double r43964 = log(r43963);
        double r43965 = base;
        double r43966 = log(r43965);
        double r43967 = atan2(r43962, r43961);
        double r43968 = 0.0;
        double r43969 = r43967 * r43968;
        double r43970 = fma(r43964, r43966, r43969);
        double r43971 = hypot(r43966, r43968);
        double r43972 = 1.0;
        double r43973 = r43971 * r43972;
        double r43974 = r43970 / r43973;
        double r43975 = r43966 * r43966;
        double r43976 = r43968 * r43968;
        double r43977 = r43975 + r43976;
        double r43978 = sqrt(r43977);
        double r43979 = r43974 / r43978;
        return r43979;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 32.3

    \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
  2. Using strategy rm
  3. Applied hypot-def0.5

    \[\leadsto \frac{\log \color{blue}{\left(\mathsf{hypot}\left(re, im\right)\right)} \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
  4. Using strategy rm
  5. Applied add-sqr-sqrt0.5

    \[\leadsto \frac{\log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\color{blue}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0} \cdot \sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}\]
  6. Applied associate-/r*0.4

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

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

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

Reproduce

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