Average Error: 31.6 → 0.5
Time: 25.8s
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 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 \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 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 \mathsf{hypot}\left(\log base, 0.0\right)}
double f(double re, double im, double base) {
        double r48778 = re;
        double r48779 = r48778 * r48778;
        double r48780 = im;
        double r48781 = r48780 * r48780;
        double r48782 = r48779 + r48781;
        double r48783 = sqrt(r48782);
        double r48784 = log(r48783);
        double r48785 = base;
        double r48786 = log(r48785);
        double r48787 = r48784 * r48786;
        double r48788 = atan2(r48780, r48778);
        double r48789 = 0.0;
        double r48790 = r48788 * r48789;
        double r48791 = r48787 + r48790;
        double r48792 = r48786 * r48786;
        double r48793 = r48789 * r48789;
        double r48794 = r48792 + r48793;
        double r48795 = r48791 / r48794;
        return r48795;
}

double f(double re, double im, double base) {
        double r48796 = base;
        double r48797 = log(r48796);
        double r48798 = re;
        double r48799 = im;
        double r48800 = hypot(r48798, r48799);
        double r48801 = log(r48800);
        double r48802 = atan2(r48799, r48798);
        double r48803 = 0.0;
        double r48804 = r48802 * r48803;
        double r48805 = fma(r48797, r48801, r48804);
        double r48806 = hypot(r48797, r48803);
        double r48807 = r48806 * r48806;
        double r48808 = r48805 / r48807;
        return r48808;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 31.6

    \[\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 associate-/r*0.4

    \[\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)}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}}\]
  6. 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)}}}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}\]
  7. Using strategy rm
  8. 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 \frac{1}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}}\]
  9. 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 \color{blue}{\frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)}}\]
  10. Using strategy rm
  11. Applied log1p-expm1-u0.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 \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)}\right)\right)}\]
  12. Using strategy rm
  13. Applied *-un-lft-identity0.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}{1 \cdot \mathsf{hypot}\left(\log base, 0.0\right)}} \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)}\right)\right)\]
  14. 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)}}{1 \cdot \mathsf{hypot}\left(\log base, 0.0\right)} \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)}\right)\right)\]
  15. Applied times-frac0.5

    \[\leadsto \color{blue}{\left(\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)}\right)} \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)}\right)\right)\]
  16. Applied associate-*l*0.5

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

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

Reproduce

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