Average Error: 31.1 → 16.9
Time: 1.7m
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.9423406127722474 \cdot 10^{+128}:\\ \;\;\;\;-\frac{\log \left(\frac{-1}{re}\right)}{\log base}\\ \mathbf{elif}\;re \le -1.3722590116078242 \cdot 10^{-271}:\\ \;\;\;\;\frac{1}{\frac{\log base}{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im \cdot \log base}{\log base \cdot \log base}\\ \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.9423406127722474 \cdot 10^{+128}:\\
\;\;\;\;-\frac{\log \left(\frac{-1}{re}\right)}{\log base}\\

\mathbf{elif}\;re \le -1.3722590116078242 \cdot 10^{-271}:\\
\;\;\;\;\frac{1}{\frac{\log base}{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\log im \cdot \log base}{\log base \cdot \log base}\\

\end{array}
double f(double re, double im, double base) {
        double r4438539 = re;
        double r4438540 = r4438539 * r4438539;
        double r4438541 = im;
        double r4438542 = r4438541 * r4438541;
        double r4438543 = r4438540 + r4438542;
        double r4438544 = sqrt(r4438543);
        double r4438545 = log(r4438544);
        double r4438546 = base;
        double r4438547 = log(r4438546);
        double r4438548 = r4438545 * r4438547;
        double r4438549 = atan2(r4438541, r4438539);
        double r4438550 = 0.0;
        double r4438551 = r4438549 * r4438550;
        double r4438552 = r4438548 + r4438551;
        double r4438553 = r4438547 * r4438547;
        double r4438554 = r4438550 * r4438550;
        double r4438555 = r4438553 + r4438554;
        double r4438556 = r4438552 / r4438555;
        return r4438556;
}

double f(double re, double im, double base) {
        double r4438557 = re;
        double r4438558 = -4.9423406127722474e+128;
        bool r4438559 = r4438557 <= r4438558;
        double r4438560 = -1.0;
        double r4438561 = r4438560 / r4438557;
        double r4438562 = log(r4438561);
        double r4438563 = base;
        double r4438564 = log(r4438563);
        double r4438565 = r4438562 / r4438564;
        double r4438566 = -r4438565;
        double r4438567 = -1.3722590116078242e-271;
        bool r4438568 = r4438557 <= r4438567;
        double r4438569 = 1.0;
        double r4438570 = im;
        double r4438571 = r4438570 * r4438570;
        double r4438572 = r4438557 * r4438557;
        double r4438573 = r4438571 + r4438572;
        double r4438574 = sqrt(r4438573);
        double r4438575 = log(r4438574);
        double r4438576 = r4438564 / r4438575;
        double r4438577 = r4438569 / r4438576;
        double r4438578 = log(r4438570);
        double r4438579 = r4438578 * r4438564;
        double r4438580 = r4438564 * r4438564;
        double r4438581 = r4438579 / r4438580;
        double r4438582 = r4438568 ? r4438577 : r4438581;
        double r4438583 = r4438559 ? r4438566 : r4438582;
        return r4438583;
}

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.9423406127722474e+128

    1. Initial program 56.1

      \[\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. Simplified56.1

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

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

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

    if -4.9423406127722474e+128 < re < -1.3722590116078242e-271

    1. Initial program 19.5

      \[\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. Simplified19.5

      \[\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 clear-num19.5

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

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

    if -1.3722590116078242e-271 < re

    1. Initial program 33.1

      \[\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. Simplified33.1

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}}\]
    3. Taylor expanded around 0 31.3

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

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

Reproduce

herbie shell --seed 2019128 
(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))))