Average Error: 31.8 → 0.5
Time: 21.7s
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}{\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)}}}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \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}{\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)}}}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}
double f(double re, double im, double base) {
        double r73077 = re;
        double r73078 = r73077 * r73077;
        double r73079 = im;
        double r73080 = r73079 * r73079;
        double r73081 = r73078 + r73080;
        double r73082 = sqrt(r73081);
        double r73083 = log(r73082);
        double r73084 = base;
        double r73085 = log(r73084);
        double r73086 = r73083 * r73085;
        double r73087 = atan2(r73079, r73077);
        double r73088 = 0.0;
        double r73089 = r73087 * r73088;
        double r73090 = r73086 + r73089;
        double r73091 = r73085 * r73085;
        double r73092 = r73088 * r73088;
        double r73093 = r73091 + r73092;
        double r73094 = r73090 / r73093;
        return r73094;
}

double f(double re, double im, double base) {
        double r73095 = 1.0;
        double r73096 = base;
        double r73097 = log(r73096);
        double r73098 = 0.0;
        double r73099 = hypot(r73097, r73098);
        double r73100 = re;
        double r73101 = im;
        double r73102 = hypot(r73100, r73101);
        double r73103 = log(r73102);
        double r73104 = atan2(r73101, r73100);
        double r73105 = r73104 * r73098;
        double r73106 = fma(r73103, r73097, r73105);
        double r73107 = r73099 / r73106;
        double r73108 = r73095 / r73107;
        double r73109 = r73098 * r73098;
        double r73110 = fma(r73097, r73097, r73109);
        double r73111 = sqrt(r73110);
        double r73112 = r73108 / r73111;
        return r73112;
}

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

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

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

Reproduce

herbie shell --seed 2019195 +o rules:numerics
(FPCore (re im base)
  :name "math.log/2 on complex, real part"
  (/ (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))