Average Error: 31.1 → 0.4
Time: 49.4s
Precision: 64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
\[\log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \frac{1}{\log base}\]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}
\log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \frac{1}{\log base}
double f(double re, double im, double base) {
        double r550002 = re;
        double r550003 = r550002 * r550002;
        double r550004 = im;
        double r550005 = r550004 * r550004;
        double r550006 = r550003 + r550005;
        double r550007 = sqrt(r550006);
        double r550008 = log(r550007);
        double r550009 = base;
        double r550010 = log(r550009);
        double r550011 = r550008 * r550010;
        double r550012 = atan2(r550004, r550002);
        double r550013 = 0.0;
        double r550014 = r550012 * r550013;
        double r550015 = r550011 + r550014;
        double r550016 = r550010 * r550010;
        double r550017 = r550013 * r550013;
        double r550018 = r550016 + r550017;
        double r550019 = r550015 / r550018;
        return r550019;
}

double f(double re, double im, double base) {
        double r550020 = re;
        double r550021 = im;
        double r550022 = hypot(r550020, r550021);
        double r550023 = log(r550022);
        double r550024 = 1.0;
        double r550025 = base;
        double r550026 = log(r550025);
        double r550027 = r550024 / r550026;
        double r550028 = r550023 * r550027;
        return r550028;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 31.1

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

    \[\leadsto \color{blue}{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log base}}\]
  3. Using strategy rm
  4. Applied clear-num0.4

    \[\leadsto \color{blue}{\frac{1}{\frac{\log base}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}}}\]
  5. Using strategy rm
  6. Applied add-log-exp0.7

    \[\leadsto \frac{1}{\color{blue}{\log \left(e^{\frac{\log base}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}}\right)}}\]
  7. Using strategy rm
  8. Applied div-inv0.7

    \[\leadsto \frac{1}{\log \left(e^{\color{blue}{\log base \cdot \frac{1}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}}}\right)}\]
  9. Applied exp-prod0.7

    \[\leadsto \frac{1}{\log \color{blue}{\left({\left(e^{\log base}\right)}^{\left(\frac{1}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}\right)}\right)}}\]
  10. Applied log-pow0.5

    \[\leadsto \frac{1}{\color{blue}{\frac{1}{\log \left(\mathsf{hypot}\left(re, im\right)\right)} \cdot \log \left(e^{\log base}\right)}}\]
  11. Applied add-sqr-sqrt0.5

    \[\leadsto \frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{\frac{1}{\log \left(\mathsf{hypot}\left(re, im\right)\right)} \cdot \log \left(e^{\log base}\right)}\]
  12. Applied times-frac0.5

    \[\leadsto \color{blue}{\frac{\sqrt{1}}{\frac{1}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}} \cdot \frac{\sqrt{1}}{\log \left(e^{\log base}\right)}}\]
  13. Simplified0.4

    \[\leadsto \color{blue}{\log \left(\mathsf{hypot}\left(re, im\right)\right)} \cdot \frac{\sqrt{1}}{\log \left(e^{\log base}\right)}\]
  14. Simplified0.4

    \[\leadsto \log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \color{blue}{\frac{1}{\log base}}\]
  15. Final simplification0.4

    \[\leadsto \log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \frac{1}{\log base}\]

Reproduce

herbie shell --seed 2019128 +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)) (+ (* (log base) (log base)) (* 0 0))))