Average Error: 32.3 → 17.9
Time: 6.9s
Precision: binary64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\begin{array}{l} \mathbf{if}\;re \le -1.659310464645964 \cdot 10^{110}:\\ \;\;\;\;\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 -2.64169877549371407 \cdot 10^{-245}:\\ \;\;\;\;\sqrt{\frac{1}{2}} \cdot \frac{\sqrt{\frac{1}{2}}}{\frac{\log 10}{\log \left(re \cdot re + im \cdot im\right)}}\\ \mathbf{elif}\;re \le 1.0744771963851055 \cdot 10^{-190}:\\ \;\;\;\;\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 2.0069927548790835 \cdot 10^{84}:\\ \;\;\;\;\frac{\sqrt{\frac{1}{2}}}{\frac{\frac{\log 10}{\log \left(re \cdot re + im \cdot im\right)}}{\sqrt{\frac{1}{2}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\frac{1}{2}}}{\sqrt{\log 10}} \cdot \frac{\sqrt{\frac{1}{2}}}{\frac{1}{\log 1 - 2 \cdot \log \left(\frac{1}{re}\right)} \cdot \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.659310464645964 \cdot 10^{110}:\\
\;\;\;\;\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 -2.64169877549371407 \cdot 10^{-245}:\\
\;\;\;\;\sqrt{\frac{1}{2}} \cdot \frac{\sqrt{\frac{1}{2}}}{\frac{\log 10}{\log \left(re \cdot re + im \cdot im\right)}}\\

\mathbf{elif}\;re \le 1.0744771963851055 \cdot 10^{-190}:\\
\;\;\;\;\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 2.0069927548790835 \cdot 10^{84}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{2}}}{\frac{\frac{\log 10}{\log \left(re \cdot re + im \cdot im\right)}}{\sqrt{\frac{1}{2}}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{2}}}{\sqrt{\log 10}} \cdot \frac{\sqrt{\frac{1}{2}}}{\frac{1}{\log 1 - 2 \cdot \log \left(\frac{1}{re}\right)} \cdot \sqrt{\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.659310464645964e+110)) {
		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 <= -2.641698775493714e-245)) {
			VAR_1 = ((double) (((double) sqrt(0.5)) * ((double) (((double) sqrt(0.5)) / ((double) (((double) log(10.0)) / ((double) log(((double) (((double) (re * re)) + ((double) (im * im))))))))))));
		} else {
			double VAR_2;
			if ((re <= 1.0744771963851055e-190)) {
				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 <= 2.0069927548790835e+84)) {
					VAR_3 = ((double) (((double) sqrt(0.5)) / ((double) (((double) (((double) log(10.0)) / ((double) log(((double) (((double) (re * re)) + ((double) (im * im)))))))) / ((double) sqrt(0.5))))));
				} else {
					VAR_3 = ((double) (((double) (((double) sqrt(0.5)) / ((double) sqrt(((double) log(10.0)))))) * ((double) (((double) sqrt(0.5)) / ((double) (((double) (1.0 / ((double) (((double) log(1.0)) - ((double) (2.0 * ((double) log(((double) (1.0 / re)))))))))) * ((double) sqrt(((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 5 regimes
  2. if re < -1.659310464645964e110

    1. Initial program 53.6

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \log \left(re \cdot re + im \cdot im\right)}}{\log 10}\]
    5. Applied associate-/l*53.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 pow153.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-pow53.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-sqrt53.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-frac53.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-sqrt53.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-frac53.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. Simplified53.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)}}\]
    14. Taylor expanded around -inf 9.1

      \[\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.659310464645964e110 < re < -2.64169877549371407e-245

    1. Initial program 20.2

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

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

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

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

      \[\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-pow20.3

      \[\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-frac20.3

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

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

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

      \[\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)}}\]

    if -2.64169877549371407e-245 < re < 1.0744771963851055e-190

    1. Initial program 33.1

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \log \left(re \cdot re + im \cdot im\right)}}{\log 10}\]
    5. Applied associate-/l*33.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 pow133.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-pow33.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-sqrt33.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-frac33.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-sqrt33.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-frac33.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. Simplified33.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 0 34.5

      \[\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 1.0744771963851055e-190 < re < 2.0069927548790835e84

    1. Initial program 17.5

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

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

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

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

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

    if 2.0069927548790835e84 < re

    1. Initial program 49.3

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

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

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

      \[\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. Simplified49.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -1.659310464645964 \cdot 10^{110}:\\ \;\;\;\;\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 -2.64169877549371407 \cdot 10^{-245}:\\ \;\;\;\;\sqrt{\frac{1}{2}} \cdot \frac{\sqrt{\frac{1}{2}}}{\frac{\log 10}{\log \left(re \cdot re + im \cdot im\right)}}\\ \mathbf{elif}\;re \le 1.0744771963851055 \cdot 10^{-190}:\\ \;\;\;\;\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 2.0069927548790835 \cdot 10^{84}:\\ \;\;\;\;\frac{\sqrt{\frac{1}{2}}}{\frac{\frac{\log 10}{\log \left(re \cdot re + im \cdot im\right)}}{\sqrt{\frac{1}{2}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\frac{1}{2}}}{\sqrt{\log 10}} \cdot \frac{\sqrt{\frac{1}{2}}}{\frac{1}{\log 1 - 2 \cdot \log \left(\frac{1}{re}\right)} \cdot \sqrt{\log 10}}\\ \end{array}\]

Reproduce

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