Average Error: 32.2 → 0.5
Time: 7.2s
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{\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} \cdot \frac{1}{\mathsf{hypot}\left(\log base, 0.0\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{\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} \cdot \frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)}
double f(double re, double im, double base) {
        double r41890 = re;
        double r41891 = r41890 * r41890;
        double r41892 = im;
        double r41893 = r41892 * r41892;
        double r41894 = r41891 + r41893;
        double r41895 = sqrt(r41894);
        double r41896 = log(r41895);
        double r41897 = base;
        double r41898 = log(r41897);
        double r41899 = r41896 * r41898;
        double r41900 = atan2(r41892, r41890);
        double r41901 = 0.0;
        double r41902 = r41900 * r41901;
        double r41903 = r41899 + r41902;
        double r41904 = r41898 * r41898;
        double r41905 = r41901 * r41901;
        double r41906 = r41904 + r41905;
        double r41907 = r41903 / r41906;
        return r41907;
}

double f(double re, double im, double base) {
        double r41908 = re;
        double r41909 = im;
        double r41910 = hypot(r41908, r41909);
        double r41911 = log(r41910);
        double r41912 = base;
        double r41913 = log(r41912);
        double r41914 = atan2(r41909, r41908);
        double r41915 = 0.0;
        double r41916 = r41914 * r41915;
        double r41917 = fma(r41911, r41913, r41916);
        double r41918 = hypot(r41913, r41915);
        double r41919 = 1.0;
        double r41920 = r41918 * r41919;
        double r41921 = r41917 / r41920;
        double r41922 = r41919 / r41918;
        double r41923 = r41921 * r41922;
        return r41923;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 32.2

    \[\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. Using strategy rm
  9. Applied div-inv0.5

    \[\leadsto \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} \cdot \frac{1}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}\]
  10. Simplified0.5

    \[\leadsto \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} \cdot \color{blue}{\frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)}}\]
  11. Final simplification0.5

    \[\leadsto \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} \cdot \frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)}\]

Reproduce

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