Average Error: 31.6 → 0.4
Time: 6.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}\]
\[\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.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}
\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}
double f(double re, double im, double base) {
        double r40900 = im;
        double r40901 = re;
        double r40902 = atan2(r40900, r40901);
        double r40903 = base;
        double r40904 = log(r40903);
        double r40905 = r40902 * r40904;
        double r40906 = r40901 * r40901;
        double r40907 = r40900 * r40900;
        double r40908 = r40906 + r40907;
        double r40909 = sqrt(r40908);
        double r40910 = log(r40909);
        double r40911 = 0.0;
        double r40912 = r40910 * r40911;
        double r40913 = r40905 - r40912;
        double r40914 = r40904 * r40904;
        double r40915 = r40911 * r40911;
        double r40916 = r40914 + r40915;
        double r40917 = r40913 / r40916;
        return r40917;
}

double f(double re, double im, double base) {
        double r40918 = im;
        double r40919 = re;
        double r40920 = atan2(r40918, r40919);
        double r40921 = base;
        double r40922 = log(r40921);
        double r40923 = r40920 * r40922;
        double r40924 = hypot(r40919, r40918);
        double r40925 = log(r40924);
        double r40926 = 0.0;
        double r40927 = r40925 * r40926;
        double r40928 = r40923 - r40927;
        double r40929 = r40922 * r40922;
        double r40930 = r40926 * r40926;
        double r40931 = r40929 + r40930;
        double r40932 = r40928 / r40931;
        return r40932;
}

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 31.6

    \[\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. Using strategy rm
  3. Applied hypot-def0.4

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

    \[\leadsto \frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]

Reproduce

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