Average Error: 32.0 → 0.7
Time: 15.3s
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)}}{\sqrt{\mathsf{hypot}\left(\log base, 0.0\right)}} \cdot \frac{1}{\sqrt{\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{\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)}}{\sqrt{\mathsf{hypot}\left(\log base, 0.0\right)}} \cdot \frac{1}{\sqrt{\mathsf{hypot}\left(\log base, 0.0\right)}}
double f(double re, double im, double base) {
        double r67837 = re;
        double r67838 = r67837 * r67837;
        double r67839 = im;
        double r67840 = r67839 * r67839;
        double r67841 = r67838 + r67840;
        double r67842 = sqrt(r67841);
        double r67843 = log(r67842);
        double r67844 = base;
        double r67845 = log(r67844);
        double r67846 = r67843 * r67845;
        double r67847 = atan2(r67839, r67837);
        double r67848 = 0.0;
        double r67849 = r67847 * r67848;
        double r67850 = r67846 + r67849;
        double r67851 = r67845 * r67845;
        double r67852 = r67848 * r67848;
        double r67853 = r67851 + r67852;
        double r67854 = r67850 / r67853;
        return r67854;
}

double f(double re, double im, double base) {
        double r67855 = re;
        double r67856 = im;
        double r67857 = hypot(r67855, r67856);
        double r67858 = log(r67857);
        double r67859 = base;
        double r67860 = log(r67859);
        double r67861 = atan2(r67856, r67855);
        double r67862 = 0.0;
        double r67863 = r67861 * r67862;
        double r67864 = fma(r67858, r67860, r67863);
        double r67865 = hypot(r67860, r67862);
        double r67866 = r67864 / r67865;
        double r67867 = sqrt(r67865);
        double r67868 = r67866 / r67867;
        double r67869 = 1.0;
        double r67870 = r67869 / r67867;
        double r67871 = r67868 * r67870;
        return r67871;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 32.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}\]
  2. Simplified0.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{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt0.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)}{\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.5

    \[\leadsto \frac{\color{blue}{1 \cdot \mathsf{fma}\left(\log \left(\mathsf{hypot}\left(re, im\right)\right), \log base, \tan^{-1}_* \frac{im}{re} \cdot 0.0\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.5

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

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

    \[\leadsto \frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)} \cdot \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)}}\]
  9. Using strategy rm
  10. Applied frac-2neg0.5

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

    \[\leadsto \frac{\color{blue}{-1}}{-\mathsf{hypot}\left(\log base, 0.0\right)} \cdot \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)}\]
  12. Using strategy rm
  13. Applied add-log-exp0.7

    \[\leadsto \color{blue}{\log \left(e^{\frac{-1}{-\mathsf{hypot}\left(\log base, 0.0\right)} \cdot \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)}}\right)}\]
  14. Simplified0.7

    \[\leadsto \log \color{blue}{\left(e^{\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)}}{\mathsf{hypot}\left(\log base, 0.0\right)}}\right)}\]
  15. Using strategy rm
  16. Applied add-sqr-sqrt0.9

    \[\leadsto \log \left(e^{\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)}}{\color{blue}{\sqrt{\mathsf{hypot}\left(\log base, 0.0\right)} \cdot \sqrt{\mathsf{hypot}\left(\log base, 0.0\right)}}}}\right)\]
  17. Applied neg-mul-10.9

    \[\leadsto \log \left(e^{\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)}{\color{blue}{-1 \cdot \mathsf{hypot}\left(\log base, 0.0\right)}}}{\sqrt{\mathsf{hypot}\left(\log base, 0.0\right)} \cdot \sqrt{\mathsf{hypot}\left(\log base, 0.0\right)}}}\right)\]
  18. Applied neg-mul-10.9

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

    \[\leadsto \log \left(e^{\frac{\color{blue}{\frac{-1}{-1} \cdot \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)}}}{\sqrt{\mathsf{hypot}\left(\log base, 0.0\right)} \cdot \sqrt{\mathsf{hypot}\left(\log base, 0.0\right)}}}\right)\]
  20. Applied times-frac0.9

    \[\leadsto \log \left(e^{\color{blue}{\frac{\frac{-1}{-1}}{\sqrt{\mathsf{hypot}\left(\log base, 0.0\right)}} \cdot \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)}}{\sqrt{\mathsf{hypot}\left(\log base, 0.0\right)}}}}\right)\]
  21. Applied exp-prod2.5

    \[\leadsto \log \color{blue}{\left({\left(e^{\frac{\frac{-1}{-1}}{\sqrt{\mathsf{hypot}\left(\log base, 0.0\right)}}}\right)}^{\left(\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)}}{\sqrt{\mathsf{hypot}\left(\log base, 0.0\right)}}\right)}\right)}\]
  22. Applied log-pow2.5

    \[\leadsto \color{blue}{\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)}}{\sqrt{\mathsf{hypot}\left(\log base, 0.0\right)}} \cdot \log \left(e^{\frac{\frac{-1}{-1}}{\sqrt{\mathsf{hypot}\left(\log base, 0.0\right)}}}\right)}\]
  23. Simplified0.7

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

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

Reproduce

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