Average Error: 32.1 → 18.5
Time: 6.0s
Precision: binary64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\begin{array}{l} \mathbf{if}\;re \le -1.05653654456576854 \cdot 10^{139}:\\ \;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\left(\log 1 + \log \left(\frac{-1}{re}\right) \cdot -2\right) \cdot \sqrt{\frac{1}{\log 10}}\right)}\right)\\ \mathbf{elif}\;re \le -8.39501769279737873 \cdot 10^{-165}:\\ \;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\right)}\right)\\ \mathbf{elif}\;re \le -2.5556997558112552 \cdot 10^{-228}:\\ \;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\left(\log 1 + \log \left(\frac{-1}{re}\right) \cdot -2\right) \cdot \sqrt{\frac{1}{\log 10}}\right)}\right)\\ \mathbf{elif}\;re \le -8.98923595946216538 \cdot 10^{-268}:\\ \;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\right)}\right)\\ \mathbf{elif}\;re \le -3.26209764193497202 \cdot 10^{-305}:\\ \;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\sqrt{\frac{1}{\log 10}} \cdot \left(\log 1 + 2 \cdot \log im\right)\right)}\right)\\ \mathbf{elif}\;re \le 1.0407504367576015 \cdot 10^{92}:\\ \;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\sqrt{\frac{1}{\log 10}} \cdot \left(\log 1 + 2 \cdot \log re\right)\right)}\right)\\ \end{array}\]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}
\begin{array}{l}
\mathbf{if}\;re \le -1.05653654456576854 \cdot 10^{139}:\\
\;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\left(\log 1 + \log \left(\frac{-1}{re}\right) \cdot -2\right) \cdot \sqrt{\frac{1}{\log 10}}\right)}\right)\\

\mathbf{elif}\;re \le -8.39501769279737873 \cdot 10^{-165}:\\
\;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\right)}\right)\\

\mathbf{elif}\;re \le -2.5556997558112552 \cdot 10^{-228}:\\
\;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\left(\log 1 + \log \left(\frac{-1}{re}\right) \cdot -2\right) \cdot \sqrt{\frac{1}{\log 10}}\right)}\right)\\

\mathbf{elif}\;re \le -8.98923595946216538 \cdot 10^{-268}:\\
\;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\right)}\right)\\

\mathbf{elif}\;re \le -3.26209764193497202 \cdot 10^{-305}:\\
\;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\sqrt{\frac{1}{\log 10}} \cdot \left(\log 1 + 2 \cdot \log im\right)\right)}\right)\\

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

