Average Error: 31.4 → 0.5
Time: 7.5s
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{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)}\]
\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{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)}
double f(double re, double im, double base) {
        double r44091 = re;
        double r44092 = r44091 * r44091;
        double r44093 = im;
        double r44094 = r44093 * r44093;
        double r44095 = r44092 + r44094;
        double r44096 = sqrt(r44095);
        double r44097 = log(r44096);
        double r44098 = base;
        double r44099 = log(r44098);
        double r44100 = r44097 * r44099;
        double r44101 = atan2(r44093, r44091);
        double r44102 = 0.0;
        double r44103 = r44101 * r44102;
        double r44104 = r44100 + r44103;
        double r44105 = r44099 * r44099;
        double r44106 = r44102 * r44102;
        double r44107 = r44105 + r44106;
        double r44108 = r44104 / r44107;
        return r44108;
}

double f(double re, double im, double base) {
        double r44109 = 1.0;
        double r44110 = base;
        double r44111 = log(r44110);
        double r44112 = 0.0;
        double r44113 = hypot(r44111, r44112);
        double r44114 = r44109 / r44113;
        double r44115 = re;
        double r44116 = im;
        double r44117 = hypot(r44115, r44116);
        double r44118 = log(r44117);
        double r44119 = atan2(r44116, r44115);
        double r44120 = r44119 * r44112;
        double r44121 = fma(r44118, r44111, r44120);
        double r44122 = r44121 / r44113;
        double r44123 = r44114 * r44122;
        return r44123;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 31.4

    \[\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. Using strategy rm
  9. Applied *-un-lft-identity0.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{\color{blue}{1 \cdot \left(\log base \cdot \log base + 0.0 \cdot 0.0\right)}}}\]
  10. Applied sqrt-prod0.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}}{\color{blue}{\sqrt{1} \cdot \sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}\]
  11. Applied *-un-lft-identity0.4

    \[\leadsto \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)}}{\mathsf{hypot}\left(\log base, 0.0\right) \cdot 1}}{\sqrt{1} \cdot \sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\]
  12. Applied times-frac0.5

    \[\leadsto \frac{\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)}{1}}}{\sqrt{1} \cdot \sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\]
  13. Applied times-frac0.5

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

    \[\leadsto \color{blue}{\frac{1}{\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)}{1}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\]
  15. 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)}}\]
  16. Final simplification0.5

    \[\leadsto \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)}\]

Reproduce

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