Average Error: 32.1 → 0.5
Time: 22.8s
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)}{\frac{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(re, im\right)\right), \log base, 0.0 \cdot \tan^{-1}_* \frac{im}{re}\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{1}{\frac{\mathsf{hypot}\left(\log base, 0.0\right)}{\frac{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(re, im\right)\right), \log base, 0.0 \cdot \tan^{-1}_* \frac{im}{re}\right)}{\mathsf{hypot}\left(\log base, 0.0\right)}}}
double f(double re, double im, double base) {
        double r69385 = re;
        double r69386 = r69385 * r69385;
        double r69387 = im;
        double r69388 = r69387 * r69387;
        double r69389 = r69386 + r69388;
        double r69390 = sqrt(r69389);
        double r69391 = log(r69390);
        double r69392 = base;
        double r69393 = log(r69392);
        double r69394 = r69391 * r69393;
        double r69395 = atan2(r69387, r69385);
        double r69396 = 0.0;
        double r69397 = r69395 * r69396;
        double r69398 = r69394 + r69397;
        double r69399 = r69393 * r69393;
        double r69400 = r69396 * r69396;
        double r69401 = r69399 + r69400;
        double r69402 = r69398 / r69401;
        return r69402;
}

double f(double re, double im, double base) {
        double r69403 = 1.0;
        double r69404 = base;
        double r69405 = log(r69404);
        double r69406 = 0.0;
        double r69407 = hypot(r69405, r69406);
        double r69408 = re;
        double r69409 = im;
        double r69410 = hypot(r69408, r69409);
        double r69411 = log(r69410);
        double r69412 = atan2(r69409, r69408);
        double r69413 = r69406 * r69412;
        double r69414 = fma(r69411, r69405, r69413);
        double r69415 = r69414 / r69407;
        double r69416 = r69407 / r69415;
        double r69417 = r69403 / r69416;
        return r69417;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 32.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}\]
  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. Simplified0.4

    \[\leadsto \frac{\color{blue}{\frac{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(re, im\right)\right), \log base, 0.0 \cdot \tan^{-1}_* \frac{im}{re}\right)}{\mathsf{hypot}\left(\log base, 0.0\right)}}}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\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, 0.0 \cdot \tan^{-1}_* \frac{im}{re}\right)}{\color{blue}{1 \cdot \mathsf{hypot}\left(\log base, 0.0\right)}}}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}\]
  9. Applied *-un-lft-identity0.4

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

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

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

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

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

Reproduce

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