Average Error: 31.7 → 0.5
Time: 10.9s
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}\]
\[\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(re, im\right)\right), \log base, \tan^{-1}_* \frac{im}{re} \cdot 0.0\right) \cdot \frac{1}{\mathsf{fma}\left(0.0, 0.0, {\left(\log base\right)}^{2}\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}
\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(re, im\right)\right), \log base, \tan^{-1}_* \frac{im}{re} \cdot 0.0\right) \cdot \frac{1}{\mathsf{fma}\left(0.0, 0.0, {\left(\log base\right)}^{2}\right)}
double f(double re, double im, double base) {
        double r49648 = re;
        double r49649 = r49648 * r49648;
        double r49650 = im;
        double r49651 = r49650 * r49650;
        double r49652 = r49649 + r49651;
        double r49653 = sqrt(r49652);
        double r49654 = log(r49653);
        double r49655 = base;
        double r49656 = log(r49655);
        double r49657 = r49654 * r49656;
        double r49658 = atan2(r49650, r49648);
        double r49659 = 0.0;
        double r49660 = r49658 * r49659;
        double r49661 = r49657 + r49660;
        double r49662 = r49656 * r49656;
        double r49663 = r49659 * r49659;
        double r49664 = r49662 + r49663;
        double r49665 = r49661 / r49664;
        return r49665;
}

double f(double re, double im, double base) {
        double r49666 = re;
        double r49667 = im;
        double r49668 = hypot(r49666, r49667);
        double r49669 = log(r49668);
        double r49670 = base;
        double r49671 = log(r49670);
        double r49672 = atan2(r49667, r49666);
        double r49673 = 0.0;
        double r49674 = r49672 * r49673;
        double r49675 = fma(r49669, r49671, r49674);
        double r49676 = 1.0;
        double r49677 = 2.0;
        double r49678 = pow(r49671, r49677);
        double r49679 = fma(r49673, r49673, r49678);
        double r49680 = r49676 / r49679;
        double r49681 = r49675 * r49680;
        return r49681;
}

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 \left(\mathsf{hypot}\left(re, im\right)\right), \log base, \tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}\]
  3. Using strategy rm
  4. Applied div-inv0.5

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

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

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

Reproduce

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