Average Error: 30.5 → 0.4
Time: 2.4m
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{\log \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(re, im\right)\right)\right)\right)}{\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}
\frac{\log \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(re, im\right)\right)\right)\right)}{\log base}
double f(double re, double im, double base) {
        double r2170123 = re;
        double r2170124 = r2170123 * r2170123;
        double r2170125 = im;
        double r2170126 = r2170125 * r2170125;
        double r2170127 = r2170124 + r2170126;
        double r2170128 = sqrt(r2170127);
        double r2170129 = log(r2170128);
        double r2170130 = base;
        double r2170131 = log(r2170130);
        double r2170132 = r2170129 * r2170131;
        double r2170133 = atan2(r2170125, r2170123);
        double r2170134 = 0.0;
        double r2170135 = r2170133 * r2170134;
        double r2170136 = r2170132 + r2170135;
        double r2170137 = r2170131 * r2170131;
        double r2170138 = r2170134 * r2170134;
        double r2170139 = r2170137 + r2170138;
        double r2170140 = r2170136 / r2170139;
        return r2170140;
}

double f(double re, double im, double base) {
        double r2170141 = re;
        double r2170142 = im;
        double r2170143 = hypot(r2170141, r2170142);
        double r2170144 = log1p(r2170143);
        double r2170145 = expm1(r2170144);
        double r2170146 = log(r2170145);
        double r2170147 = base;
        double r2170148 = log(r2170147);
        double r2170149 = r2170146 / r2170148;
        return r2170149;
}

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.5

    \[\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 expm1-log1p-u0.4

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

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

Reproduce

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