Average Error: 30.6 → 0.4
Time: 19.0s
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 \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\log base}\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}
\log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\log base}\right)\right)
double f(double re, double im, double base) {
        double r695601 = re;
        double r695602 = r695601 * r695601;
        double r695603 = im;
        double r695604 = r695603 * r695603;
        double r695605 = r695602 + r695604;
        double r695606 = sqrt(r695605);
        double r695607 = log(r695606);
        double r695608 = base;
        double r695609 = log(r695608);
        double r695610 = r695607 * r695609;
        double r695611 = atan2(r695603, r695601);
        double r695612 = 0.0;
        double r695613 = r695611 * r695612;
        double r695614 = r695610 + r695613;
        double r695615 = r695609 * r695609;
        double r695616 = r695612 * r695612;
        double r695617 = r695615 + r695616;
        double r695618 = r695614 / r695617;
        return r695618;
}

double f(double re, double im, double base) {
        double r695619 = re;
        double r695620 = im;
        double r695621 = hypot(r695619, r695620);
        double r695622 = log(r695621);
        double r695623 = 1.0;
        double r695624 = base;
        double r695625 = log(r695624);
        double r695626 = r695623 / r695625;
        double r695627 = expm1(r695626);
        double r695628 = log1p(r695627);
        double r695629 = r695622 * r695628;
        return r695629;
}

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 30.6

    \[\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 div-inv0.4

    \[\leadsto \color{blue}{\log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \frac{1}{\log base}}\]
  5. Using strategy rm
  6. Applied log1p-expm1-u0.4

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

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

Reproduce

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