Average Error: 32.2 → 17.5
Time: 21.2s
Precision: 64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
\[\begin{array}{l} \mathbf{if}\;re \le -1.436271402192578108943210466530039245152 \cdot 10^{107}:\\ \;\;\;\;\frac{-1}{\frac{\log base}{\log \left(\frac{-1}{re}\right)}}\\ \mathbf{elif}\;re \le 2.584890597092747745228887794867760307358 \cdot 10^{95}:\\ \;\;\;\;\left(\log base \cdot \log base - 0.0 \cdot 0.0\right) \cdot \frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(\left(\log \left(\sqrt[3]{base}\right) \cdot \log base + \left(\log \left(\sqrt[3]{base}\right) \cdot \log base + \log \left(\sqrt[3]{base}\right) \cdot \log base\right)\right) + 0.0 \cdot 0.0\right) \cdot \left(\log base \cdot \log base - 0.0 \cdot 0.0\right)}\\ \mathbf{else}:\\ \;\;\;\;-\frac{\log re}{-\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.0}{\log base \cdot \log base + 0.0 \cdot 0.0}
\begin{array}{l}
\mathbf{if}\;re \le -1.436271402192578108943210466530039245152 \cdot 10^{107}:\\
\;\;\;\;\frac{-1}{\frac{\log base}{\log \left(\frac{-1}{re}\right)}}\\

\mathbf{elif}\;re \le 2.584890597092747745228887794867760307358 \cdot 10^{95}:\\
\;\;\;\;\left(\log base \cdot \log base - 0.0 \cdot 0.0\right) \cdot \frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(\left(\log \left(\sqrt[3]{base}\right) \cdot \log base + \left(\log \left(\sqrt[3]{base}\right) \cdot \log base + \log \left(\sqrt[3]{base}\right) \cdot \log base\right)\right) + 0.0 \cdot 0.0\right) \cdot \left(\log base \cdot \log base - 0.0 \cdot 0.0\right)}\\

\mathbf{else}:\\
\;\;\;\;-\frac{\log re}{-\log base}\\

\end{array}
double f(double re, double im, double base) {
        double r1876360 = re;
        double r1876361 = r1876360 * r1876360;
        double r1876362 = im;
        double r1876363 = r1876362 * r1876362;
        double r1876364 = r1876361 + r1876363;
        double r1876365 = sqrt(r1876364);
        double r1876366 = log(r1876365);
        double r1876367 = base;
        double r1876368 = log(r1876367);
        double r1876369 = r1876366 * r1876368;
        double r1876370 = atan2(r1876362, r1876360);
        double r1876371 = 0.0;
        double r1876372 = r1876370 * r1876371;
        double r1876373 = r1876369 + r1876372;
        double r1876374 = r1876368 * r1876368;
        double r1876375 = r1876371 * r1876371;
        double r1876376 = r1876374 + r1876375;
        double r1876377 = r1876373 / r1876376;
        return r1876377;
}

