Average Error: 32.1 → 17.3
Time: 18.9s
Precision: 64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\begin{array}{l} \mathbf{if}\;re \le -1.300812438992646141617859246198844532718 \cdot 10^{100}:\\ \;\;\;\;\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 5.714402214507161350041984173167312711037 \cdot 10^{91}:\\ \;\;\;\;\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(2 \cdot \log re\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 -1.300812438992646141617859246198844532718 \cdot 10^{100}:\\
\;\;\;\;\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 5.714402214507161350041984173167312711037 \cdot 10^{91}:\\
\;\;\;\;\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(2 \cdot \log re\right) \cdot \frac{1}{\sqrt{\log 10}}\right)\\

\end{array}
double f(double re, double im) {
        double r1121695 = re;
        double r1121696 = r1121695 * r1121695;
        double r1121697 = im;
        double r1121698 = r1121697 * r1121697;
        double r1121699 = r1121696 + r1121698;
        double r1121700 = sqrt(r1121699);
        double r1121701 = log(r1121700);
        double r1121702 = 10.0;
        double r1121703 = log(r1121702);
        double r1121704 = r1121701 / r1121703;
        return r1121704;
}

double f(double re, double im) {
        double r1121705 = re;
        double r1121706 = -1.3008124389926461e+100;
        bool r1121707 = r1121705 <= r1121706;
        double r1121708 = -1.0;
        double r1121709 = r1121708 / r1121705;
        double r1121710 = log(r1121709);
        double r1121711 = -2.0;
        double r1121712 = r1121710 * r1121711;
        double r1121713 = 1.0;
        double r1121714 = 10.0;
        double r1121715 = log(r1121714);
        double r1121716 = sqrt(r1121715);
        double r1121717 = r1121713 / r1121716;
        double r1121718 = r1121712 * r1121717;
        double r1121719 = 0.5;
        double r1121720 = r1121719 / r1121716;
        double r1121721 = r1121718 * r1121720;
        double r1121722 = 5.714402214507161e+91;
        bool r1121723 = r1121705 <= r1121722;
        double r1121724 = im;
        double r1121725 = r1121724 * r1121724;
        double r1121726 = r1121705 * r1121705;
        double r1121727 = r1121725 + r1121726;
        double r1121728 = log(r1121727);
        double r1121729 = r1121717 * r1121728;
        double r1121730 = r1121729 * r1121720;
        double r1121731 = 2.0;
        double r1121732 = log(r1121705);
        double r1121733 = r1121731 * r1121732;
        double r1121734 = r1121733 * r1121717;
        double r1121735 = r1121720 * r1121734;
        double r1121736 = r1121723 ? r1121730 : r1121735;
        double r1121737 = r1121707 ? r1121721 : r1121736;
        return r1121737;
}

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 < -1.3008124389926461e+100

    1. Initial program 51.9

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt51.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/251.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-pow51.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-frac51.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. Using strategy rm
    8. Applied div-inv51.9

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

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

      \[\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 -1.3008124389926461e+100 < re < 5.714402214507161e+91

    1. Initial program 21.9

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt21.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/221.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-pow21.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-frac21.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. Using strategy rm
    8. Applied div-inv21.8

      \[\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 5.714402214507161e+91 < re

    1. Initial program 49.9

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt49.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/249.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-pow49.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-frac49.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. Using strategy rm
    8. Applied div-inv49.9

      \[\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.9

      \[\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.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -1.300812438992646141617859246198844532718 \cdot 10^{100}:\\ \;\;\;\;\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 5.714402214507161350041984173167312711037 \cdot 10^{91}:\\ \;\;\;\;\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(2 \cdot \log re\right) \cdot \frac{1}{\sqrt{\log 10}}\right)\\ \end{array}\]

Reproduce

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