Average Error: 30.5 → 16.5
Time: 25.3s
Precision: 64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
\[\begin{array}{l} \mathbf{if}\;re \le -4.0303141568877995 \cdot 10^{+114}:\\ \;\;\;\;\log \left(-re\right) \cdot \frac{1}{\log base}\\ \mathbf{elif}\;re \le 1.945423092678915 \cdot 10^{+111}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\log base} \cdot \log re\\ \end{array}\]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}
\begin{array}{l}
\mathbf{if}\;re \le -4.0303141568877995 \cdot 10^{+114}:\\
\;\;\;\;\log \left(-re\right) \cdot \frac{1}{\log base}\\

\mathbf{elif}\;re \le 1.945423092678915 \cdot 10^{+111}:\\
\;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\log base} \cdot \log re\\

\end{array}
double f(double re, double im, double base) {
        double r1363654 = re;
        double r1363655 = r1363654 * r1363654;
        double r1363656 = im;
        double r1363657 = r1363656 * r1363656;
        double r1363658 = r1363655 + r1363657;
        double r1363659 = sqrt(r1363658);
        double r1363660 = log(r1363659);
        double r1363661 = base;
        double r1363662 = log(r1363661);
        double r1363663 = r1363660 * r1363662;
        double r1363664 = atan2(r1363656, r1363654);
        double r1363665 = 0.0;
        double r1363666 = r1363664 * r1363665;
        double r1363667 = r1363663 + r1363666;
        double r1363668 = r1363662 * r1363662;
        double r1363669 = r1363665 * r1363665;
        double r1363670 = r1363668 + r1363669;
        double r1363671 = r1363667 / r1363670;
        return r1363671;
}

double f(double re, double im, double base) {
        double r1363672 = re;
        double r1363673 = -4.0303141568877995e+114;
        bool r1363674 = r1363672 <= r1363673;
        double r1363675 = -r1363672;
        double r1363676 = log(r1363675);
        double r1363677 = 1.0;
        double r1363678 = base;
        double r1363679 = log(r1363678);
        double r1363680 = r1363677 / r1363679;
        double r1363681 = r1363676 * r1363680;
        double r1363682 = 1.945423092678915e+111;
        bool r1363683 = r1363672 <= r1363682;
        double r1363684 = im;
        double r1363685 = r1363684 * r1363684;
        double r1363686 = r1363672 * r1363672;
        double r1363687 = r1363685 + r1363686;
        double r1363688 = sqrt(r1363687);
        double r1363689 = log(r1363688);
        double r1363690 = r1363689 / r1363679;
        double r1363691 = log(r1363672);
        double r1363692 = r1363680 * r1363691;
        double r1363693 = r1363683 ? r1363690 : r1363692;
        double r1363694 = r1363674 ? r1363681 : r1363693;
        return r1363694;
}

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. Split input into 3 regimes
  2. if re < -4.0303141568877995e+114

    1. Initial program 52.3

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
    2. Simplified52.3

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}}\]
    3. Using strategy rm
    4. Applied associate-/r*52.3

      \[\leadsto \color{blue}{\frac{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base}}{\log base}}\]
    5. Simplified52.3

      \[\leadsto \frac{\color{blue}{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}}{\log base}\]
    6. Using strategy rm
    7. Applied div-inv52.3

      \[\leadsto \color{blue}{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \frac{1}{\log base}}\]
    8. Taylor expanded around -inf 7.7

      \[\leadsto \log \color{blue}{\left(-1 \cdot re\right)} \cdot \frac{1}{\log base}\]
    9. Simplified7.7

      \[\leadsto \log \color{blue}{\left(-re\right)} \cdot \frac{1}{\log base}\]

    if -4.0303141568877995e+114 < re < 1.945423092678915e+111

    1. Initial program 20.4

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
    2. Simplified20.4

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}}\]
    3. Using strategy rm
    4. Applied associate-/r*20.3

      \[\leadsto \color{blue}{\frac{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base}}{\log base}}\]
    5. Simplified20.3

      \[\leadsto \frac{\color{blue}{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}}{\log base}\]

    if 1.945423092678915e+111 < re

    1. Initial program 52.4

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
    2. Simplified52.4

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}}\]
    3. Using strategy rm
    4. Applied associate-/r*52.3

      \[\leadsto \color{blue}{\frac{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base}}{\log base}}\]
    5. Simplified52.3

      \[\leadsto \frac{\color{blue}{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}}{\log base}\]
    6. Using strategy rm
    7. Applied div-inv52.3

      \[\leadsto \color{blue}{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \frac{1}{\log base}}\]
    8. Taylor expanded around inf 8.7

      \[\leadsto \log \color{blue}{re} \cdot \frac{1}{\log base}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification16.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -4.0303141568877995 \cdot 10^{+114}:\\ \;\;\;\;\log \left(-re\right) \cdot \frac{1}{\log base}\\ \mathbf{elif}\;re \le 1.945423092678915 \cdot 10^{+111}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\log base} \cdot \log re\\ \end{array}\]

Reproduce

herbie shell --seed 2019152 
(FPCore (re im base)
  :name "math.log/2 on complex, real part"
  (/ (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0)) (+ (* (log base) (log base)) (* 0 0))))