Average Error: 32.3 → 0.5
Time: 46.0s
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{1}{\frac{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}{\mathsf{fma}\left(\log base, \log \left(\mathsf{hypot}\left(re, im\right)\right), \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}}}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}\]
\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{1}{\frac{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}{\mathsf{fma}\left(\log base, \log \left(\mathsf{hypot}\left(re, im\right)\right), \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}}}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}
double f(double re, double im, double base) {
        double r1474865 = re;
        double r1474866 = r1474865 * r1474865;
        double r1474867 = im;
        double r1474868 = r1474867 * r1474867;
        double r1474869 = r1474866 + r1474868;
        double r1474870 = sqrt(r1474869);
        double r1474871 = log(r1474870);
        double r1474872 = base;
        double r1474873 = log(r1474872);
        double r1474874 = r1474871 * r1474873;
        double r1474875 = atan2(r1474867, r1474865);
        double r1474876 = 0.0;
        double r1474877 = r1474875 * r1474876;
        double r1474878 = r1474874 + r1474877;
        double r1474879 = r1474873 * r1474873;
        double r1474880 = r1474876 * r1474876;
        double r1474881 = r1474879 + r1474880;
        double r1474882 = r1474878 / r1474881;
        return r1474882;
}

double f(double re, double im, double base) {
        double r1474883 = 1.0;
        double r1474884 = 0.0;
        double r1474885 = base;
        double r1474886 = log(r1474885);
        double r1474887 = r1474886 * r1474886;
        double r1474888 = fma(r1474884, r1474884, r1474887);
        double r1474889 = sqrt(r1474888);
        double r1474890 = re;
        double r1474891 = im;
        double r1474892 = hypot(r1474890, r1474891);
        double r1474893 = log(r1474892);
        double r1474894 = atan2(r1474891, r1474890);
        double r1474895 = r1474894 * r1474884;
        double r1474896 = fma(r1474886, r1474893, r1474895);
        double r1474897 = r1474889 / r1474896;
        double r1474898 = r1474883 / r1474897;
        double r1474899 = r1474898 / r1474889;
        return r1474899;
}

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. Simplified0.5

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

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

    \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(\log base, \log \left(\mathsf{hypot}\left(re, im\right)\right), \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}}\]
  6. Using strategy rm
  7. Applied clear-num0.5

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

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

Reproduce

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