Average Error: 32.3 → 0.3
Time: 4.6s
Precision: 64
\[\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
\[\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\tan^{-1}_* \frac{im}{re}}{\log base}\right)\right)\]
\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}
\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\tan^{-1}_* \frac{im}{re}}{\log base}\right)\right)
double f(double re, double im, double base) {
        double r36725 = im;
        double r36726 = re;
        double r36727 = atan2(r36725, r36726);
        double r36728 = base;
        double r36729 = log(r36728);
        double r36730 = r36727 * r36729;
        double r36731 = r36726 * r36726;
        double r36732 = r36725 * r36725;
        double r36733 = r36731 + r36732;
        double r36734 = sqrt(r36733);
        double r36735 = log(r36734);
        double r36736 = 0.0;
        double r36737 = r36735 * r36736;
        double r36738 = r36730 - r36737;
        double r36739 = r36729 * r36729;
        double r36740 = r36736 * r36736;
        double r36741 = r36739 + r36740;
        double r36742 = r36738 / r36741;
        return r36742;
}

double f(double re, double im, double base) {
        double r36743 = im;
        double r36744 = re;
        double r36745 = atan2(r36743, r36744);
        double r36746 = base;
        double r36747 = log(r36746);
        double r36748 = r36745 / r36747;
        double r36749 = expm1(r36748);
        double r36750 = log1p(r36749);
        return r36750;
}

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 32.3

    \[\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
  2. Taylor expanded around 0 0.3

    \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re}}{\log base}}\]
  3. Using strategy rm
  4. Applied log1p-expm1-u0.3

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\tan^{-1}_* \frac{im}{re}}{\log base}\right)\right)}\]
  5. Final simplification0.3

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\tan^{-1}_* \frac{im}{re}}{\log base}\right)\right)\]

Reproduce

herbie shell --seed 2020020 +o rules:numerics
(FPCore (re im base)
  :name "math.log/2 on complex, imaginary part"
  :precision binary64
  (/ (- (* (atan2 im re) (log base)) (* (log (sqrt (+ (* re re) (* im im)))) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))