Average Error: 31.8 → 0.4
Time: 20.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{\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - 0.0 \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)}{\mathsf{hypot}\left(\log base, 0.0\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{\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - 0.0 \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)}{\mathsf{hypot}\left(\log base, 0.0\right)}}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}
double f(double re, double im, double base) {
        double r90592 = im;
        double r90593 = re;
        double r90594 = atan2(r90592, r90593);
        double r90595 = base;
        double r90596 = log(r90595);
        double r90597 = r90594 * r90596;
        double r90598 = r90593 * r90593;
        double r90599 = r90592 * r90592;
        double r90600 = r90598 + r90599;
        double r90601 = sqrt(r90600);
        double r90602 = log(r90601);
        double r90603 = 0.0;
        double r90604 = r90602 * r90603;
        double r90605 = r90597 - r90604;
        double r90606 = r90596 * r90596;
        double r90607 = r90603 * r90603;
        double r90608 = r90606 + r90607;
        double r90609 = r90605 / r90608;
        return r90609;
}

double f(double re, double im, double base) {
        double r90610 = im;
        double r90611 = re;
        double r90612 = atan2(r90610, r90611);
        double r90613 = base;
        double r90614 = log(r90613);
        double r90615 = r90612 * r90614;
        double r90616 = 0.0;
        double r90617 = hypot(r90611, r90610);
        double r90618 = log(r90617);
        double r90619 = r90616 * r90618;
        double r90620 = r90615 - r90619;
        double r90621 = hypot(r90614, r90616);
        double r90622 = r90620 / r90621;
        double r90623 = r90616 * r90616;
        double r90624 = fma(r90614, r90614, r90623);
        double r90625 = sqrt(r90624);
        double r90626 = r90622 / r90625;
        return r90626;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 31.8

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

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

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

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

Reproduce

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