Average Error: 31.1 → 0.4
Time: 1.3m
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}\]
\[\frac{1}{\frac{\log base}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}}\]
\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}
\frac{1}{\frac{\log base}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}}
double f(double re, double im, double base) {
        double r1747244 = re;
        double r1747245 = r1747244 * r1747244;
        double r1747246 = im;
        double r1747247 = r1747246 * r1747246;
        double r1747248 = r1747245 + r1747247;
        double r1747249 = sqrt(r1747248);
        double r1747250 = log(r1747249);
        double r1747251 = base;
        double r1747252 = log(r1747251);
        double r1747253 = r1747250 * r1747252;
        double r1747254 = atan2(r1747246, r1747244);
        double r1747255 = 0.0;
        double r1747256 = r1747254 * r1747255;
        double r1747257 = r1747253 + r1747256;
        double r1747258 = r1747252 * r1747252;
        double r1747259 = r1747255 * r1747255;
        double r1747260 = r1747258 + r1747259;
        double r1747261 = r1747257 / r1747260;
        return r1747261;
}

double f(double re, double im, double base) {
        double r1747262 = 1.0;
        double r1747263 = base;
        double r1747264 = log(r1747263);
        double r1747265 = re;
        double r1747266 = im;
        double r1747267 = hypot(r1747265, r1747266);
        double r1747268 = log(r1747267);
        double r1747269 = r1747264 / r1747268;
        double r1747270 = r1747262 / r1747269;
        return r1747270;
}

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

    \[\leadsto \frac{\color{blue}{1 \cdot 1}}{\log \left(e^{\frac{\log base}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}}\right)}\]
  9. Applied associate-/l*0.7

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

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

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

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))))