Average Error: 31.8 → 17.3
Time: 22.0s
Precision: 64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\begin{array}{l} \mathbf{if}\;re \le -1.181793183213821728908776663248811693415 \cdot 10^{151}:\\ \;\;\;\;\left(\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \left(-2 \cdot \log \left(\frac{-1}{re}\right)\right)\right) \cdot \frac{1}{\sqrt{\log 10}}\\ \mathbf{elif}\;re \le 7.392440833541333777660561627276981553815 \cdot 10^{126}:\\ \;\;\;\;\left(\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \log \left(re \cdot re + im \cdot im\right)\right) \cdot \frac{1}{\sqrt{\log 10}}\\ \mathbf{else}:\\ \;\;\;\;\left(\log re \cdot \sqrt{\frac{1}{\log 10}}\right) \cdot \frac{1}{\sqrt{\log 10}}\\ \end{array}\]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}
\begin{array}{l}
\mathbf{if}\;re \le -1.181793183213821728908776663248811693415 \cdot 10^{151}:\\
\;\;\;\;\left(\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \left(-2 \cdot \log \left(\frac{-1}{re}\right)\right)\right) \cdot \frac{1}{\sqrt{\log 10}}\\

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

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

\end{array}
double f(double re, double im) {
        double r2108090 = re;
        double r2108091 = r2108090 * r2108090;
        double r2108092 = im;
        double r2108093 = r2108092 * r2108092;
        double r2108094 = r2108091 + r2108093;
        double r2108095 = sqrt(r2108094);
        double r2108096 = log(r2108095);
        double r2108097 = 10.0;
        double r2108098 = log(r2108097);
        double r2108099 = r2108096 / r2108098;
        return r2108099;
}

double f(double re, double im) {
        double r2108100 = re;
        double r2108101 = -1.1817931832138217e+151;
        bool r2108102 = r2108100 <= r2108101;
        double r2108103 = 0.5;
        double r2108104 = 10.0;
        double r2108105 = log(r2108104);
        double r2108106 = sqrt(r2108105);
        double r2108107 = r2108103 / r2108106;
        double r2108108 = -2.0;
        double r2108109 = -1.0;
        double r2108110 = r2108109 / r2108100;
        double r2108111 = log(r2108110);
        double r2108112 = r2108108 * r2108111;
        double r2108113 = r2108107 * r2108112;
        double r2108114 = 1.0;
        double r2108115 = r2108114 / r2108106;
        double r2108116 = r2108113 * r2108115;
        double r2108117 = 7.392440833541334e+126;
        bool r2108118 = r2108100 <= r2108117;
        double r2108119 = r2108100 * r2108100;
        double r2108120 = im;
        double r2108121 = r2108120 * r2108120;
        double r2108122 = r2108119 + r2108121;
        double r2108123 = log(r2108122);
        double r2108124 = r2108107 * r2108123;
        double r2108125 = r2108124 * r2108115;
        double r2108126 = log(r2108100);
        double r2108127 = r2108114 / r2108105;
        double r2108128 = sqrt(r2108127);
        double r2108129 = r2108126 * r2108128;
        double r2108130 = r2108129 * r2108115;
        double r2108131 = r2108118 ? r2108125 : r2108130;
        double r2108132 = r2108102 ? r2108116 : r2108131;
        return r2108132;
}

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.1817931832138217e+151

    1. Initial program 63.1

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt63.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/263.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-pow63.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-frac63.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-inv63.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. Applied associate-*r*63.1

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

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

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

    if -1.1817931832138217e+151 < re < 7.392440833541334e+126

    1. Initial program 21.1

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

      \[\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-inv20.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. Applied associate-*r*20.9

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

    if 7.392440833541334e+126 < re

    1. Initial program 56.5

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt56.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/256.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-pow56.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-frac56.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 div-inv56.5

      \[\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. Applied associate-*r*56.5

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

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

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

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

Reproduce

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