Average Error: 31.7 → 0.5
Time: 8.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), \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}{\mathsf{hypot}\left(\log base, 0.0\right) \cdot 1} \cdot \frac{1}{\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 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} \cdot \frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)}
double f(double re, double im, double base) {
        double r49687 = re;
        double r49688 = r49687 * r49687;
        double r49689 = im;
        double r49690 = r49689 * r49689;
        double r49691 = r49688 + r49690;
        double r49692 = sqrt(r49691);
        double r49693 = log(r49692);
        double r49694 = base;
        double r49695 = log(r49694);
        double r49696 = r49693 * r49695;
        double r49697 = atan2(r49689, r49687);
        double r49698 = 0.0;
        double r49699 = r49697 * r49698;
        double r49700 = r49696 + r49699;
        double r49701 = r49695 * r49695;
        double r49702 = r49698 * r49698;
        double r49703 = r49701 + r49702;
        double r49704 = r49700 / r49703;
        return r49704;
}

double f(double re, double im, double base) {
        double r49705 = base;
        double r49706 = log(r49705);
        double r49707 = re;
        double r49708 = im;
        double r49709 = hypot(r49707, r49708);
        double r49710 = log(r49709);
        double r49711 = atan2(r49708, r49707);
        double r49712 = 0.0;
        double r49713 = r49711 * r49712;
        double r49714 = fma(r49706, r49710, r49713);
        double r49715 = hypot(r49706, r49712);
        double r49716 = 1.0;
        double r49717 = r49715 * r49716;
        double r49718 = r49714 / r49717;
        double r49719 = r49716 / r49715;
        double r49720 = r49718 * r49719;
        return r49720;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 31.7

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

    \[\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 div-inv0.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{hypot}\left(\log base, 0.0\right) \cdot 1} \cdot \frac{1}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}\]
  11. Simplified0.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)}{\mathsf{hypot}\left(\log base, 0.0\right) \cdot 1} \cdot \color{blue}{\frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)}}\]
  12. Final simplification0.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)}{\mathsf{hypot}\left(\log base, 0.0\right) \cdot 1} \cdot \frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)}\]

Reproduce

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