Average Error: 32.3 → 0.5
Time: 7.8s
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)}{1}} \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)}{\mathsf{hypot}\left(\log base, 0.0\right) \cdot 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}
\frac{1}{\frac{\mathsf{hypot}\left(\log base, 0.0\right)}{1}} \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)}{\mathsf{hypot}\left(\log base, 0.0\right) \cdot 1}
double f(double re, double im, double base) {
        double r45513 = re;
        double r45514 = r45513 * r45513;
        double r45515 = im;
        double r45516 = r45515 * r45515;
        double r45517 = r45514 + r45516;
        double r45518 = sqrt(r45517);
        double r45519 = log(r45518);
        double r45520 = base;
        double r45521 = log(r45520);
        double r45522 = r45519 * r45521;
        double r45523 = atan2(r45515, r45513);
        double r45524 = 0.0;
        double r45525 = r45523 * r45524;
        double r45526 = r45522 + r45525;
        double r45527 = r45521 * r45521;
        double r45528 = r45524 * r45524;
        double r45529 = r45527 + r45528;
        double r45530 = r45526 / r45529;
        return r45530;
}

double f(double re, double im, double base) {
        double r45531 = 1.0;
        double r45532 = base;
        double r45533 = log(r45532);
        double r45534 = 0.0;
        double r45535 = hypot(r45533, r45534);
        double r45536 = r45535 / r45531;
        double r45537 = r45531 / r45536;
        double r45538 = re;
        double r45539 = im;
        double r45540 = hypot(r45538, r45539);
        double r45541 = log(r45540);
        double r45542 = atan2(r45539, r45538);
        double r45543 = r45542 * r45534;
        double r45544 = fma(r45533, r45541, r45543);
        double r45545 = r45535 * r45531;
        double r45546 = r45544 / r45545;
        double r45547 = r45537 * r45546;
        return r45547;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 32.3

    \[\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-log32.3

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

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

    \[\leadsto \color{blue}{\frac{1}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}} \cdot \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}}}\]
  9. Simplified0.5

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

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

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

Reproduce

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