Average Error: 32.3 → 0.3
Time: 5.0s
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 r33510 = im;
        double r33511 = re;
        double r33512 = atan2(r33510, r33511);
        double r33513 = base;
        double r33514 = log(r33513);
        double r33515 = r33512 * r33514;
        double r33516 = r33511 * r33511;
        double r33517 = r33510 * r33510;
        double r33518 = r33516 + r33517;
        double r33519 = sqrt(r33518);
        double r33520 = log(r33519);
        double r33521 = 0.0;
        double r33522 = r33520 * r33521;
        double r33523 = r33515 - r33522;
        double r33524 = r33514 * r33514;
        double r33525 = r33521 * r33521;
        double r33526 = r33524 + r33525;
        double r33527 = r33523 / r33526;
        return r33527;
}

double f(double re, double im, double base) {
        double r33528 = im;
        double r33529 = re;
        double r33530 = atan2(r33528, r33529);
        double r33531 = base;
        double r33532 = log(r33531);
        double r33533 = r33530 / r33532;
        double r33534 = expm1(r33533);
        double r33535 = log1p(r33534);
        return r33535;
}

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