Average Error: 32.1 → 0.4
Time: 29.1s
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{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\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)}}\]
\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{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\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)}}
double f(double re, double im, double base) {
        double r2357503 = re;
        double r2357504 = r2357503 * r2357503;
        double r2357505 = im;
        double r2357506 = r2357505 * r2357505;
        double r2357507 = r2357504 + r2357506;
        double r2357508 = sqrt(r2357507);
        double r2357509 = log(r2357508);
        double r2357510 = base;
        double r2357511 = log(r2357510);
        double r2357512 = r2357509 * r2357511;
        double r2357513 = atan2(r2357505, r2357503);
        double r2357514 = 0.0;
        double r2357515 = r2357513 * r2357514;
        double r2357516 = r2357512 + r2357515;
        double r2357517 = r2357511 * r2357511;
        double r2357518 = r2357514 * r2357514;
        double r2357519 = r2357517 + r2357518;
        double r2357520 = r2357516 / r2357519;
        return r2357520;
}

double f(double re, double im, double base) {
        double r2357521 = re;
        double r2357522 = im;
        double r2357523 = hypot(r2357521, r2357522);
        double r2357524 = log(r2357523);
        double r2357525 = base;
        double r2357526 = log(r2357525);
        double r2357527 = r2357524 * r2357526;
        double r2357528 = atan2(r2357522, r2357521);
        double r2357529 = 0.0;
        double r2357530 = r2357528 * r2357529;
        double r2357531 = r2357527 + r2357530;
        double r2357532 = r2357526 * r2357526;
        double r2357533 = fma(r2357529, r2357529, r2357532);
        double r2357534 = sqrt(r2357533);
        double r2357535 = r2357531 / r2357534;
        double r2357536 = r2357535 / r2357534;
        return r2357536;
}

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. Using strategy rm
  7. Applied fma-udef0.4

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

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

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