Average Error: 32.0 → 0.4
Time: 17.7s
Precision: 64
\[\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
\[\frac{1}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}} \cdot \frac{\log base \cdot \tan^{-1}_* \frac{im}{re} - 0.0 \cdot \log \left(\mathsf{hypot}\left(im, re\right)\right)}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}\]
\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}
\frac{1}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}} \cdot \frac{\log base \cdot \tan^{-1}_* \frac{im}{re} - 0.0 \cdot \log \left(\mathsf{hypot}\left(im, re\right)\right)}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}
double f(double re, double im, double base) {
        double r2391427 = im;
        double r2391428 = re;
        double r2391429 = atan2(r2391427, r2391428);
        double r2391430 = base;
        double r2391431 = log(r2391430);
        double r2391432 = r2391429 * r2391431;
        double r2391433 = r2391428 * r2391428;
        double r2391434 = r2391427 * r2391427;
        double r2391435 = r2391433 + r2391434;
        double r2391436 = sqrt(r2391435);
        double r2391437 = log(r2391436);
        double r2391438 = 0.0;
        double r2391439 = r2391437 * r2391438;
        double r2391440 = r2391432 - r2391439;
        double r2391441 = r2391431 * r2391431;
        double r2391442 = r2391438 * r2391438;
        double r2391443 = r2391441 + r2391442;
        double r2391444 = r2391440 / r2391443;
        return r2391444;
}

double f(double re, double im, double base) {
        double r2391445 = 1.0;
        double r2391446 = base;
        double r2391447 = log(r2391446);
        double r2391448 = 0.0;
        double r2391449 = r2391448 * r2391448;
        double r2391450 = fma(r2391447, r2391447, r2391449);
        double r2391451 = sqrt(r2391450);
        double r2391452 = r2391445 / r2391451;
        double r2391453 = im;
        double r2391454 = re;
        double r2391455 = atan2(r2391453, r2391454);
        double r2391456 = r2391447 * r2391455;
        double r2391457 = hypot(r2391453, r2391454);
        double r2391458 = log(r2391457);
        double r2391459 = r2391448 * r2391458;
        double r2391460 = r2391456 - r2391459;
        double r2391461 = r2391460 / r2391451;
        double r2391462 = r2391452 * r2391461;
        return r2391462;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 32.0

    \[\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
  2. Simplified0.4

    \[\leadsto \color{blue}{\frac{\log base \cdot \tan^{-1}_* \frac{im}{re} - \log \left(\mathsf{hypot}\left(im, re\right)\right) \cdot 0.0}{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt0.4

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

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

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

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

Reproduce

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