Average Error: 32.0 → 0.4
Time: 41.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{1}{\log base} \cdot \tan^{-1}_* \frac{im}{re}\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{1}{\log base} \cdot \tan^{-1}_* \frac{im}{re}\right)\right)
double f(double re, double im, double base) {
        double r2487966 = im;
        double r2487967 = re;
        double r2487968 = atan2(r2487966, r2487967);
        double r2487969 = base;
        double r2487970 = log(r2487969);
        double r2487971 = r2487968 * r2487970;
        double r2487972 = r2487967 * r2487967;
        double r2487973 = r2487966 * r2487966;
        double r2487974 = r2487972 + r2487973;
        double r2487975 = sqrt(r2487974);
        double r2487976 = log(r2487975);
        double r2487977 = 0.0;
        double r2487978 = r2487976 * r2487977;
        double r2487979 = r2487971 - r2487978;
        double r2487980 = r2487970 * r2487970;
        double r2487981 = r2487977 * r2487977;
        double r2487982 = r2487980 + r2487981;
        double r2487983 = r2487979 / r2487982;
        return r2487983;
}

double f(double re, double im, double base) {
        double r2487984 = 1.0;
        double r2487985 = base;
        double r2487986 = log(r2487985);
        double r2487987 = r2487984 / r2487986;
        double r2487988 = im;
        double r2487989 = re;
        double r2487990 = atan2(r2487988, r2487989);
        double r2487991 = r2487987 * r2487990;
        double r2487992 = expm1(r2487991);
        double r2487993 = log1p(r2487992);
        return r2487993;
}

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

    \[\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. Simplified0.4

    \[\leadsto \color{blue}{\frac{\log base \cdot \tan^{-1}_* \frac{im}{re} - \log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot 0.0}{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}\]
  3. Taylor expanded around 0 0.3

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

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\tan^{-1}_* \frac{im}{re}}{\log base}\right)\right)}\]
  6. Using strategy rm
  7. 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)\]
  8. Final simplification0.4

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

Reproduce

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