Average Error: 31.8 → 0.6
Time: 27.4s
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{1}{\mathsf{hypot}\left(\log base, 0.0\right)}}{\mathsf{hypot}\left(\log base, 0.0\right)} \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(re, im\right)\right), \log base, \tan^{-1}_* \frac{im}{re} \cdot 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{1}{\mathsf{hypot}\left(\log base, 0.0\right)}}{\mathsf{hypot}\left(\log base, 0.0\right)} \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(re, im\right)\right), \log base, \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}}
double f(double re, double im, double base) {
        double r107992 = re;
        double r107993 = r107992 * r107992;
        double r107994 = im;
        double r107995 = r107994 * r107994;
        double r107996 = r107993 + r107995;
        double r107997 = sqrt(r107996);
        double r107998 = log(r107997);
        double r107999 = base;
        double r108000 = log(r107999);
        double r108001 = r107998 * r108000;
        double r108002 = atan2(r107994, r107992);
        double r108003 = 0.0;
        double r108004 = r108002 * r108003;
        double r108005 = r108001 + r108004;
        double r108006 = r108000 * r108000;
        double r108007 = r108003 * r108003;
        double r108008 = r108006 + r108007;
        double r108009 = r108005 / r108008;
        return r108009;
}

double f(double re, double im, double base) {
        double r108010 = 1.0;
        double r108011 = base;
        double r108012 = log(r108011);
        double r108013 = 0.0;
        double r108014 = hypot(r108012, r108013);
        double r108015 = r108010 / r108014;
        double r108016 = r108015 / r108014;
        double r108017 = re;
        double r108018 = im;
        double r108019 = hypot(r108017, r108018);
        double r108020 = log(r108019);
        double r108021 = atan2(r108018, r108017);
        double r108022 = r108021 * r108013;
        double r108023 = fma(r108020, r108012, r108022);
        double r108024 = r108010 / r108023;
        double r108025 = r108010 / r108024;
        double r108026 = r108016 * r108025;
        return r108026;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 31.8

    \[\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 clear-num0.5

    \[\leadsto \frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)} \cdot \color{blue}{\frac{1}{\frac{\mathsf{hypot}\left(\log base, 0.0\right)}{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(re, im\right)\right), \log base, \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}}}\]
  11. Using strategy rm
  12. Applied div-inv0.6

    \[\leadsto \frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)} \cdot \frac{1}{\color{blue}{\mathsf{hypot}\left(\log base, 0.0\right) \cdot \frac{1}{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(re, im\right)\right), \log base, \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}}}\]
  13. Applied add-cube-cbrt0.6

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

    \[\leadsto \frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)} \cdot \color{blue}{\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\mathsf{hypot}\left(\log base, 0.0\right)} \cdot \frac{\sqrt[3]{1}}{\frac{1}{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(re, im\right)\right), \log base, \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}}\right)}\]
  15. Applied associate-*r*0.7

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

    \[\leadsto \color{blue}{\frac{\frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)}}{\mathsf{hypot}\left(\log base, 0.0\right)}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(re, im\right)\right), \log base, \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}}\]
  17. Final simplification0.6

    \[\leadsto \frac{\frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)}}{\mathsf{hypot}\left(\log base, 0.0\right)} \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(re, im\right)\right), \log base, \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}}\]

Reproduce

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