Average Error: 32.1 → 17.6
Time: 5.4s
Precision: 64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\begin{array}{l} \mathbf{if}\;re \le -5.543624575485825300470836787098407507184 \cdot 10^{99}:\\ \;\;\;\;\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \left(-2 \cdot \left(\log \left(\frac{-1}{re}\right) \cdot \sqrt{\frac{1}{\log 10}}\right)\right)\\ \mathbf{elif}\;re \le -9.578288750802014562135419564622868355459 \cdot 10^{-264}:\\ \;\;\;\;\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\\ \mathbf{elif}\;re \le 2.695186912474015462769700121112449872029 \cdot 10^{-166}:\\ \;\;\;\;\frac{\log im}{\log 10}\\ \mathbf{elif}\;re \le 4.969148025702489596813788314716096306133 \cdot 10^{122}:\\ \;\;\;\;\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \left(-2 \cdot \left(\log \left(\frac{1}{re}\right) \cdot \sqrt{\frac{1}{\log 10}}\right)\right)\\ \end{array}\]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}
\begin{array}{l}
\mathbf{if}\;re \le -5.543624575485825300470836787098407507184 \cdot 10^{99}:\\
\;\;\;\;\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \left(-2 \cdot \left(\log \left(\frac{-1}{re}\right) \cdot \sqrt{\frac{1}{\log 10}}\right)\right)\\

\mathbf{elif}\;re \le -9.578288750802014562135419564622868355459 \cdot 10^{-264}:\\
\;\;\;\;\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\\

\mathbf{elif}\;re \le 2.695186912474015462769700121112449872029 \cdot 10^{-166}:\\
\;\;\;\;\frac{\log im}{\log 10}\\

\mathbf{elif}\;re \le 4.969148025702489596813788314716096306133 \cdot 10^{122}:\\
\;\;\;\;\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \left(-2 \cdot \left(\log \left(\frac{1}{re}\right) \cdot \sqrt{\frac{1}{\log 10}}\right)\right)\\

\end{array}
double f(double re, double im) {
        double r39632 = re;
        double r39633 = r39632 * r39632;
        double r39634 = im;
        double r39635 = r39634 * r39634;
        double r39636 = r39633 + r39635;
        double r39637 = sqrt(r39636);
        double r39638 = log(r39637);
        double r39639 = 10.0;
        double r39640 = log(r39639);
        double r39641 = r39638 / r39640;
        return r39641;
}

double f(double re, double im) {
        double r39642 = re;
        double r39643 = -5.543624575485825e+99;
        bool r39644 = r39642 <= r39643;
        double r39645 = 0.5;
        double r39646 = 10.0;
        double r39647 = log(r39646);
        double r39648 = sqrt(r39647);
        double r39649 = r39645 / r39648;
        double r39650 = -2.0;
        double r39651 = -1.0;
        double r39652 = r39651 / r39642;
        double r39653 = log(r39652);
        double r39654 = 1.0;
        double r39655 = r39654 / r39647;
        double r39656 = sqrt(r39655);
        double r39657 = r39653 * r39656;
        double r39658 = r39650 * r39657;
        double r39659 = r39649 * r39658;
        double r39660 = -9.578288750802015e-264;
        bool r39661 = r39642 <= r39660;
        double r39662 = r39642 * r39642;
        double r39663 = im;
        double r39664 = r39663 * r39663;
        double r39665 = r39662 + r39664;
        double r39666 = r39654 / r39648;
        double r39667 = pow(r39665, r39666);
        double r39668 = log(r39667);
        double r39669 = r39649 * r39668;
        double r39670 = 2.6951869124740155e-166;
        bool r39671 = r39642 <= r39670;
        double r39672 = log(r39663);
        double r39673 = r39672 / r39647;
        double r39674 = 4.9691480257024896e+122;
        bool r39675 = r39642 <= r39674;
        double r39676 = r39654 / r39642;
        double r39677 = log(r39676);
        double r39678 = r39677 * r39656;
        double r39679 = r39650 * r39678;
        double r39680 = r39649 * r39679;
        double r39681 = r39675 ? r39669 : r39680;
        double r39682 = r39671 ? r39673 : r39681;
        double r39683 = r39661 ? r39669 : r39682;
        double r39684 = r39644 ? r39659 : r39683;
        return r39684;
}

Error

Bits error versus re

