Average Error: 30.6 → 0.4
Time: 16.7s
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 r681624 = re;
        double r681625 = r681624 * r681624;
        double r681626 = im;
        double r681627 = r681626 * r681626;
        double r681628 = r681625 + r681627;
        double r681629 = sqrt(r681628);
        double r681630 = log(r681629);
        double r681631 = base;
        double r681632 = log(r681631);
        double r681633 = r681630 * r681632;
        double r681634 = atan2(r681626, r681624);
        double r681635 = 0.0;
        double r681636 = r681634 * r681635;
        double r681637 = r681633 + r681636;
        double r681638 = r681632 * r681632;
        double r681639 = r681635 * r681635;
        double r681640 = r681638 + r681639;
        double r681641 = r681637 / r681640;
        return r681641;
}

double f(double re, double im, double base) {
        double r681642 = re;
        double r681643 = im;
        double r681644 = hypot(r681642, r681643);
        double r681645 = log(r681644);
        double r681646 = 1.0;
        double r681647 = base;
        double r681648 = log(r681647);
        double r681649 = r681646 / r681648;
        double r681650 = expm1(r681649);
        double r681651 = log1p(r681650);
        double r681652 = r681645 * r681651;
        return r681652;
}

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