Average Error: 31.9 → 0.3
Time: 16.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 r49720 = im;
        double r49721 = re;
        double r49722 = atan2(r49720, r49721);
        double r49723 = base;
        double r49724 = log(r49723);
        double r49725 = r49722 * r49724;
        double r49726 = r49721 * r49721;
        double r49727 = r49720 * r49720;
        double r49728 = r49726 + r49727;
        double r49729 = sqrt(r49728);
        double r49730 = log(r49729);
        double r49731 = 0.0;
        double r49732 = r49730 * r49731;
        double r49733 = r49725 - r49732;
        double r49734 = r49724 * r49724;
        double r49735 = r49731 * r49731;
        double r49736 = r49734 + r49735;
        double r49737 = r49733 / r49736;
        return r49737;
}

double f(double re, double im, double base) {
        double r49738 = im;
        double r49739 = re;
        double r49740 = atan2(r49738, r49739);
        double r49741 = base;
        double r49742 = log(r49741);
        double r49743 = r49740 / r49742;
        return r49743;
}

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

    \[\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 0 0.3

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

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

Reproduce

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