Average Error: 31.5 → 0.4
Time: 27.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}\]
\[\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 r2038077 = re;
        double r2038078 = r2038077 * r2038077;
        double r2038079 = im;
        double r2038080 = r2038079 * r2038079;
        double r2038081 = r2038078 + r2038080;
        double r2038082 = sqrt(r2038081);
        double r2038083 = log(r2038082);
        double r2038084 = base;
        double r2038085 = log(r2038084);
        double r2038086 = r2038083 * r2038085;
        double r2038087 = atan2(r2038079, r2038077);
        double r2038088 = 0.0;
        double r2038089 = r2038087 * r2038088;
        double r2038090 = r2038086 + r2038089;
        double r2038091 = r2038085 * r2038085;
        double r2038092 = r2038088 * r2038088;
        double r2038093 = r2038091 + r2038092;
        double r2038094 = r2038090 / r2038093;
        return r2038094;
}

double f(double re, double im, double base) {
        double r2038095 = re;
        double r2038096 = im;
        double r2038097 = hypot(r2038095, r2038096);
        double r2038098 = log(r2038097);
        double r2038099 = base;
        double r2038100 = log(r2038099);
        double r2038101 = r2038098 * r2038100;
        double r2038102 = atan2(r2038096, r2038095);
        double r2038103 = 0.0;
        double r2038104 = r2038102 * r2038103;
        double r2038105 = r2038101 + r2038104;
        double r2038106 = r2038100 * r2038100;
        double r2038107 = fma(r2038103, r2038103, r2038106);
        double r2038108 = sqrt(r2038107);
        double r2038109 = r2038105 / r2038108;
        double r2038110 = r2038109 / r2038108;
        return r2038110;
}

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