Average Error: 32.0 → 0.5
Time: 22.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}\]
\[\mathsf{fma}\left(\tan^{-1}_* \frac{im}{re}, 0.0, \log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \log base\right) \cdot \frac{1}{\mathsf{fma}\left(0.0, 0.0, {\left(\log base\right)}^{2}\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}
\mathsf{fma}\left(\tan^{-1}_* \frac{im}{re}, 0.0, \log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \log base\right) \cdot \frac{1}{\mathsf{fma}\left(0.0, 0.0, {\left(\log base\right)}^{2}\right)}
double f(double re, double im, double base) {
        double r113176 = re;
        double r113177 = r113176 * r113176;
        double r113178 = im;
        double r113179 = r113178 * r113178;
        double r113180 = r113177 + r113179;
        double r113181 = sqrt(r113180);
        double r113182 = log(r113181);
        double r113183 = base;
        double r113184 = log(r113183);
        double r113185 = r113182 * r113184;
        double r113186 = atan2(r113178, r113176);
        double r113187 = 0.0;
        double r113188 = r113186 * r113187;
        double r113189 = r113185 + r113188;
        double r113190 = r113184 * r113184;
        double r113191 = r113187 * r113187;
        double r113192 = r113190 + r113191;
        double r113193 = r113189 / r113192;
        return r113193;
}

double f(double re, double im, double base) {
        double r113194 = im;
        double r113195 = re;
        double r113196 = atan2(r113194, r113195);
        double r113197 = 0.0;
        double r113198 = hypot(r113195, r113194);
        double r113199 = log(r113198);
        double r113200 = base;
        double r113201 = log(r113200);
        double r113202 = r113199 * r113201;
        double r113203 = fma(r113196, r113197, r113202);
        double r113204 = 1.0;
        double r113205 = 2.0;
        double r113206 = pow(r113201, r113205);
        double r113207 = fma(r113197, r113197, r113206);
        double r113208 = r113204 / r113207;
        double r113209 = r113203 * r113208;
        return r113209;
}

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 associate-/r*0.4

    \[\leadsto \color{blue}{\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)}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}}\]
  6. 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)}}}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}\]
  7. Using strategy rm
  8. Applied *-un-lft-identity0.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)}}{\sqrt{\color{blue}{1 \cdot \mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}}\]
  9. Applied sqrt-prod0.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)}}{\color{blue}{\sqrt{1} \cdot \sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}}\]
  10. Applied div-inv0.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) \cdot \frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)}}}{\sqrt{1} \cdot \sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}\]
  11. Applied times-frac0.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)}{\sqrt{1}} \cdot \frac{\frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)}}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}}\]
  12. Simplified0.5

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

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

    \[\leadsto \mathsf{fma}\left(\tan^{-1}_* \frac{im}{re}, 0.0, \log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \log base\right) \cdot \frac{1}{\mathsf{fma}\left(0.0, 0.0, {\left(\log base\right)}^{2}\right)}\]

Reproduce

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