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 r48120 = re;
        double r48121 = r48120 * r48120;
        double r48122 = im;
        double r48123 = r48122 * r48122;
        double r48124 = r48121 + r48123;
        double r48125 = sqrt(r48124);
        double r48126 = log(r48125);
        double r48127 = base;
        double r48128 = log(r48127);
        double r48129 = r48126 * r48128;
        double r48130 = atan2(r48122, r48120);
        double r48131 = 0.0;
        double r48132 = r48130 * r48131;
        double r48133 = r48129 + r48132;
        double r48134 = r48128 * r48128;
        double r48135 = r48131 * r48131;
        double r48136 = r48134 + r48135;
        double r48137 = r48133 / r48136;
        return r48137;
}

double f(double re, double im, double base) {
        double r48138 = 1.0;
        double r48139 = base;
        double r48140 = log(r48139);
        double r48141 = 0.0;
        double r48142 = hypot(r48140, r48141);
        double r48143 = r48142 / r48138;
        double r48144 = r48138 / r48143;
        double r48145 = re;
        double r48146 = im;
        double r48147 = hypot(r48145, r48146);
        double r48148 = log(r48147);
        double r48149 = atan2(r48146, r48145);
        double r48150 = r48149 * r48141;
        double r48151 = fma(r48140, r48148, r48150);
        double r48152 = r48142 * r48138;
        double r48153 = r48151 / r48152;
        double r48154 = r48144 * r48153;
        return r48154;
}

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 2020065 +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))))