Average Error: 31.7 → 0.5
Time: 22.0s
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 r1786416 = re;
        double r1786417 = r1786416 * r1786416;
        double r1786418 = im;
        double r1786419 = r1786418 * r1786418;
        double r1786420 = r1786417 + r1786419;
        double r1786421 = sqrt(r1786420);
        double r1786422 = log(r1786421);
        double r1786423 = base;
        double r1786424 = log(r1786423);
        double r1786425 = r1786422 * r1786424;
        double r1786426 = atan2(r1786418, r1786416);
        double r1786427 = 0.0;
        double r1786428 = r1786426 * r1786427;
        double r1786429 = r1786425 + r1786428;
        double r1786430 = r1786424 * r1786424;
        double r1786431 = r1786427 * r1786427;
        double r1786432 = r1786430 + r1786431;
        double r1786433 = r1786429 / r1786432;
        return r1786433;
}

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

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))))