Average Error: 31.3 → 0.3
Time: 21.2s
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}}{-\log base}\]
\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}}{-\log base}
double f(double re, double im, double base) {
        double r94189 = im;
        double r94190 = re;
        double r94191 = atan2(r94189, r94190);
        double r94192 = base;
        double r94193 = log(r94192);
        double r94194 = r94191 * r94193;
        double r94195 = r94190 * r94190;
        double r94196 = r94189 * r94189;
        double r94197 = r94195 + r94196;
        double r94198 = sqrt(r94197);
        double r94199 = log(r94198);
        double r94200 = 0.0;
        double r94201 = r94199 * r94200;
        double r94202 = r94194 - r94201;
        double r94203 = r94193 * r94193;
        double r94204 = r94200 * r94200;
        double r94205 = r94203 + r94204;
        double r94206 = r94202 / r94205;
        return r94206;
}

double f(double re, double im, double base) {
        double r94207 = im;
        double r94208 = re;
        double r94209 = atan2(r94207, r94208);
        double r94210 = base;
        double r94211 = log(r94210);
        double r94212 = -r94211;
        double r94213 = r94209 / r94212;
        double r94214 = -r94213;
        return r94214;
}

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

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

    \[\leadsto \color{blue}{-1 \cdot \frac{\tan^{-1}_* \frac{im}{re}}{\log \left(\frac{1}{base}\right)}}\]
  4. Simplified0.3

    \[\leadsto \color{blue}{-\frac{\tan^{-1}_* \frac{im}{re}}{-\log base}}\]
  5. Final simplification0.3

    \[\leadsto -\frac{\tan^{-1}_* \frac{im}{re}}{-\log base}\]

Reproduce

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