Average Error: 32.4 → 0.4
Time: 14.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(\log base, 0.0\right)}}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\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(\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 r45302 = re;
        double r45303 = r45302 * r45302;
        double r45304 = im;
        double r45305 = r45304 * r45304;
        double r45306 = r45303 + r45305;
        double r45307 = sqrt(r45306);
        double r45308 = log(r45307);
        double r45309 = base;
        double r45310 = log(r45309);
        double r45311 = r45308 * r45310;
        double r45312 = atan2(r45304, r45302);
        double r45313 = 0.0;
        double r45314 = r45312 * r45313;
        double r45315 = r45311 + r45314;
        double r45316 = r45310 * r45310;
        double r45317 = r45313 * r45313;
        double r45318 = r45316 + r45317;
        double r45319 = r45315 / r45318;
        return r45319;
}

double f(double re, double im, double base) {
        double r45320 = re;
        double r45321 = im;
        double r45322 = hypot(r45320, r45321);
        double r45323 = log(r45322);
        double r45324 = base;
        double r45325 = log(r45324);
        double r45326 = atan2(r45321, r45320);
        double r45327 = 0.0;
        double r45328 = r45326 * r45327;
        double r45329 = fma(r45323, r45325, r45328);
        double r45330 = hypot(r45325, r45327);
        double r45331 = r45329 / r45330;
        double r45332 = r45327 * r45327;
        double r45333 = fma(r45325, r45325, r45332);
        double r45334 = sqrt(r45333);
        double r45335 = r45331 / r45334;
        return r45335;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 32.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. 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 add-sqr-sqrt0.5

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

Reproduce

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