Average Error: 31.4 → 0.4
Time: 7.5s
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(\log base, 0.0\right) \cdot 1}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\]
\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(\log base, 0.0\right) \cdot 1}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}
double f(double re, double im, double base) {
        double r43236 = re;
        double r43237 = r43236 * r43236;
        double r43238 = im;
        double r43239 = r43238 * r43238;
        double r43240 = r43237 + r43239;
        double r43241 = sqrt(r43240);
        double r43242 = log(r43241);
        double r43243 = base;
        double r43244 = log(r43243);
        double r43245 = r43242 * r43244;
        double r43246 = atan2(r43238, r43236);
        double r43247 = 0.0;
        double r43248 = r43246 * r43247;
        double r43249 = r43245 + r43248;
        double r43250 = r43244 * r43244;
        double r43251 = r43247 * r43247;
        double r43252 = r43250 + r43251;
        double r43253 = r43249 / r43252;
        return r43253;
}

double f(double re, double im, double base) {
        double r43254 = re;
        double r43255 = im;
        double r43256 = hypot(r43254, r43255);
        double r43257 = log(r43256);
        double r43258 = base;
        double r43259 = log(r43258);
        double r43260 = atan2(r43255, r43254);
        double r43261 = 0.0;
        double r43262 = r43260 * r43261;
        double r43263 = fma(r43257, r43259, r43262);
        double r43264 = hypot(r43259, r43261);
        double r43265 = 1.0;
        double r43266 = r43264 * r43265;
        double r43267 = r43263 / r43266;
        double r43268 = r43259 * r43259;
        double r43269 = r43261 * r43261;
        double r43270 = r43268 + r43269;
        double r43271 = sqrt(r43270);
        double r43272 = r43267 / r43271;
        return r43272;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 31.4

    \[\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. Using strategy rm
  3. Applied hypot-def0.5

    \[\leadsto \frac{\log \color{blue}{\left(\mathsf{hypot}\left(re, im\right)\right)} \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
  4. Using strategy rm
  5. Applied add-sqr-sqrt0.5

    \[\leadsto \frac{\log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\color{blue}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0} \cdot \sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}\]
  6. Applied associate-/r*0.4

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

    \[\leadsto \frac{\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{hypot}\left(\log base, 0.0\right) \cdot 1}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\]
  8. 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(\log base, 0.0\right) \cdot 1}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\]

Reproduce

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