double f(double re, double im, double base) {
        double r1876378 = re;
        double r1876379 = -1.4362714021925781e+107;
        bool r1876380 = r1876378 <= r1876379;
        double r1876381 = -1.0;
        double r1876382 = base;
        double r1876383 = log(r1876382);
        double r1876384 = r1876381 / r1876378;
        double r1876385 = log(r1876384);
        double r1876386 = r1876383 / r1876385;
        double r1876387 = r1876381 / r1876386;
        double r1876388 = 2.5848905970927477e+95;
        bool r1876389 = r1876378 <= r1876388;
        double r1876390 = r1876383 * r1876383;
        double r1876391 = 0.0;
        double r1876392 = r1876391 * r1876391;
        double r1876393 = r1876390 - r1876392;
        double r1876394 = im;
        double r1876395 = r1876394 * r1876394;
        double r1876396 = r1876378 * r1876378;
        double r1876397 = r1876395 + r1876396;
        double r1876398 = sqrt(r1876397);
        double r1876399 = log(r1876398);
        double r1876400 = r1876399 * r1876383;
        double r1876401 = atan2(r1876394, r1876378);
        double r1876402 = r1876401 * r1876391;
        double r1876403 = r1876400 + r1876402;
        double r1876404 = cbrt(r1876382);
        double r1876405 = log(r1876404);
        double r1876406 = r1876405 * r1876383;
        double r1876407 = r1876406 + r1876406;
        double r1876408 = r1876406 + r1876407;
        double r1876409 = r1876408 + r1876392;
        double r1876410 = r1876409 * r1876393;
        double r1876411 = r1876403 / r1876410;
        double r1876412 = r1876393 * r1876411;
        double r1876413 = log(r1876378);
        double r1876414 = -r1876383;
        double r1876415 = r1876413 / r1876414;
        double r1876416 = -r1876415;
        double r1876417 = r1876389 ? r1876412 : r1876416;
        double r1876418 = r1876380 ? r1876387 : r1876417;
        return r1876418;
}

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 < -1.4362714021925781e+107

    1. Initial program 52.7

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
    2. Taylor expanded around -inf 64.0

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

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

    if -1.4362714021925781e+107 < re < 2.5848905970927477e+95

    1. Initial program 21.9

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
    2. Using strategy rm
    3. Applied flip-+21.9

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\color{blue}{\frac{\left(\log base \cdot \log base\right) \cdot \left(\log base \cdot \log base\right) - \left(0.0 \cdot 0.0\right) \cdot \left(0.0 \cdot 0.0\right)}{\log base \cdot \log base - 0.0 \cdot 0.0}}}\]
    4. Applied associate-/r/22.0

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(\log base \cdot \log base\right) \cdot \left(\log base \cdot \log base\right) - \left(0.0 \cdot 0.0\right) \cdot \left(0.0 \cdot 0.0\right)} \cdot \left(\log base \cdot \log base - 0.0 \cdot 0.0\right)}\]
    5. Simplified22.0

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(\log base \cdot \log base + 0.0 \cdot 0.0\right) \cdot \left(\log base \cdot \log base - 0.0 \cdot 0.0\right)}} \cdot \left(\log base \cdot \log base - 0.0 \cdot 0.0\right)\]
    6. Using strategy rm
    7. Applied add-cube-cbrt22.0

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(\log base \cdot \log \color{blue}{\left(\left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) \cdot \sqrt[3]{base}\right)} + 0.0 \cdot 0.0\right) \cdot \left(\log base \cdot \log base - 0.0 \cdot 0.0\right)} \cdot \left(\log base \cdot \log base - 0.0 \cdot 0.0\right)\]
    8. Applied log-prod22.0

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(\log base \cdot \color{blue}{\left(\log \left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) + \log \left(\sqrt[3]{base}\right)\right)} + 0.0 \cdot 0.0\right) \cdot \left(\log base \cdot \log base - 0.0 \cdot 0.0\right)} \cdot \left(\log base \cdot \log base - 0.0 \cdot 0.0\right)\]
    9. Applied distribute-lft-in22.0

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

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(\left(\color{blue}{\left(\log \left(\sqrt[3]{base}\right) \cdot \log base + \log \left(\sqrt[3]{base}\right) \cdot \log base\right)} + \log base \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0\right) \cdot \left(\log base \cdot \log base - 0.0 \cdot 0.0\right)} \cdot \left(\log base \cdot \log base - 0.0 \cdot 0.0\right)\]
    11. Simplified22.0

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

    if 2.5848905970927477e+95 < re

    1. Initial program 52.1

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
    2. Taylor expanded around inf 9.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -1.436271402192578108943210466530039245152 \cdot 10^{107}:\\ \;\;\;\;\frac{-1}{\frac{\log base}{\log \left(\frac{-1}{re}\right)}}\\ \mathbf{elif}\;re \le 2.584890597092747745228887794867760307358 \cdot 10^{95}:\\ \;\;\;\;\left(\log base \cdot \log base - 0.0 \cdot 0.0\right) \cdot \frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(\left(\log \left(\sqrt[3]{base}\right) \cdot \log base + \left(\log \left(\sqrt[3]{base}\right) \cdot \log base + \log \left(\sqrt[3]{base}\right) \cdot \log base\right)\right) + 0.0 \cdot 0.0\right) \cdot \left(\log base \cdot \log base - 0.0 \cdot 0.0\right)}\\ \mathbf{else}:\\ \;\;\;\;-\frac{\log re}{-\log base}\\ \end{array}\]

Reproduce

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