Average Error: 32.2 → 0.4
Time: 9.1s
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(\tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\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(\tan^{-1}_* \frac{im}{re} \cdot \frac{1}{\log base}\right)\right)
double f(double re, double im, double base) {
        double r152 = im;
        double r153 = re;
        double r154 = atan2(r152, r153);
        double r155 = base;
        double r156 = log(r155);
        double r157 = r154 * r156;
        double r158 = r153 * r153;
        double r159 = r152 * r152;
        double r160 = r158 + r159;
        double r161 = sqrt(r160);
        double r162 = log(r161);
        double r163 = 0.0;
        double r164 = r162 * r163;
        double r165 = r157 - r164;
        double r166 = r156 * r156;
        double r167 = r163 * r163;
        double r168 = r166 + r167;
        double r169 = r165 / r168;
        return r169;
}

double f(double re, double im, double base) {
        double r170 = im;
        double r171 = re;
        double r172 = atan2(r170, r171);
        double r173 = 1.0;
        double r174 = base;
        double r175 = log(r174);
        double r176 = r173 / r175;
        double r177 = r172 * r176;
        double r178 = expm1(r177);
        double r179 = log1p(r178);
        return r179;
}

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

    \[\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. Using strategy rm
  6. Applied div-inv0.4

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

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

Reproduce

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