Average Error: 32.3 → 0.4
Time: 7.6s
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 r43830 = re;
        double r43831 = r43830 * r43830;
        double r43832 = im;
        double r43833 = r43832 * r43832;
        double r43834 = r43831 + r43833;
        double r43835 = sqrt(r43834);
        double r43836 = log(r43835);
        double r43837 = base;
        double r43838 = log(r43837);
        double r43839 = r43836 * r43838;
        double r43840 = atan2(r43832, r43830);
        double r43841 = 0.0;
        double r43842 = r43840 * r43841;
        double r43843 = r43839 + r43842;
        double r43844 = r43838 * r43838;
        double r43845 = r43841 * r43841;
        double r43846 = r43844 + r43845;
        double r43847 = r43843 / r43846;
        return r43847;
}

double f(double re, double im, double base) {
        double r43848 = re;
        double r43849 = im;
        double r43850 = hypot(r43848, r43849);
        double r43851 = log(r43850);
        double r43852 = base;
        double r43853 = log(r43852);
        double r43854 = atan2(r43849, r43848);
        double r43855 = 0.0;
        double r43856 = r43854 * r43855;
        double r43857 = fma(r43851, r43853, r43856);
        double r43858 = hypot(r43853, r43855);
        double r43859 = 1.0;
        double r43860 = r43858 * r43859;
        double r43861 = r43857 / r43860;
        double r43862 = r43853 * r43853;
        double r43863 = r43855 * r43855;
        double r43864 = r43862 + r43863;
        double r43865 = sqrt(r43864);
        double r43866 = r43861 / r43865;
        return r43866;
}

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 2020027 +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))))