Average Error: 31.5 → 0.5
Time: 9.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}{\frac{\mathsf{fma}\left(0.0, 0.0, {\left(\log base\right)}^{2}\right)}{\mathsf{fma}\left(\log base, \log \left(\mathsf{hypot}\left(re, im\right)\right), \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{1}{\frac{\mathsf{fma}\left(0.0, 0.0, {\left(\log base\right)}^{2}\right)}{\mathsf{fma}\left(\log base, \log \left(\mathsf{hypot}\left(re, im\right)\right), \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}}
double f(double re, double im, double base) {
        double r44467 = re;
        double r44468 = r44467 * r44467;
        double r44469 = im;
        double r44470 = r44469 * r44469;
        double r44471 = r44468 + r44470;
        double r44472 = sqrt(r44471);
        double r44473 = log(r44472);
        double r44474 = base;
        double r44475 = log(r44474);
        double r44476 = r44473 * r44475;
        double r44477 = atan2(r44469, r44467);
        double r44478 = 0.0;
        double r44479 = r44477 * r44478;
        double r44480 = r44476 + r44479;
        double r44481 = r44475 * r44475;
        double r44482 = r44478 * r44478;
        double r44483 = r44481 + r44482;
        double r44484 = r44480 / r44483;
        return r44484;
}

double f(double re, double im, double base) {
        double r44485 = 1.0;
        double r44486 = 0.0;
        double r44487 = base;
        double r44488 = log(r44487);
        double r44489 = 2.0;
        double r44490 = pow(r44488, r44489);
        double r44491 = fma(r44486, r44486, r44490);
        double r44492 = re;
        double r44493 = im;
        double r44494 = hypot(r44492, r44493);
        double r44495 = log(r44494);
        double r44496 = atan2(r44493, r44492);
        double r44497 = r44496 * r44486;
        double r44498 = fma(r44488, r44495, r44497);
        double r44499 = r44491 / r44498;
        double r44500 = r44485 / r44499;
        return r44500;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 31.5

    \[\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 add-exp-log31.5

    \[\leadsto \frac{\log \color{blue}{\left(e^{\log \left(\sqrt{re \cdot re + im \cdot 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. Simplified0.5

    \[\leadsto \frac{\log \left(e^{\color{blue}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
  5. Using strategy rm
  6. Applied add-sqr-sqrt0.5

    \[\leadsto \frac{\log \left(e^{\log \left(\mathsf{hypot}\left(re, im\right)\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}}}\]
  7. Applied associate-/r*0.4

    \[\leadsto \color{blue}{\frac{\frac{\log \left(e^{\log \left(\mathsf{hypot}\left(re, im\right)\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}}}\]
  8. Simplified0.4

    \[\leadsto \frac{\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{hypot}\left(\log base, 0.0\right) \cdot 1}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\]
  9. Using strategy rm
  10. Applied clear-num0.5

    \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{\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), \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}{\mathsf{hypot}\left(\log base, 0.0\right) \cdot 1}}}}\]
  11. Simplified0.5

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

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

Reproduce

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