Average Error: 32.0 → 0.5
Time: 8.3s
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 r43619 = re;
        double r43620 = r43619 * r43619;
        double r43621 = im;
        double r43622 = r43621 * r43621;
        double r43623 = r43620 + r43622;
        double r43624 = sqrt(r43623);
        double r43625 = log(r43624);
        double r43626 = base;
        double r43627 = log(r43626);
        double r43628 = r43625 * r43627;
        double r43629 = atan2(r43621, r43619);
        double r43630 = 0.0;
        double r43631 = r43629 * r43630;
        double r43632 = r43628 + r43631;
        double r43633 = r43627 * r43627;
        double r43634 = r43630 * r43630;
        double r43635 = r43633 + r43634;
        double r43636 = r43632 / r43635;
        return r43636;
}

double f(double re, double im, double base) {
        double r43637 = 1.0;
        double r43638 = base;
        double r43639 = log(r43638);
        double r43640 = 0.0;
        double r43641 = hypot(r43639, r43640);
        double r43642 = r43641 / r43637;
        double r43643 = r43637 / r43642;
        double r43644 = re;
        double r43645 = im;
        double r43646 = hypot(r43644, r43645);
        double r43647 = log(r43646);
        double r43648 = atan2(r43645, r43644);
        double r43649 = r43648 * r43640;
        double r43650 = fma(r43639, r43647, r43649);
        double r43651 = r43641 * r43637;
        double r43652 = r43650 / r43651;
        double r43653 = r43643 * r43652;
        return r43653;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 32.0

    \[\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 *-un-lft-identity32.0

    \[\leadsto \frac{\log \left(\sqrt{\color{blue}{1 \cdot \left(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. Applied sqrt-prod32.0

    \[\leadsto \frac{\log \color{blue}{\left(\sqrt{1} \cdot \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}\]
  5. Simplified32.0

    \[\leadsto \frac{\log \left(\color{blue}{1} \cdot \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}\]
  6. Simplified0.5

    \[\leadsto \frac{\log \left(1 \cdot \color{blue}{\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}\]
  7. Using strategy rm
  8. Applied add-sqr-sqrt0.5

    \[\leadsto \frac{\log \left(1 \cdot \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}}}\]
  9. Applied *-un-lft-identity0.5

    \[\leadsto \frac{\color{blue}{1 \cdot \left(\log \left(1 \cdot \mathsf{hypot}\left(re, im\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}}\]
  10. Applied times-frac0.5

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

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