Average Error: 31.7 → 0.5
Time: 23.4s
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{\mathsf{fma}\left(\log base, \log \left(\mathsf{hypot}\left(re, im\right)\right), 0.0 \cdot \tan^{-1}_* \frac{im}{re}\right)}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}} \cdot \frac{1}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\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{\mathsf{fma}\left(\log base, \log \left(\mathsf{hypot}\left(re, im\right)\right), 0.0 \cdot \tan^{-1}_* \frac{im}{re}\right)}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}} \cdot \frac{1}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}
double f(double re, double im, double base) {
        double r1786414 = re;
        double r1786415 = r1786414 * r1786414;
        double r1786416 = im;
        double r1786417 = r1786416 * r1786416;
        double r1786418 = r1786415 + r1786417;
        double r1786419 = sqrt(r1786418);
        double r1786420 = log(r1786419);
        double r1786421 = base;
        double r1786422 = log(r1786421);
        double r1786423 = r1786420 * r1786422;
        double r1786424 = atan2(r1786416, r1786414);
        double r1786425 = 0.0;
        double r1786426 = r1786424 * r1786425;
        double r1786427 = r1786423 + r1786426;
        double r1786428 = r1786422 * r1786422;
        double r1786429 = r1786425 * r1786425;
        double r1786430 = r1786428 + r1786429;
        double r1786431 = r1786427 / r1786430;
        return r1786431;
}

double f(double re, double im, double base) {
        double r1786432 = base;
        double r1786433 = log(r1786432);
        double r1786434 = re;
        double r1786435 = im;
        double r1786436 = hypot(r1786434, r1786435);
        double r1786437 = log(r1786436);
        double r1786438 = 0.0;
        double r1786439 = atan2(r1786435, r1786434);
        double r1786440 = r1786438 * r1786439;
        double r1786441 = fma(r1786433, r1786437, r1786440);
        double r1786442 = r1786433 * r1786433;
        double r1786443 = fma(r1786438, r1786438, r1786442);
        double r1786444 = sqrt(r1786443);
        double r1786445 = r1786441 / r1786444;
        double r1786446 = 1.0;
        double r1786447 = r1786446 / r1786444;
        double r1786448 = r1786445 * r1786447;
        return r1786448;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 31.7

    \[\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 *-un-lft-identity0.5

    \[\leadsto \frac{\color{blue}{1 \cdot \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)} \cdot \sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}\]
  6. Applied times-frac0.5

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

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

Reproduce

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