Average Error: 32.2 → 0.5
Time: 52.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}\]
\[\mathsf{fma}\left(\tan^{-1}_* \frac{im}{re}, 0.0, \log base \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)\right) \cdot \frac{\frac{1}{\log base}}{\log base}\]
\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 base \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)\right) \cdot \frac{\frac{1}{\log base}}{\log base}
double f(double re, double im, double base) {
        double r1750179 = re;
        double r1750180 = r1750179 * r1750179;
        double r1750181 = im;
        double r1750182 = r1750181 * r1750181;
        double r1750183 = r1750180 + r1750182;
        double r1750184 = sqrt(r1750183);
        double r1750185 = log(r1750184);
        double r1750186 = base;
        double r1750187 = log(r1750186);
        double r1750188 = r1750185 * r1750187;
        double r1750189 = atan2(r1750181, r1750179);
        double r1750190 = 0.0;
        double r1750191 = r1750189 * r1750190;
        double r1750192 = r1750188 + r1750191;
        double r1750193 = r1750187 * r1750187;
        double r1750194 = r1750190 * r1750190;
        double r1750195 = r1750193 + r1750194;
        double r1750196 = r1750192 / r1750195;
        return r1750196;
}

double f(double re, double im, double base) {
        double r1750197 = im;
        double r1750198 = re;
        double r1750199 = atan2(r1750197, r1750198);
        double r1750200 = 0.0;
        double r1750201 = base;
        double r1750202 = log(r1750201);
        double r1750203 = hypot(r1750198, r1750197);
        double r1750204 = log(r1750203);
        double r1750205 = r1750202 * r1750204;
        double r1750206 = fma(r1750199, r1750200, r1750205);
        double r1750207 = 1.0;
        double r1750208 = r1750207 / r1750202;
        double r1750209 = r1750208 / r1750202;
        double r1750210 = r1750206 * r1750209;
        return r1750210;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 32.2

    \[\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 base, \log \left(\mathsf{hypot}\left(re, im\right)\right), \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt0.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)}{\color{blue}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)} \cdot \sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}}\]
  5. Applied associate-/r*0.4

    \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(\log base, \log \left(\mathsf{hypot}\left(re, im\right)\right), \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}}\]
  6. Using strategy rm
  7. Applied *-un-lft-identity0.4

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

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

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\log base, \log \left(\mathsf{hypot}\left(re, im\right)\right), \tan^{-1}_* \frac{im}{re} \cdot 0.0\right) \cdot \frac{1}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}}}{\sqrt{1} \cdot \sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}\]
  10. Applied times-frac0.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)}{\sqrt{1}} \cdot \frac{\frac{1}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}}\]
  11. 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}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}\]
  12. 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{hypot}\left(\log base, 0.0\right) \cdot \mathsf{hypot}\left(\log base, 0.0\right)}}\]
  13. Taylor expanded around 0 0.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}{{\left(\log base\right)}^{2}}}\]
  14. 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{\frac{1}{\log base}}{\log base}}\]
  15. Final simplification0.5

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

Reproduce

herbie shell --seed 2019168 +o rules:numerics
(FPCore (re im base)
  :name "math.log/2 on complex, real part"
  (/ (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))