Bits error versus im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if re < -5.543624575485825e+99

    1. Initial program 50.9

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt50.9

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\color{blue}{\sqrt{\log 10} \cdot \sqrt{\log 10}}}\]
    4. Applied pow1/250.9

      \[\leadsto \frac{\log \color{blue}{\left({\left(re \cdot re + im \cdot im\right)}^{\frac{1}{2}}\right)}}{\sqrt{\log 10} \cdot \sqrt{\log 10}}\]
    5. Applied log-pow50.9

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \log \left(re \cdot re + im \cdot im\right)}}{\sqrt{\log 10} \cdot \sqrt{\log 10}}\]
    6. Applied times-frac50.9

      \[\leadsto \color{blue}{\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \frac{\log \left(re \cdot re + im \cdot im\right)}{\sqrt{\log 10}}}\]
    7. Taylor expanded around -inf 9.1

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

    if -5.543624575485825e+99 < re < -9.578288750802015e-264 or 2.6951869124740155e-166 < re < 4.9691480257024896e+122

    1. Initial program 18.5

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt18.5

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\color{blue}{\sqrt{\log 10} \cdot \sqrt{\log 10}}}\]
    4. Applied pow1/218.5

      \[\leadsto \frac{\log \color{blue}{\left({\left(re \cdot re + im \cdot im\right)}^{\frac{1}{2}}\right)}}{\sqrt{\log 10} \cdot \sqrt{\log 10}}\]
    5. Applied log-pow18.5

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \log \left(re \cdot re + im \cdot im\right)}}{\sqrt{\log 10} \cdot \sqrt{\log 10}}\]
    6. Applied times-frac18.5

      \[\leadsto \color{blue}{\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \frac{\log \left(re \cdot re + im \cdot im\right)}{\sqrt{\log 10}}}\]
    7. Using strategy rm
    8. Applied add-log-exp18.5

      \[\leadsto \frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \color{blue}{\log \left(e^{\frac{\log \left(re \cdot re + im \cdot im\right)}{\sqrt{\log 10}}}\right)}\]
    9. Simplified18.3

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

    if -9.578288750802015e-264 < re < 2.6951869124740155e-166

    1. Initial program 32.3

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Taylor expanded around 0 34.6

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

    if 4.9691480257024896e+122 < re

    1. Initial program 56.3

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt56.3

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\color{blue}{\sqrt{\log 10} \cdot \sqrt{\log 10}}}\]
    4. Applied pow1/256.3

      \[\leadsto \frac{\log \color{blue}{\left({\left(re \cdot re + im \cdot im\right)}^{\frac{1}{2}}\right)}}{\sqrt{\log 10} \cdot \sqrt{\log 10}}\]
    5. Applied log-pow56.3

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \log \left(re \cdot re + im \cdot im\right)}}{\sqrt{\log 10} \cdot \sqrt{\log 10}}\]
    6. Applied times-frac56.3

      \[\leadsto \color{blue}{\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \frac{\log \left(re \cdot re + im \cdot im\right)}{\sqrt{\log 10}}}\]
    7. Taylor expanded around inf 8.2

      \[\leadsto \frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \color{blue}{\left(-2 \cdot \left(\log \left(\frac{1}{re}\right) \cdot \sqrt{\frac{1}{\log 10}}\right)\right)}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification17.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -5.543624575485825300470836787098407507184 \cdot 10^{99}:\\ \;\;\;\;\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \left(-2 \cdot \left(\log \left(\frac{-1}{re}\right) \cdot \sqrt{\frac{1}{\log 10}}\right)\right)\\ \mathbf{elif}\;re \le -9.578288750802014562135419564622868355459 \cdot 10^{-264}:\\ \;\;\;\;\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\\ \mathbf{elif}\;re \le 2.695186912474015462769700121112449872029 \cdot 10^{-166}:\\ \;\;\;\;\frac{\log im}{\log 10}\\ \mathbf{elif}\;re \le 4.969148025702489596813788314716096306133 \cdot 10^{122}:\\ \;\;\;\;\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \left(-2 \cdot \left(\log \left(\frac{1}{re}\right) \cdot \sqrt{\frac{1}{\log 10}}\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019353 
(FPCore (re im)
  :name "math.log10 on complex, real part"
  :precision binary64
  (/ (log (sqrt (+ (* re re) (* im im)))) (log 10)))