Average Error: 32.1 → 0.5
Time: 23.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{1}{\frac{\mathsf{hypot}\left(\log base, 0.0\right)}{\frac{\mathsf{fma}\left(\tan^{-1}_* \frac{im}{re}, 0.0, \log base \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)\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}{\frac{\mathsf{hypot}\left(\log base, 0.0\right)}{\frac{\mathsf{fma}\left(\tan^{-1}_* \frac{im}{re}, 0.0, \log base \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)\right)}{\mathsf{hypot}\left(\log base, 0.0\right)}}}
double f(double re, double im, double base) {
        double r1682263 = re;
        double r1682264 = r1682263 * r1682263;
        double r1682265 = im;
        double r1682266 = r1682265 * r1682265;
        double r1682267 = r1682264 + r1682266;
        double r1682268 = sqrt(r1682267);
        double r1682269 = log(r1682268);
        double r1682270 = base;
        double r1682271 = log(r1682270);
        double r1682272 = r1682269 * r1682271;
        double r1682273 = atan2(r1682265, r1682263);
        double r1682274 = 0.0;
        double r1682275 = r1682273 * r1682274;
        double r1682276 = r1682272 + r1682275;
        double r1682277 = r1682271 * r1682271;
        double r1682278 = r1682274 * r1682274;
        double r1682279 = r1682277 + r1682278;
        double r1682280 = r1682276 / r1682279;
        return r1682280;
}

double f(double re, double im, double base) {
        double r1682281 = 1.0;
        double r1682282 = base;
        double r1682283 = log(r1682282);
        double r1682284 = 0.0;
        double r1682285 = hypot(r1682283, r1682284);
        double r1682286 = im;
        double r1682287 = re;
        double r1682288 = atan2(r1682286, r1682287);
        double r1682289 = hypot(r1682287, r1682286);
        double r1682290 = log(r1682289);
        double r1682291 = r1682283 * r1682290;
        double r1682292 = fma(r1682288, r1682284, r1682291);
        double r1682293 = r1682292 / r1682285;
        double r1682294 = r1682285 / r1682293;
        double r1682295 = r1682281 / r1682294;
        return r1682295;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 32.1

    \[\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 base, \log \left(\mathsf{hypot}\left(re, im\right)\right), \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt0.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)}{\color{blue}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)} \cdot \sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}}\]
  5. Applied associate-/r*0.4

    \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(\log base, \log \left(\mathsf{hypot}\left(re, im\right)\right), \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}}\]
  6. Using strategy rm
  7. Applied clear-num0.5

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

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

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

Reproduce

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