Average Error: 31.8 → 0.5
Time: 6.9s
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 \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) \cdot \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{\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) \cdot \mathsf{hypot}\left(\log base, 0.0\right)}
double f(double re, double im, double base) {
        double r40525 = re;
        double r40526 = r40525 * r40525;
        double r40527 = im;
        double r40528 = r40527 * r40527;
        double r40529 = r40526 + r40528;
        double r40530 = sqrt(r40529);
        double r40531 = log(r40530);
        double r40532 = base;
        double r40533 = log(r40532);
        double r40534 = r40531 * r40533;
        double r40535 = atan2(r40527, r40525);
        double r40536 = 0.0;
        double r40537 = r40535 * r40536;
        double r40538 = r40534 + r40537;
        double r40539 = r40533 * r40533;
        double r40540 = r40536 * r40536;
        double r40541 = r40539 + r40540;
        double r40542 = r40538 / r40541;
        return r40542;
}

double f(double re, double im, double base) {
        double r40543 = re;
        double r40544 = im;
        double r40545 = hypot(r40543, r40544);
        double r40546 = log(r40545);
        double r40547 = base;
        double r40548 = log(r40547);
        double r40549 = atan2(r40544, r40543);
        double r40550 = 0.0;
        double r40551 = r40549 * r40550;
        double r40552 = fma(r40546, r40548, r40551);
        double r40553 = hypot(r40548, r40550);
        double r40554 = r40553 * r40553;
        double r40555 = r40552 / r40554;
        return r40555;
}

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. Using strategy rm
  3. Applied hypot-def0.5

    \[\leadsto \frac{\log \color{blue}{\left(\mathsf{hypot}\left(re, 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. Using strategy rm
  5. Applied add-sqr-sqrt0.5

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

    \[\leadsto \color{blue}{\frac{\frac{\log \left(\mathsf{hypot}\left(re, im\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}}}\]
  7. 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) \cdot 1}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\]
  8. Using strategy rm
  9. Applied div-inv0.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{hypot}\left(\log base, 0.0\right) \cdot 1} \cdot \frac{1}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}\]
  10. Simplified0.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)}{\mathsf{hypot}\left(\log base, 0.0\right) \cdot 1} \cdot \color{blue}{\frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)}}\]
  11. Using strategy rm
  12. Applied frac-times0.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) \cdot 1}{\left(\mathsf{hypot}\left(\log base, 0.0\right) \cdot 1\right) \cdot \mathsf{hypot}\left(\log base, 0.0\right)}}\]
  13. Simplified0.5

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

Reproduce

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