Average Error: 32.4 → 19.4
Time: 7.9s
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 -3.23581803284482809 \cdot 10^{99}:\\ \;\;\;\;\frac{\frac{\left(-1 \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\ \mathbf{elif}\;re \le -3.31761422822591608 \cdot 10^{-169}:\\ \;\;\;\;\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 \left(2 \cdot \log \left(\sqrt[3]{base}\right)\right) + \log base \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0}\\ \mathbf{elif}\;re \le 4.1929943707664459 \cdot 10^{-158}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \mathbf{elif}\;re \le 1.636596928009733 \cdot 10^{98}:\\ \;\;\;\;\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 \left(2 \cdot \log \left({\left(\frac{1}{base}\right)}^{\frac{-1}{3}}\right)\right) + \log base \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0}\\ \mathbf{elif}\;re \le 6.2677095626547518 \cdot 10^{130}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{1}{re}\right)}{\log \left(\frac{1}{base}\right)}\\ \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 -3.23581803284482809 \cdot 10^{99}:\\
\;\;\;\;\frac{\frac{\left(-1 \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\

\mathbf{elif}\;re \le -3.31761422822591608 \cdot 10^{-169}:\\
\;\;\;\;\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 \left(2 \cdot \log \left(\sqrt[3]{base}\right)\right) + \log base \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0}\\

\mathbf{elif}\;re \le 4.1929943707664459 \cdot 10^{-158}:\\
\;\;\;\;\frac{\log im}{\log base}\\

\mathbf{elif}\;re \le 1.636596928009733 \cdot 10^{98}:\\
\;\;\;\;\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 \left(2 \cdot \log \left({\left(\frac{1}{base}\right)}^{\frac{-1}{3}}\right)\right) + \log base \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0}\\

\mathbf{elif}\;re \le 6.2677095626547518 \cdot 10^{130}:\\
\;\;\;\;\frac{\log im}{\log base}\\

\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\frac{1}{re}\right)}{\log \left(\frac{1}{base}\right)}\\

\end{array}
double f(double re, double im, double base) {
        double r43438 = re;
        double r43439 = r43438 * r43438;
        double r43440 = im;
        double r43441 = r43440 * r43440;
        double r43442 = r43439 + r43441;
        double r43443 = sqrt(r43442);
        double r43444 = log(r43443);
        double r43445 = base;
        double r43446 = log(r43445);
        double r43447 = r43444 * r43446;
        double r43448 = atan2(r43440, r43438);
        double r43449 = 0.0;
        double r43450 = r43448 * r43449;
        double r43451 = r43447 + r43450;
        double r43452 = r43446 * r43446;
        double r43453 = r43449 * r43449;
        double r43454 = r43452 + r43453;
        double r43455 = r43451 / r43454;
        return r43455;
}

