Average Error: 31.8 → 0.5
Time: 23.4s
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{\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 \frac{1}{\mathsf{hypot}\left(\log base, 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{\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 \frac{1}{\mathsf{hypot}\left(\log base, 0.0\right)}
double f(double re, double im, double base) {
        double r70914 = re;
        double r70915 = r70914 * r70914;
        double r70916 = im;
        double r70917 = r70916 * r70916;
        double r70918 = r70915 + r70917;
        double r70919 = sqrt(r70918);
        double r70920 = log(r70919);
        double r70921 = base;
        double r70922 = log(r70921);
        double r70923 = r70920 * r70922;
        double r70924 = atan2(r70916, r70914);
        double r70925 = 0.0;
        double r70926 = r70924 * r70925;
        double r70927 = r70923 + r70926;
        double r70928 = r70922 * r70922;
        double r70929 = r70925 * r70925;
        double r70930 = r70928 + r70929;
        double r70931 = r70927 / r70930;
        return r70931;
}

double f(double re, double im, double base) {
        double r70932 = re;
        double r70933 = im;
        double r70934 = hypot(r70932, r70933);
        double r70935 = log(r70934);
        double r70936 = base;
        double r70937 = log(r70936);
        double r70938 = atan2(r70933, r70932);
        double r70939 = 0.0;
        double r70940 = r70938 * r70939;
        double r70941 = fma(r70935, r70937, r70940);
        double r70942 = hypot(r70937, r70939);
        double r70943 = r70941 / r70942;
        double r70944 = 1.0;
        double r70945 = r70944 / r70942;
        double r70946 = r70943 * r70945;
        return r70946;
}

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

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

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

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

Reproduce

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