Average Error: 31.4 → 17.1
Time: 21.5s
Precision: 64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\begin{array}{l} \mathbf{if}\;re \le -5.1674722654441826 \cdot 10^{+113}:\\ \;\;\;\;\left(\left(\log \left(\frac{-1}{re}\right) \cdot -2\right) \cdot \frac{1}{\sqrt{\log 10}}\right) \cdot \frac{\frac{1}{2}}{\sqrt{\log 10}}\\ \mathbf{elif}\;re \le 1.4251927726542934 \cdot 10^{+129}:\\ \;\;\;\;\left(\frac{1}{\sqrt{\log 10}} \cdot \log \left(im \cdot im + re \cdot re\right)\right) \cdot \frac{\frac{1}{2}}{\sqrt{\log 10}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \left(\left(\log re \cdot 2\right) \cdot \frac{1}{\sqrt{\log 10}}\right)\\ \end{array}\]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}
\begin{array}{l}
\mathbf{if}\;re \le -5.1674722654441826 \cdot 10^{+113}:\\
\;\;\;\;\left(\left(\log \left(\frac{-1}{re}\right) \cdot -2\right) \cdot \frac{1}{\sqrt{\log 10}}\right) \cdot \frac{\frac{1}{2}}{\sqrt{\log 10}}\\

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

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

\end{array}
double f(double re, double im) {
        double r1399732 = re;
        double r1399733 = r1399732 * r1399732;
        double r1399734 = im;
        double r1399735 = r1399734 * r1399734;
        double r1399736 = r1399733 + r1399735;
        double r1399737 = sqrt(r1399736);
        double r1399738 = log(r1399737);
        double r1399739 = 10.0;
        double r1399740 = log(r1399739);
        double r1399741 = r1399738 / r1399740;
        return r1399741;
}

double f(double re, double im) {
        double r1399742 = re;
        double r1399743 = -5.1674722654441826e+113;
        bool r1399744 = r1399742 <= r1399743;
        double r1399745 = -1.0;
        double r1399746 = r1399745 / r1399742;
        double r1399747 = log(r1399746);
        double r1399748 = -2.0;
        double r1399749 = r1399747 * r1399748;
        double r1399750 = 1.0;
        double r1399751 = 10.0;
        double r1399752 = log(r1399751);
        double r1399753 = sqrt(r1399752);
        double r1399754 = r1399750 / r1399753;
        double r1399755 = r1399749 * r1399754;
        double r1399756 = 0.5;
        double r1399757 = r1399756 / r1399753;
        double r1399758 = r1399755 * r1399757;
        double r1399759 = 1.4251927726542934e+129;
        bool r1399760 = r1399742 <= r1399759;
        double r1399761 = im;
        double r1399762 = r1399761 * r1399761;
        double r1399763 = r1399742 * r1399742;
        double r1399764 = r1399762 + r1399763;
        double r1399765 = log(r1399764);
        double r1399766 = r1399754 * r1399765;
        double r1399767 = r1399766 * r1399757;
        double r1399768 = log(r1399742);
        double r1399769 = 2.0;
        double r1399770 = r1399768 * r1399769;
        double r1399771 = r1399770 * r1399754;
        double r1399772 = r1399757 * r1399771;
        double r1399773 = r1399760 ? r1399767 : r1399772;
        double r1399774 = r1399744 ? r1399758 : r1399773;
        return r1399774;
}

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 3 regimes
  2. if re < -5.1674722654441826e+113

    1. Initial program 52.1

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

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

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

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

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

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

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

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

    if -5.1674722654441826e+113 < re < 1.4251927726542934e+129

    1. Initial program 21.4

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

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

      \[\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-pow21.4

      \[\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-frac21.4

      \[\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 div-inv21.2

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

    if 1.4251927726542934e+129 < re

    1. Initial program 55.4

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

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

      \[\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-pow55.4

      \[\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-frac55.4

      \[\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 div-inv55.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -5.1674722654441826 \cdot 10^{+113}:\\ \;\;\;\;\left(\left(\log \left(\frac{-1}{re}\right) \cdot -2\right) \cdot \frac{1}{\sqrt{\log 10}}\right) \cdot \frac{\frac{1}{2}}{\sqrt{\log 10}}\\ \mathbf{elif}\;re \le 1.4251927726542934 \cdot 10^{+129}:\\ \;\;\;\;\left(\frac{1}{\sqrt{\log 10}} \cdot \log \left(im \cdot im + re \cdot re\right)\right) \cdot \frac{\frac{1}{2}}{\sqrt{\log 10}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \left(\left(\log re \cdot 2\right) \cdot \frac{1}{\sqrt{\log 10}}\right)\\ \end{array}\]

Reproduce

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