Average Error: 32.0 → 0.4
Time: 17.6s
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{\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)}}{\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{\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)}}{\mathsf{hypot}\left(\log base, 0.0\right)}
double f(double re, double im, double base) {
        double r64178 = re;
        double r64179 = r64178 * r64178;
        double r64180 = im;
        double r64181 = r64180 * r64180;
        double r64182 = r64179 + r64181;
        double r64183 = sqrt(r64182);
        double r64184 = log(r64183);
        double r64185 = base;
        double r64186 = log(r64185);
        double r64187 = r64184 * r64186;
        double r64188 = atan2(r64180, r64178);
        double r64189 = 0.0;
        double r64190 = r64188 * r64189;
        double r64191 = r64187 + r64190;
        double r64192 = r64186 * r64186;
        double r64193 = r64189 * r64189;
        double r64194 = r64192 + r64193;
        double r64195 = r64191 / r64194;
        return r64195;
}

double f(double re, double im, double base) {
        double r64196 = re;
        double r64197 = im;
        double r64198 = hypot(r64196, r64197);
        double r64199 = log(r64198);
        double r64200 = base;
        double r64201 = log(r64200);
        double r64202 = atan2(r64197, r64196);
        double r64203 = 0.0;
        double r64204 = r64202 * r64203;
        double r64205 = fma(r64199, r64201, r64204);
        double r64206 = hypot(r64201, r64203);
        double r64207 = r64205 / r64206;
        double r64208 = r64207 / r64206;
        return r64208;
}

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. Simplified0.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{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt0.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}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)} \cdot \sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}}\]
  5. Applied *-un-lft-identity0.5

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

    \[\leadsto \color{blue}{\frac{1}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}} \cdot \frac{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(re, im\right)\right), \log base, \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}}\]
  7. Simplified0.5

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

    \[\leadsto \frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)} \cdot \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)}}\]
  9. Using strategy rm
  10. Applied clear-num0.5

    \[\leadsto \frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)} \cdot \color{blue}{\frac{1}{\frac{\mathsf{hypot}\left(\log base, 0.0\right)}{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(re, im\right)\right), \log base, \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}}}\]
  11. Using strategy rm
  12. Applied associate-*l/0.5

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

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

Reproduce

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