Average Error: 31.7 → 17.4
Time: 5.6s
Precision: binary64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\begin{array}{l} \mathbf{if}\;re \leq -1.2212465663556388 \cdot 10^{+84}:\\ \;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \left(\left(\log 1 + \log \left(\frac{-1}{re}\right) \cdot -2\right) \cdot \sqrt{\frac{1}{\log 10}}\right)\\ \mathbf{elif}\;re \leq -1.1094194130263304 \cdot 10^{-267}:\\ \;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\\ \mathbf{elif}\;re \leq 7.114272991027333 \cdot 10^{-197}:\\ \;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \left(\sqrt{\frac{1}{\log 10}} \cdot \left(\log 1 + 2 \cdot \log im\right)\right)\\ \mathbf{elif}\;re \leq 4.636459646981212 \cdot 10^{+35}:\\ \;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5} \cdot \frac{\sqrt{0.5}}{\frac{\log 10}{\log 1 + 2 \cdot \log re}}\\ \end{array}\]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}
\begin{array}{l}
\mathbf{if}\;re \leq -1.2212465663556388 \cdot 10^{+84}:\\
\;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \left(\left(\log 1 + \log \left(\frac{-1}{re}\right) \cdot -2\right) \cdot \sqrt{\frac{1}{\log 10}}\right)\\

\mathbf{elif}\;re \leq -1.1094194130263304 \cdot 10^{-267}:\\
\;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\\

\mathbf{elif}\;re \leq 7.114272991027333 \cdot 10^{-197}:\\
\;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \left(\sqrt{\frac{1}{\log 10}} \cdot \left(\log 1 + 2 \cdot \log im\right)\right)\\

\mathbf{elif}\;re \leq 4.636459646981212 \cdot 10^{+35}:\\
\;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\\

\mathbf{else}:\\
\;\;\;\;\sqrt{0.5} \cdot \frac{\sqrt{0.5}}{\frac{\log 10}{\log 1 + 2 \cdot \log re}}\\

\end{array}
double code(double re, double im) {
	return (((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.2212465663556388e+84)) {
		VAR = ((double) ((0.5 / ((double) sqrt(((double) log(10.0))))) * ((double) (((double) (((double) log(1.0)) + ((double) (((double) log((-1.0 / re))) * -2.0)))) * ((double) sqrt((1.0 / ((double) log(10.0)))))))));
	} else {
		double VAR_1;
		if ((re <= -1.1094194130263304e-267)) {
			VAR_1 = ((double) ((0.5 / ((double) sqrt(((double) log(10.0))))) * ((double) log(((double) pow(((double) (((double) (re * re)) + ((double) (im * im)))), (1.0 / ((double) sqrt(((double) log(10.0)))))))))));
		} else {
			double VAR_2;
			if ((re <= 7.114272991027333e-197)) {
				VAR_2 = ((double) ((0.5 / ((double) sqrt(((double) log(10.0))))) * ((double) (((double) sqrt((1.0 / ((double) log(10.0))))) * ((double) (((double) log(1.0)) + ((double) (2.0 * ((double) log(im))))))))));
			} else {
				double VAR_3;
				if ((re <= 4.636459646981212e+35)) {
					VAR_3 = ((double) ((0.5 / ((double) sqrt(((double) log(10.0))))) * ((double) log(((double) pow(((double) (((double) (re * re)) + ((double) (im * im)))), (1.0 / ((double) sqrt(((double) log(10.0)))))))))));
				} else {
					VAR_3 = ((double) (((double) sqrt(0.5)) * (((double) sqrt(0.5)) / (((double) log(10.0)) / ((double) (((double) log(1.0)) + ((double) (2.0 * ((double) log(re))))))))));
				}
				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.22124656635563882e84

    1. Initial program 48.8

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt48.8

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\color{blue}{\sqrt{\log 10} \cdot \sqrt{\log 10}}}\]
    4. Applied pow1/248.8

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

      \[\leadsto \frac{\color{blue}{0.5 \cdot \log \left(re \cdot re + im \cdot im\right)}}{\sqrt{\log 10} \cdot \sqrt{\log 10}}\]
    6. Applied times-frac48.7

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

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

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

    if -1.22124656635563882e84 < re < -1.1094194130263304e-267 or 7.11427299102733342e-197 < re < 4.6364596469812118e35

    1. Initial program 19.4

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt19.4

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\color{blue}{\sqrt{\log 10} \cdot \sqrt{\log 10}}}\]
    4. Applied pow1/219.4

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

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

      \[\leadsto \color{blue}{\frac{0.5}{\sqrt{\log 10}} \cdot \frac{\log \left(re \cdot re + im \cdot im\right)}{\sqrt{\log 10}}}\]
    7. Using strategy rm
    8. Applied add-log-exp19.4

      \[\leadsto \frac{0.5}{\sqrt{\log 10}} \cdot \color{blue}{\log \left(e^{\frac{\log \left(re \cdot re + im \cdot im\right)}{\sqrt{\log 10}}}\right)}\]
    9. Simplified19.2

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

    if -1.1094194130263304e-267 < re < 7.11427299102733342e-197

    1. Initial program 30.4

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt30.4

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\color{blue}{\sqrt{\log 10} \cdot \sqrt{\log 10}}}\]
    4. Applied pow1/230.4

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

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

      \[\leadsto \color{blue}{\frac{0.5}{\sqrt{\log 10}} \cdot \frac{\log \left(re \cdot re + im \cdot im\right)}{\sqrt{\log 10}}}\]
    7. Taylor expanded around 0 32.8

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

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

    if 4.6364596469812118e35 < re

    1. Initial program 44.2

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt44.2

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\color{blue}{\sqrt{\log 10} \cdot \sqrt{\log 10}}}\]
    4. Applied pow1/244.2

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

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

      \[\leadsto \color{blue}{\frac{0.5}{\sqrt{\log 10}} \cdot \frac{\log \left(re \cdot re + im \cdot im\right)}{\sqrt{\log 10}}}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity44.2

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

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

      \[\leadsto \color{blue}{\left(\frac{\sqrt{0.5}}{1} \cdot \frac{\sqrt{0.5}}{\sqrt{\log 10}}\right)} \cdot \frac{\log \left(re \cdot re + im \cdot im\right)}{\sqrt{\log 10}}\]
    11. Applied associate-*l*44.1

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -1.2212465663556388 \cdot 10^{+84}:\\ \;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \left(\left(\log 1 + \log \left(\frac{-1}{re}\right) \cdot -2\right) \cdot \sqrt{\frac{1}{\log 10}}\right)\\ \mathbf{elif}\;re \leq -1.1094194130263304 \cdot 10^{-267}:\\ \;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\\ \mathbf{elif}\;re \leq 7.114272991027333 \cdot 10^{-197}:\\ \;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \left(\sqrt{\frac{1}{\log 10}} \cdot \left(\log 1 + 2 \cdot \log im\right)\right)\\ \mathbf{elif}\;re \leq 4.636459646981212 \cdot 10^{+35}:\\ \;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5} \cdot \frac{\sqrt{0.5}}{\frac{\log 10}{\log 1 + 2 \cdot \log re}}\\ \end{array}\]

Reproduce

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