Average Error: 32.1 → 17.7
Time: 6.6s
Precision: binary64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\begin{array}{l} \mathbf{if}\;re \le -1.05447510547605622 \cdot 10^{115}:\\ \;\;\;\;\frac{\sqrt{\frac{1}{2}}}{\sqrt{\log 10}} \cdot \frac{\sqrt{\frac{1}{2}}}{\frac{\sqrt{\log 10}}{\log 1 - 2 \cdot \log \left(\frac{-1}{re}\right)}}\\ \mathbf{elif}\;re \le 1.20683423310939025 \cdot 10^{29}:\\ \;\;\;\;\frac{\sqrt{\frac{1}{2}}}{\sqrt{\log 10}} \cdot \frac{\sqrt{\frac{1}{2}}}{\frac{\sqrt{\log 10}}{\log \left(re \cdot re + im \cdot im\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\frac{1}{2}}}{\sqrt{\log 10}} \cdot \left(\left(\left(\log 1 - 2 \cdot \log \left(\frac{1}{re}\right)\right) \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{\frac{1}{\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.05447510547605622 \cdot 10^{115}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{2}}}{\sqrt{\log 10}} \cdot \frac{\sqrt{\frac{1}{2}}}{\frac{\sqrt{\log 10}}{\log 1 - 2 \cdot \log \left(\frac{-1}{re}\right)}}\\

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

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

\end{array}
double code(double re, double im) {
	return ((double) (((double) log(((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im)))))))) / ((double) log(10.0))));
}
double code(double re, double im) {
	double VAR;
	if ((re <= -1.0544751054760562e+115)) {
		VAR = ((double) (((double) (((double) sqrt(0.5)) / ((double) sqrt(((double) log(10.0)))))) * ((double) (((double) sqrt(0.5)) / ((double) (((double) sqrt(((double) log(10.0)))) / ((double) (((double) log(1.0)) - ((double) (2.0 * ((double) log(((double) (-1.0 / re))))))))))))));
	} else {
		double VAR_1;
		if ((re <= 1.2068342331093902e+29)) {
			VAR_1 = ((double) (((double) (((double) sqrt(0.5)) / ((double) sqrt(((double) log(10.0)))))) * ((double) (((double) sqrt(0.5)) / ((double) (((double) sqrt(((double) log(10.0)))) / ((double) log(((double) (((double) (re * re)) + ((double) (im * im))))))))))));
		} else {
			VAR_1 = ((double) (((double) (((double) sqrt(0.5)) / ((double) sqrt(((double) log(10.0)))))) * ((double) (((double) (((double) (((double) log(1.0)) - ((double) (2.0 * ((double) log(((double) (1.0 / re)))))))) * ((double) sqrt(0.5)))) * ((double) sqrt(((double) (1.0 / ((double) log(10.0))))))))));
		}
		VAR = VAR_1;
	}
	return VAR;
}

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.05447510547605622e115

    1. Initial program 55.0

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Using strategy rm
    3. Applied pow1/255.0

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

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \log \left(re \cdot re + im \cdot im\right)}}{\log 10}\]
    5. Applied associate-/l*55.0

      \[\leadsto \color{blue}{\frac{\frac{1}{2}}{\frac{\log 10}{\log \left(re \cdot re + im \cdot im\right)}}}\]
    6. Using strategy rm
    7. Applied pow155.0

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

      \[\leadsto \frac{\frac{1}{2}}{\frac{\log 10}{\color{blue}{1 \cdot \log \left(re \cdot re + im \cdot im\right)}}}\]
    9. Applied add-sqr-sqrt55.0

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

      \[\leadsto \frac{\frac{1}{2}}{\color{blue}{\frac{\sqrt{\log 10}}{1} \cdot \frac{\sqrt{\log 10}}{\log \left(re \cdot re + im \cdot im\right)}}}\]
    11. Applied add-sqr-sqrt55.0

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

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

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

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

    if -1.05447510547605622e115 < re < 1.20683423310939025e29

    1. Initial program 22.1

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Using strategy rm
    3. Applied pow1/222.1

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

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \log \left(re \cdot re + im \cdot im\right)}}{\log 10}\]
    5. Applied associate-/l*22.1

      \[\leadsto \color{blue}{\frac{\frac{1}{2}}{\frac{\log 10}{\log \left(re \cdot re + im \cdot im\right)}}}\]
    6. Using strategy rm
    7. Applied pow122.1

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

      \[\leadsto \frac{\frac{1}{2}}{\frac{\log 10}{\color{blue}{1 \cdot \log \left(re \cdot re + im \cdot im\right)}}}\]
    9. Applied add-sqr-sqrt22.1

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

      \[\leadsto \frac{\frac{1}{2}}{\color{blue}{\frac{\sqrt{\log 10}}{1} \cdot \frac{\sqrt{\log 10}}{\log \left(re \cdot re + im \cdot im\right)}}}\]
    11. Applied add-sqr-sqrt22.1

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

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

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

    if 1.20683423310939025e29 < re

    1. Initial program 43.3

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Using strategy rm
    3. Applied pow1/243.3

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

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \log \left(re \cdot re + im \cdot im\right)}}{\log 10}\]
    5. Applied associate-/l*43.3

      \[\leadsto \color{blue}{\frac{\frac{1}{2}}{\frac{\log 10}{\log \left(re \cdot re + im \cdot im\right)}}}\]
    6. Using strategy rm
    7. Applied pow143.3

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

      \[\leadsto \frac{\frac{1}{2}}{\frac{\log 10}{\color{blue}{1 \cdot \log \left(re \cdot re + im \cdot im\right)}}}\]
    9. Applied add-sqr-sqrt43.3

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

      \[\leadsto \frac{\frac{1}{2}}{\color{blue}{\frac{\sqrt{\log 10}}{1} \cdot \frac{\sqrt{\log 10}}{\log \left(re \cdot re + im \cdot im\right)}}}\]
    11. Applied add-sqr-sqrt43.3

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

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

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

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

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

Reproduce

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