Average Error: 31.8 → 0.5
Time: 21.2s
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), 0.0 \cdot \tan^{-1}_* \frac{im}{re}\right)}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}} \cdot \frac{1}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\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), 0.0 \cdot \tan^{-1}_* \frac{im}{re}\right)}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}} \cdot \frac{1}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}
double f(double re, double im, double base) {
        double r1891533 = re;
        double r1891534 = r1891533 * r1891533;
        double r1891535 = im;
        double r1891536 = r1891535 * r1891535;
        double r1891537 = r1891534 + r1891536;
        double r1891538 = sqrt(r1891537);
        double r1891539 = log(r1891538);
        double r1891540 = base;
        double r1891541 = log(r1891540);
        double r1891542 = r1891539 * r1891541;
        double r1891543 = atan2(r1891535, r1891533);
        double r1891544 = 0.0;
        double r1891545 = r1891543 * r1891544;
        double r1891546 = r1891542 + r1891545;
        double r1891547 = r1891541 * r1891541;
        double r1891548 = r1891544 * r1891544;
        double r1891549 = r1891547 + r1891548;
        double r1891550 = r1891546 / r1891549;
        return r1891550;
}

double f(double re, double im, double base) {
        double r1891551 = base;
        double r1891552 = log(r1891551);
        double r1891553 = re;
        double r1891554 = im;
        double r1891555 = hypot(r1891553, r1891554);
        double r1891556 = log(r1891555);
        double r1891557 = 0.0;
        double r1891558 = atan2(r1891554, r1891553);
        double r1891559 = r1891557 * r1891558;
        double r1891560 = fma(r1891552, r1891556, r1891559);
        double r1891561 = r1891552 * r1891552;
        double r1891562 = fma(r1891557, r1891557, r1891561);
        double r1891563 = sqrt(r1891562);
        double r1891564 = r1891560 / r1891563;
        double r1891565 = 1.0;
        double r1891566 = r1891565 / r1891563;
        double r1891567 = r1891564 * r1891566;
        return r1891567;
}

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 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 *-un-lft-identity0.5

    \[\leadsto \frac{\color{blue}{1 \cdot \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)} \cdot \sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}\]
  6. Applied times-frac0.5

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

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

Reproduce

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