Average Error: 31.5 → 17.5
Time: 7.9s
Precision: 64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\begin{array}{l} \mathbf{if}\;re \le -4.12234854353282129 \cdot 10^{83}:\\ \;\;\;\;\frac{\sqrt{\frac{1}{2}}}{\sqrt{\log 10}} \cdot \left(-2 \cdot \left(\left(\log \left(\frac{-1}{re}\right) \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{\frac{1}{\log 10}}\right)\right)\\ \mathbf{elif}\;re \le 9.92580502184387772 \cdot 10^{51}:\\ \;\;\;\;\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{\sqrt{\log 10}}{\log re \cdot 2}}\\ \end{array}\]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}
\begin{array}{l}
\mathbf{if}\;re \le -4.12234854353282129 \cdot 10^{83}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{2}}}{\sqrt{\log 10}} \cdot \left(-2 \cdot \left(\left(\log \left(\frac{-1}{re}\right) \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{\frac{1}{\log 10}}\right)\right)\\

\mathbf{elif}\;re \le 9.92580502184387772 \cdot 10^{51}:\\
\;\;\;\;\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{\sqrt{\log 10}}{\log re \cdot 2}}\\

\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 <= -4.1223485435328213e+83)) {
		VAR = ((double) (((double) (((double) sqrt(0.5)) / ((double) sqrt(((double) log(10.0)))))) * ((double) (-2.0 * ((double) (((double) (((double) log(((double) (-1.0 / re)))) * ((double) sqrt(0.5)))) * ((double) sqrt(((double) (1.0 / ((double) log(10.0))))))))))));
	} else {
		double VAR_1;
		if ((re <= 9.925805021843878e+51)) {
			VAR_1 = ((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_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) (((double) log(re)) * 2.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 < -4.1223485435328213e+83

    1. Initial program 48.5

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \log \left(re \cdot re + im \cdot im\right)}}{\log 10}\]
    5. Applied associate-/l*48.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 pow148.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-pow48.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-sqrt48.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-frac48.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-sqrt48.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-frac48.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. Simplified48.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.9

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

    if -4.1223485435328213e+83 < re < 9.925805021843878e+51

    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 add-sqr-sqrt22.2

      \[\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*22.0

      \[\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 9.925805021843878e+51 < re

    1. Initial program 44.7

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

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

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

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

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

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

      \[\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-frac44.8

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -4.12234854353282129 \cdot 10^{83}:\\ \;\;\;\;\frac{\sqrt{\frac{1}{2}}}{\sqrt{\log 10}} \cdot \left(-2 \cdot \left(\left(\log \left(\frac{-1}{re}\right) \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{\frac{1}{\log 10}}\right)\right)\\ \mathbf{elif}\;re \le 9.92580502184387772 \cdot 10^{51}:\\ \;\;\;\;\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{\sqrt{\log 10}}{\log re \cdot 2}}\\ \end{array}\]

Reproduce

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