Average Error: 31.5 → 0.4
Time: 20.6s
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{\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(0.0, \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{\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(0.0, \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 r54492 = re;
        double r54493 = r54492 * r54492;
        double r54494 = im;
        double r54495 = r54494 * r54494;
        double r54496 = r54493 + r54495;
        double r54497 = sqrt(r54496);
        double r54498 = log(r54497);
        double r54499 = base;
        double r54500 = log(r54499);
        double r54501 = r54498 * r54500;
        double r54502 = atan2(r54494, r54492);
        double r54503 = 0.0;
        double r54504 = r54502 * r54503;
        double r54505 = r54501 + r54504;
        double r54506 = r54500 * r54500;
        double r54507 = r54503 * r54503;
        double r54508 = r54506 + r54507;
        double r54509 = r54505 / r54508;
        return r54509;
}

double f(double re, double im, double base) {
        double r54510 = re;
        double r54511 = im;
        double r54512 = hypot(r54510, r54511);
        double r54513 = log(r54512);
        double r54514 = base;
        double r54515 = log(r54514);
        double r54516 = atan2(r54511, r54510);
        double r54517 = 0.0;
        double r54518 = r54516 * r54517;
        double r54519 = fma(r54513, r54515, r54518);
        double r54520 = hypot(r54517, r54515);
        double r54521 = r54519 / r54520;
        double r54522 = r54515 * r54515;
        double r54523 = fma(r54517, r54517, r54522);
        double r54524 = sqrt(r54523);
        double r54525 = r54521 / r54524;
        return r54525;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 31.5

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

    \[\leadsto \frac{\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(0.0, \log base\right)}}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}\]

Reproduce

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