Average Error: 32.1 → 0.5
Time: 16.7s
Precision: 64
\[\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
\[\mathsf{fma}\left(\tan^{-1}_* \frac{im}{re}, \log base, -0.0 \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)\right) \cdot \frac{1}{\mathsf{fma}\left(0.0, 0.0, {\left(\log base\right)}^{2}\right)}\]
\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}
\mathsf{fma}\left(\tan^{-1}_* \frac{im}{re}, \log base, -0.0 \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)\right) \cdot \frac{1}{\mathsf{fma}\left(0.0, 0.0, {\left(\log base\right)}^{2}\right)}
double f(double re, double im, double base) {
        double r91023 = im;
        double r91024 = re;
        double r91025 = atan2(r91023, r91024);
        double r91026 = base;
        double r91027 = log(r91026);
        double r91028 = r91025 * r91027;
        double r91029 = r91024 * r91024;
        double r91030 = r91023 * r91023;
        double r91031 = r91029 + r91030;
        double r91032 = sqrt(r91031);
        double r91033 = log(r91032);
        double r91034 = 0.0;
        double r91035 = r91033 * r91034;
        double r91036 = r91028 - r91035;
        double r91037 = r91027 * r91027;
        double r91038 = r91034 * r91034;
        double r91039 = r91037 + r91038;
        double r91040 = r91036 / r91039;
        return r91040;
}

double f(double re, double im, double base) {
        double r91041 = im;
        double r91042 = re;
        double r91043 = atan2(r91041, r91042);
        double r91044 = base;
        double r91045 = log(r91044);
        double r91046 = 0.0;
        double r91047 = hypot(r91042, r91041);
        double r91048 = log(r91047);
        double r91049 = r91046 * r91048;
        double r91050 = -r91049;
        double r91051 = fma(r91043, r91045, r91050);
        double r91052 = 1.0;
        double r91053 = 2.0;
        double r91054 = pow(r91045, r91053);
        double r91055 = fma(r91046, r91046, r91054);
        double r91056 = r91052 / r91055;
        double r91057 = r91051 * r91056;
        return r91057;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 32.1

    \[\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
  2. Simplified0.4

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

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

    \[\leadsto \mathsf{fma}\left(\tan^{-1}_* \frac{im}{re}, \log base, -0.0 \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)\right) \cdot \color{blue}{\frac{1}{\mathsf{fma}\left(0.0, 0.0, {\left(\log base\right)}^{2}\right)}}\]
  6. Final simplification0.5

    \[\leadsto \mathsf{fma}\left(\tan^{-1}_* \frac{im}{re}, \log base, -0.0 \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)\right) \cdot \frac{1}{\mathsf{fma}\left(0.0, 0.0, {\left(\log base\right)}^{2}\right)}\]

Reproduce

herbie shell --seed 2020043 +o rules:numerics
(FPCore (re im base)
  :name "math.log/2 on complex, imaginary part"
  :precision binary64
  (/ (- (* (atan2 im re) (log base)) (* (log (sqrt (+ (* re re) (* im im)))) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))