Average Error: 31.9 → 0.4
Time: 8.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{\log \left(e^{\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{hypot}\left(\log base, 0.0\right)}}\right)}{\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{\log \left(e^{\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{hypot}\left(\log base, 0.0\right)}}\right)}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}
double f(double re, double im, double base) {
        double r50773 = re;
        double r50774 = r50773 * r50773;
        double r50775 = im;
        double r50776 = r50775 * r50775;
        double r50777 = r50774 + r50776;
        double r50778 = sqrt(r50777);
        double r50779 = log(r50778);
        double r50780 = base;
        double r50781 = log(r50780);
        double r50782 = r50779 * r50781;
        double r50783 = atan2(r50775, r50773);
        double r50784 = 0.0;
        double r50785 = r50783 * r50784;
        double r50786 = r50782 + r50785;
        double r50787 = r50781 * r50781;
        double r50788 = r50784 * r50784;
        double r50789 = r50787 + r50788;
        double r50790 = r50786 / r50789;
        return r50790;
}

double f(double re, double im, double base) {
        double r50791 = base;
        double r50792 = log(r50791);
        double r50793 = re;
        double r50794 = im;
        double r50795 = hypot(r50793, r50794);
        double r50796 = log(r50795);
        double r50797 = atan2(r50794, r50793);
        double r50798 = 0.0;
        double r50799 = r50797 * r50798;
        double r50800 = fma(r50792, r50796, r50799);
        double r50801 = hypot(r50792, r50798);
        double r50802 = r50800 / r50801;
        double r50803 = exp(r50802);
        double r50804 = log(r50803);
        double r50805 = r50792 * r50792;
        double r50806 = r50798 * r50798;
        double r50807 = r50805 + r50806;
        double r50808 = sqrt(r50807);
        double r50809 = r50804 / r50808;
        return r50809;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 31.9

    \[\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 *-un-lft-identity31.9

    \[\leadsto \frac{\log \left(\sqrt{\color{blue}{1 \cdot \left(re \cdot re + im \cdot 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. Applied sqrt-prod31.9

    \[\leadsto \frac{\log \color{blue}{\left(\sqrt{1} \cdot \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}\]
  5. Simplified31.9

    \[\leadsto \frac{\log \left(\color{blue}{1} \cdot \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}\]
  6. Simplified0.5

    \[\leadsto \frac{\log \left(1 \cdot \color{blue}{\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}\]
  7. Using strategy rm
  8. Applied add-sqr-sqrt0.5

    \[\leadsto \frac{\log \left(1 \cdot \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}}}\]
  9. Applied associate-/r*0.4

    \[\leadsto \color{blue}{\frac{\frac{\log \left(1 \cdot \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}}}\]
  10. Simplified0.4

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

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

    \[\leadsto \frac{\log \color{blue}{\left(e^{\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{hypot}\left(\log base, 0.0\right)}}\right)}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\]
  14. Final simplification0.4

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

Reproduce

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