Average Error: 32.2 → 0.5
Time: 25.2s
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 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, \sqrt[3]{\left(\left(\log base \cdot \log base\right) \cdot \log base\right) \cdot \left(\left(\log base \cdot \log base\right) \cdot \log base\right)}\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(\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, \sqrt[3]{\left(\left(\log base \cdot \log base\right) \cdot \log base\right) \cdot \left(\left(\log base \cdot \log base\right) \cdot \log base\right)}\right)}}}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}
double f(double re, double im, double base) {
        double r1677066 = re;
        double r1677067 = r1677066 * r1677066;
        double r1677068 = im;
        double r1677069 = r1677068 * r1677068;
        double r1677070 = r1677067 + r1677069;
        double r1677071 = sqrt(r1677070);
        double r1677072 = log(r1677071);
        double r1677073 = base;
        double r1677074 = log(r1677073);
        double r1677075 = r1677072 * r1677074;
        double r1677076 = atan2(r1677068, r1677066);
        double r1677077 = 0.0;
        double r1677078 = r1677076 * r1677077;
        double r1677079 = r1677075 + r1677078;
        double r1677080 = r1677074 * r1677074;
        double r1677081 = r1677077 * r1677077;
        double r1677082 = r1677080 + r1677081;
        double r1677083 = r1677079 / r1677082;
        return r1677083;
}

double f(double re, double im, double base) {
        double r1677084 = base;
        double r1677085 = log(r1677084);
        double r1677086 = re;
        double r1677087 = im;
        double r1677088 = hypot(r1677086, r1677087);
        double r1677089 = log(r1677088);
        double r1677090 = atan2(r1677087, r1677086);
        double r1677091 = 0.0;
        double r1677092 = r1677090 * r1677091;
        double r1677093 = fma(r1677085, r1677089, r1677092);
        double r1677094 = r1677085 * r1677085;
        double r1677095 = r1677094 * r1677085;
        double r1677096 = r1677095 * r1677095;
        double r1677097 = cbrt(r1677096);
        double r1677098 = fma(r1677091, r1677091, r1677097);
        double r1677099 = sqrt(r1677098);
        double r1677100 = r1677093 / r1677099;
        double r1677101 = fma(r1677091, r1677091, r1677094);
        double r1677102 = sqrt(r1677101);
        double r1677103 = r1677100 / r1677102;
        return r1677103;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Derivation

  1. Initial program 32.2

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

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

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

    \[\leadsto \color{blue}{\frac{1 \cdot \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)}}}\]
  9. Using strategy rm
  10. Applied add-cbrt-cube0.5

    \[\leadsto \frac{1 \cdot \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 \color{blue}{\sqrt[3]{\left(\log base \cdot \log base\right) \cdot \log base}}\right)}}}{\sqrt{\mathsf{fma}\left(0.0, 0.0, \log base \cdot \log base\right)}}\]
  11. Applied add-cbrt-cube0.7

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

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

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

Reproduce

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