double f(double re, double im, double base) {
        double r43456 = re;
        double r43457 = -3.235818032844828e+99;
        bool r43458 = r43456 <= r43457;
        double r43459 = -1.0;
        double r43460 = r43459 / r43456;
        double r43461 = log(r43460);
        double r43462 = r43459 * r43461;
        double r43463 = base;
        double r43464 = log(r43463);
        double r43465 = r43462 * r43464;
        double r43466 = im;
        double r43467 = atan2(r43466, r43456);
        double r43468 = 0.0;
        double r43469 = r43467 * r43468;
        double r43470 = r43465 + r43469;
        double r43471 = r43464 * r43464;
        double r43472 = r43468 * r43468;
        double r43473 = r43471 + r43472;
        double r43474 = sqrt(r43473);
        double r43475 = r43470 / r43474;
        double r43476 = r43475 / r43474;
        double r43477 = -3.317614228225916e-169;
        bool r43478 = r43456 <= r43477;
        double r43479 = r43456 * r43456;
        double r43480 = r43466 * r43466;
        double r43481 = r43479 + r43480;
        double r43482 = sqrt(r43481);
        double r43483 = log(r43482);
        double r43484 = r43483 * r43464;
        double r43485 = r43484 + r43469;
        double r43486 = 2.0;
        double r43487 = cbrt(r43463);
        double r43488 = log(r43487);
        double r43489 = r43486 * r43488;
        double r43490 = r43464 * r43489;
        double r43491 = r43464 * r43488;
        double r43492 = r43490 + r43491;
        double r43493 = r43492 + r43472;
        double r43494 = r43485 / r43493;
        double r43495 = 4.192994370766446e-158;
        bool r43496 = r43456 <= r43495;
        double r43497 = log(r43466);
        double r43498 = r43497 / r43464;
        double r43499 = 1.636596928009733e+98;
        bool r43500 = r43456 <= r43499;
        double r43501 = 1.0;
        double r43502 = r43501 / r43463;
        double r43503 = -0.3333333333333333;
        double r43504 = pow(r43502, r43503);
        double r43505 = log(r43504);
        double r43506 = r43486 * r43505;
        double r43507 = r43464 * r43506;
        double r43508 = r43507 + r43491;
        double r43509 = r43508 + r43472;
        double r43510 = r43485 / r43509;
        double r43511 = 6.267709562654752e+130;
        bool r43512 = r43456 <= r43511;
        double r43513 = r43501 / r43456;
        double r43514 = log(r43513);
        double r43515 = log(r43502);
        double r43516 = r43514 / r43515;
        double r43517 = r43512 ? r43498 : r43516;
        double r43518 = r43500 ? r43510 : r43517;
        double r43519 = r43496 ? r43498 : r43518;
        double r43520 = r43478 ? r43494 : r43519;
        double r43521 = r43458 ? r43476 : r43520;
        return r43521;
}

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 5 regimes
  2. if re < -3.235818032844828e+99

    1. Initial program 51.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 add-sqr-sqrt51.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}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0} \cdot \sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}\]
    4. Applied associate-/r*51.9

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

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

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

    if -3.235818032844828e+99 < re < -3.317614228225916e-169

    1. Initial program 17.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. Using strategy rm
    3. Applied add-cube-cbrt17.7

      \[\leadsto \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 \color{blue}{\left(\left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) \cdot \sqrt[3]{base}\right)} + 0.0 \cdot 0.0}\]
    4. Applied log-prod17.7

      \[\leadsto \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 \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}\]
    5. Applied distribute-lft-in17.7

      \[\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}{\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}\]
    6. Simplified17.7

      \[\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}{\log base \cdot \left(2 \cdot \log \left(\sqrt[3]{base}\right)\right)} + \log base \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0}\]

    if -3.317614228225916e-169 < re < 4.192994370766446e-158 or 1.636596928009733e+98 < re < 6.267709562654752e+130

    1. Initial program 30.0

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

      \[\leadsto \color{blue}{\frac{\log im}{\log base}}\]

    if 4.192994370766446e-158 < re < 1.636596928009733e+98

    1. Initial program 16.6

      \[\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 add-cube-cbrt16.6

      \[\leadsto \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 \color{blue}{\left(\left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) \cdot \sqrt[3]{base}\right)} + 0.0 \cdot 0.0}\]
    4. Applied log-prod16.6

      \[\leadsto \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 \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}\]
    5. Applied distribute-lft-in16.6

      \[\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}{\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}\]
    6. Simplified16.6

      \[\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}{\log base \cdot \left(2 \cdot \log \left(\sqrt[3]{base}\right)\right)} + \log base \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0}\]
    7. Taylor expanded around inf 16.6

      \[\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 \left(2 \cdot \log \color{blue}{\left({\left(\frac{1}{base}\right)}^{\frac{-1}{3}}\right)}\right) + \log base \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0}\]

    if 6.267709562654752e+130 < re

    1. Initial program 57.6

      \[\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 7.2

      \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{re}\right)}{\log \left(\frac{1}{base}\right)}}\]
  3. Recombined 5 regimes into one program.
  4. Final simplification19.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -3.23581803284482809 \cdot 10^{99}:\\ \;\;\;\;\frac{\frac{\left(-1 \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\ \mathbf{elif}\;re \le -3.31761422822591608 \cdot 10^{-169}:\\ \;\;\;\;\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 \left(2 \cdot \log \left(\sqrt[3]{base}\right)\right) + \log base \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0}\\ \mathbf{elif}\;re \le 4.1929943707664459 \cdot 10^{-158}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \mathbf{elif}\;re \le 1.636596928009733 \cdot 10^{98}:\\ \;\;\;\;\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 \left(2 \cdot \log \left({\left(\frac{1}{base}\right)}^{\frac{-1}{3}}\right)\right) + \log base \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0}\\ \mathbf{elif}\;re \le 6.2677095626547518 \cdot 10^{130}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{1}{re}\right)}{\log \left(\frac{1}{base}\right)}\\ \end{array}\]

Reproduce

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