Average Error: 31.9 → 18.3
Time: 8.0s
Precision: binary64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\begin{array}{l} \mathbf{if}\;re \le -1.6998950373020774 \cdot 10^{87}:\\ \;\;\;\;\sqrt{\frac{1}{2}} \cdot \frac{\left(\log 1 - 2 \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \sqrt{\frac{1}{2}}}{\log 10}\\ \mathbf{elif}\;re \le -1.1243171280702968 \cdot 10^{-257}:\\ \;\;\;\;\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{elif}\;re \le 2.4669184868707975 \cdot 10^{-173}:\\ \;\;\;\;\frac{\sqrt{\frac{1}{2}}}{\sqrt{\log 10}} \cdot \frac{\sqrt{\frac{1}{2}}}{\frac{\sqrt{\log 10}}{\log 1 + 2 \cdot \log im}}\\ \mathbf{elif}\;re \le 9.355465747616013 \cdot 10^{131}:\\ \;\;\;\;\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}:\\ \;\;\;\;\sqrt{\frac{1}{2}} \cdot \frac{\left(\log 1 - 2 \cdot \log \left(\frac{1}{re}\right)\right) \cdot \sqrt{\frac{1}{2}}}{\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.6998950373020774 \cdot 10^{87}:\\
\;\;\;\;\sqrt{\frac{1}{2}} \cdot \frac{\left(\log 1 - 2 \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \sqrt{\frac{1}{2}}}{\log 10}\\

\mathbf{elif}\;re \le -1.1243171280702968 \cdot 10^{-257}:\\
\;\;\;\;\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{elif}\;re \le 2.4669184868707975 \cdot 10^{-173}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{2}}}{\sqrt{\log 10}} \cdot \frac{\sqrt{\frac{1}{2}}}{\frac{\sqrt{\log 10}}{\log 1 + 2 \cdot \log im}}\\

\mathbf{elif}\;re \le 9.355465747616013 \cdot 10^{131}:\\
\;\;\;\;\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}:\\
\;\;\;\;\sqrt{\frac{1}{2}} \cdot \frac{\left(\log 1 - 2 \cdot \log \left(\frac{1}{re}\right)\right) \cdot \sqrt{\frac{1}{2}}}{\log 10}\\

\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.6998950373020774e+87)) {
		VAR = ((double) (((double) sqrt(0.5)) * ((double) (((double) (((double) (((double) log(1.0)) - ((double) (2.0 * ((double) log(((double) (-1.0 / re)))))))) * ((double) sqrt(0.5)))) / ((double) log(10.0))))));
	} else {
		double VAR_1;
		if ((re <= -1.1243171280702968e-257)) {
			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 {
			double VAR_2;
			if ((re <= 2.4669184868707975e-173)) {
				VAR_2 = ((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(im))))))))))));
			} else {
				double VAR_3;
				if ((re <= 9.355465747616013e+131)) {
					VAR_3 = ((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_3 = ((double) (((double) sqrt(0.5)) * ((double) (((double) (((double) (((double) log(1.0)) - ((double) (2.0 * ((double) log(((double) (1.0 / re)))))))) * ((double) sqrt(0.5)))) / ((double) log(10.0))))));
				}
				VAR_2 = VAR_3;
			}
			VAR_1 = VAR_2;
		}
		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 4 regimes
  2. if re < -1.6998950373020774e87

    1. Initial program 49.0

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \log \left(re \cdot re + im \cdot im\right)}}{\log 10}\]
    5. Applied associate-/l*49.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 pow149.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-pow49.0

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

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

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

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

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

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

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

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

    if -1.6998950373020774e87 < re < -1.1243171280702968e-257 or 2.4669184868707975e-173 < re < 9.355465747616013e131

    1. Initial program 19.6

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

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

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

      \[\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 pow119.6

      \[\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-pow19.6

      \[\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-sqrt19.6

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

      \[\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-sqrt19.6

      \[\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-frac19.5

      \[\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. Simplified19.5

      \[\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.1243171280702968e-257 < re < 2.4669184868707975e-173

    1. Initial program 31.5

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

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

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

      \[\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 pow131.5

      \[\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-pow31.5

      \[\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-sqrt31.5

      \[\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-frac31.6

      \[\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-sqrt31.5

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

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

      \[\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 0 34.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 im}}}\]

    if 9.355465747616013e131 < re

    1. Initial program 58.0

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -1.6998950373020774 \cdot 10^{87}:\\ \;\;\;\;\sqrt{\frac{1}{2}} \cdot \frac{\left(\log 1 - 2 \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \sqrt{\frac{1}{2}}}{\log 10}\\ \mathbf{elif}\;re \le -1.1243171280702968 \cdot 10^{-257}:\\ \;\;\;\;\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{elif}\;re \le 2.4669184868707975 \cdot 10^{-173}:\\ \;\;\;\;\frac{\sqrt{\frac{1}{2}}}{\sqrt{\log 10}} \cdot \frac{\sqrt{\frac{1}{2}}}{\frac{\sqrt{\log 10}}{\log 1 + 2 \cdot \log im}}\\ \mathbf{elif}\;re \le 9.355465747616013 \cdot 10^{131}:\\ \;\;\;\;\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}:\\ \;\;\;\;\sqrt{\frac{1}{2}} \cdot \frac{\left(\log 1 - 2 \cdot \log \left(\frac{1}{re}\right)\right) \cdot \sqrt{\frac{1}{2}}}{\log 10}\\ \end{array}\]

Reproduce

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