Average Error: 32.0 → 0.3
Time: 14.3s
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 r49221 = im;
        double r49222 = re;
        double r49223 = atan2(r49221, r49222);
        double r49224 = base;
        double r49225 = log(r49224);
        double r49226 = r49223 * r49225;
        double r49227 = r49222 * r49222;
        double r49228 = r49221 * r49221;
        double r49229 = r49227 + r49228;
        double r49230 = sqrt(r49229);
        double r49231 = log(r49230);
        double r49232 = 0.0;
        double r49233 = r49231 * r49232;
        double r49234 = r49226 - r49233;
        double r49235 = r49225 * r49225;
        double r49236 = r49232 * r49232;
        double r49237 = r49235 + r49236;
        double r49238 = r49234 / r49237;
        return r49238;
}

double f(double re, double im, double base) {
        double r49239 = im;
        double r49240 = re;
        double r49241 = atan2(r49239, r49240);
        double r49242 = base;
        double r49243 = log(r49242);
        double r49244 = -r49243;
        double r49245 = r49241 / r49244;
        double r49246 = -r49245;
        return r49246;
}

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{\mathsf{fma}\left(-0.0, \log \left(\mathsf{hypot}\left(im, re\right)\right), \log base \cdot \tan^{-1}_* \frac{im}{re}\right)}{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt0.4

    \[\leadsto \frac{\mathsf{fma}\left(-0.0, \log \left(\mathsf{hypot}\left(im, re\right)\right), \log base \cdot \tan^{-1}_* \frac{im}{re}\right)}{\color{blue}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)} \cdot \sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}}\]
  5. Applied *-un-lft-identity0.4

    \[\leadsto \frac{\color{blue}{1 \cdot \mathsf{fma}\left(-0.0, \log \left(\mathsf{hypot}\left(im, re\right)\right), \log base \cdot \tan^{-1}_* \frac{im}{re}\right)}}{\sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)} \cdot \sqrt{\mathsf{fma}\left(\log base, \log base, 0.0 \cdot 0.0\right)}}\]
  6. Applied times-frac0.4

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

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

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

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

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

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

Reproduce

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