Average Error: 32.8 → 0.4
Time: 38.8s
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(\tan^{-1}_* \frac{im}{re}, 0.0, \log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \log base\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)}}\]
\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(\tan^{-1}_* \frac{im}{re}, 0.0, \log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \log base\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)}}
double f(double re, double im, double base) {
        double r1559064 = re;
        double r1559065 = r1559064 * r1559064;
        double r1559066 = im;
        double r1559067 = r1559066 * r1559066;
        double r1559068 = r1559065 + r1559067;
        double r1559069 = sqrt(r1559068);
        double r1559070 = log(r1559069);
        double r1559071 = base;
        double r1559072 = log(r1559071);
        double r1559073 = r1559070 * r1559072;
        double r1559074 = atan2(r1559066, r1559064);
        double r1559075 = 0.0;
        double r1559076 = r1559074 * r1559075;
        double r1559077 = r1559073 + r1559076;
        double r1559078 = r1559072 * r1559072;
        double r1559079 = r1559075 * r1559075;
        double r1559080 = r1559078 + r1559079;
        double r1559081 = r1559077 / r1559080;
        return r1559081;
}

double f(double re, double im, double base) {
        double r1559082 = im;
        double r1559083 = re;
        double r1559084 = atan2(r1559082, r1559083);
        double r1559085 = 0.0;
        double r1559086 = hypot(r1559083, r1559082);
        double r1559087 = log(r1559086);
        double r1559088 = base;
        double r1559089 = log(r1559088);
        double r1559090 = r1559087 * r1559089;
        double r1559091 = fma(r1559084, r1559085, r1559090);
        double r1559092 = r1559089 * r1559089;
        double r1559093 = fma(r1559085, r1559085, r1559092);
        double r1559094 = sqrt(r1559093);
        double r1559095 = r1559091 / r1559094;
        double r1559096 = r1559095 / r1559094;
        return r1559096;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 32.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(\tan^{-1}_* \frac{im}{re}, 0.0, \log base \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)\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(\tan^{-1}_* \frac{im}{re}, 0.0, \log base \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)\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(\tan^{-1}_* \frac{im}{re}, 0.0, \log base \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)\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. Final simplification0.4

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

Reproduce

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