Average Error: 31.8 → 0.6
Time: 32.1s
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{1}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}} \cdot \left(\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}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}\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{1}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}} \cdot \left(\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}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}\right)
double f(double re, double im, double base) {
        double r5675037 = re;
        double r5675038 = r5675037 * r5675037;
        double r5675039 = im;
        double r5675040 = r5675039 * r5675039;
        double r5675041 = r5675038 + r5675040;
        double r5675042 = sqrt(r5675041);
        double r5675043 = log(r5675042);
        double r5675044 = base;
        double r5675045 = log(r5675044);
        double r5675046 = r5675043 * r5675045;
        double r5675047 = atan2(r5675039, r5675037);
        double r5675048 = 0.0;
        double r5675049 = r5675047 * r5675048;
        double r5675050 = r5675046 + r5675049;
        double r5675051 = r5675045 * r5675045;
        double r5675052 = r5675048 * r5675048;
        double r5675053 = r5675051 + r5675052;
        double r5675054 = r5675050 / r5675053;
        return r5675054;
}

double f(double re, double im, double base) {
        double r5675055 = 1.0;
        double r5675056 = base;
        double r5675057 = log(r5675056);
        double r5675058 = 0.0;
        double r5675059 = r5675058 * r5675058;
        double r5675060 = fma(r5675057, r5675057, r5675059);
        double r5675061 = sqrt(r5675060);
        double r5675062 = r5675055 / r5675061;
        double r5675063 = re;
        double r5675064 = im;
        double r5675065 = hypot(r5675063, r5675064);
        double r5675066 = log(r5675065);
        double r5675067 = atan2(r5675064, r5675063);
        double r5675068 = r5675067 * r5675058;
        double r5675069 = fma(r5675066, r5675057, r5675068);
        double r5675070 = r5675069 * r5675062;
        double r5675071 = r5675062 * r5675070;
        return r5675071;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 31.8

    \[\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 *-un-lft-identity0.5

    \[\leadsto \frac{\color{blue}{1 \cdot \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)} \cdot \sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}\]
  6. Applied times-frac0.5

    \[\leadsto \color{blue}{\frac{1}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}} \cdot \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)}}}\]
  7. Using strategy rm
  8. Applied div-inv0.6

    \[\leadsto \frac{1}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}} \cdot \color{blue}{\left(\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}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}\right)}\]
  9. Final simplification0.6

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

Reproduce

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