\mathbf{else}:\\
\;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\sqrt{\frac{1}{\log 10}} \cdot \left(\log 1 + 2 \cdot \log re\right)\right)}\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.0565365445657685e+139)) {
		VAR = ((double) log(((double) pow(((double) exp(((double) (0.5 / ((double) sqrt(((double) log(10.0)))))))), ((double) (((double) (((double) log(1.0)) + ((double) (((double) log(((double) (-1.0 / re)))) * -2.0)))) * ((double) sqrt(((double) (1.0 / ((double) log(10.0))))))))))));
	} else {
		double VAR_1;
		if ((re <= -8.395017692797379e-165)) {
			VAR_1 = ((double) log(((double) pow(((double) exp(((double) (0.5 / ((double) sqrt(((double) log(10.0)))))))), ((double) log(((double) pow(((double) (((double) (re * re)) + ((double) (im * im)))), ((double) (1.0 / ((double) sqrt(((double) log(10.0))))))))))))));
		} else {
			double VAR_2;
			if ((re <= -2.5556997558112552e-228)) {
				VAR_2 = ((double) log(((double) pow(((double) exp(((double) (0.5 / ((double) sqrt(((double) log(10.0)))))))), ((double) (((double) (((double) log(1.0)) + ((double) (((double) log(((double) (-1.0 / re)))) * -2.0)))) * ((double) sqrt(((double) (1.0 / ((double) log(10.0))))))))))));
			} else {
				double VAR_3;
				if ((re <= -8.989235959462165e-268)) {
					VAR_3 = ((double) log(((double) pow(((double) exp(((double) (0.5 / ((double) sqrt(((double) log(10.0)))))))), ((double) log(((double) pow(((double) (((double) (re * re)) + ((double) (im * im)))), ((double) (1.0 / ((double) sqrt(((double) log(10.0))))))))))))));
				} else {
					double VAR_4;
					if ((re <= -3.262097641934972e-305)) {
						VAR_4 = ((double) log(((double) pow(((double) exp(((double) (0.5 / ((double) sqrt(((double) log(10.0)))))))), ((double) (((double) sqrt(((double) (1.0 / ((double) log(10.0)))))) * ((double) (((double) log(1.0)) + ((double) (2.0 * ((double) log(im))))))))))));
					} else {
						double VAR_5;
						if ((re <= 1.0407504367576015e+92)) {
							VAR_5 = ((double) log(((double) pow(((double) exp(((double) (0.5 / ((double) sqrt(((double) log(10.0)))))))), ((double) log(((double) pow(((double) (((double) (re * re)) + ((double) (im * im)))), ((double) (1.0 / ((double) sqrt(((double) log(10.0))))))))))))));
						} else {
							VAR_5 = ((double) log(((double) pow(((double) exp(((double) (0.5 / ((double) sqrt(((double) log(10.0)))))))), ((double) (((double) sqrt(((double) (1.0 / ((double) log(10.0)))))) * ((double) (((double) log(1.0)) + ((double) (2.0 * ((double) log(re))))))))))));
						}
						VAR_4 = VAR_5;
					}
					VAR_3 = VAR_4;
				}
				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.05653654456576854e139 or -8.39501769279737873e-165 < re < -2.5556997558112552e-228

    1. Initial program 52.4

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

      \[\leadsto \color{blue}{\log \left(e^{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}}\right)}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt52.4

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

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

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

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

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

      \[\leadsto \log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\color{blue}{\left(\left(\log 1 - 2 \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \sqrt{\frac{1}{\log 10}}\right)}}\right)\]
    11. Simplified18.8

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

    if -1.05653654456576854e139 < re < -8.39501769279737873e-165 or -2.5556997558112552e-228 < re < -8.98923595946216538e-268 or -3.26209764193497202e-305 < re < 1.0407504367576015e92

    1. Initial program 20.4

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

      \[\leadsto \color{blue}{\log \left(e^{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}}\right)}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt20.4

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

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

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

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

      \[\leadsto \log \color{blue}{\left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\frac{\log \left(re \cdot re + im \cdot im\right)}{\sqrt{\log 10}}\right)}\right)}\]
    10. Using strategy rm
    11. Applied add-log-exp20.2

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

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

    if -8.98923595946216538e-268 < re < -3.26209764193497202e-305

    1. Initial program 31.9

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

      \[\leadsto \color{blue}{\log \left(e^{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}}\right)}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt31.9

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

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

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

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

      \[\leadsto \log \color{blue}{\left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\frac{\log \left(re \cdot re + im \cdot im\right)}{\sqrt{\log 10}}\right)}\right)}\]
    10. Taylor expanded around 0 33.3

      \[\leadsto \log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\color{blue}{\left(\sqrt{\frac{1}{\log 10}} \cdot \left(\log 1 + 2 \cdot \log im\right)\right)}}\right)\]
    11. Simplified33.3

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

    if 1.0407504367576015e92 < re

    1. Initial program 51.0

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

      \[\leadsto \color{blue}{\log \left(e^{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}}\right)}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt51.0

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

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

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

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

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

      \[\leadsto \log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\color{blue}{\left(\left(\log 1 - 2 \cdot \log \left(\frac{1}{re}\right)\right) \cdot \sqrt{\frac{1}{\log 10}}\right)}}\right)\]
    11. Simplified10.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -1.05653654456576854 \cdot 10^{139}:\\ \;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\left(\log 1 + \log \left(\frac{-1}{re}\right) \cdot -2\right) \cdot \sqrt{\frac{1}{\log 10}}\right)}\right)\\ \mathbf{elif}\;re \le -8.39501769279737873 \cdot 10^{-165}:\\ \;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\right)}\right)\\ \mathbf{elif}\;re \le -2.5556997558112552 \cdot 10^{-228}:\\ \;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\left(\log 1 + \log \left(\frac{-1}{re}\right) \cdot -2\right) \cdot \sqrt{\frac{1}{\log 10}}\right)}\right)\\ \mathbf{elif}\;re \le -8.98923595946216538 \cdot 10^{-268}:\\ \;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\right)}\right)\\ \mathbf{elif}\;re \le -3.26209764193497202 \cdot 10^{-305}:\\ \;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\sqrt{\frac{1}{\log 10}} \cdot \left(\log 1 + 2 \cdot \log im\right)\right)}\right)\\ \mathbf{elif}\;re \le 1.0407504367576015 \cdot 10^{92}:\\ \;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left({\left(e^{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)}^{\left(\sqrt{\frac{1}{\log 10}} \cdot \left(\log 1 + 2 \cdot \log re\right)\right)}\right)\\ \end{array}\]

Reproduce

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