Average Error: 32.3 → 17.9
Time: 4.2s
Precision: binary64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\begin{array}{l} \mathbf{if}\;re \leq -2.8311489939222134 \cdot 10^{+74}:\\ \;\;\;\;\frac{0.5}{\frac{\log 10}{\log \left(\frac{-1}{re}\right) \cdot -2}}\\ \mathbf{elif}\;re \leq 3.234431479514519 \cdot 10^{+70}:\\ \;\;\;\;\frac{\sqrt[3]{0.5} \cdot \sqrt[3]{0.5}}{\sqrt[3]{\log 10} \cdot \sqrt[3]{\log 10}} \cdot \frac{\sqrt[3]{0.5}}{\frac{\sqrt[3]{\log 10}}{\log \left(re \cdot re + im \cdot im\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{0.5} \cdot \sqrt[3]{0.5}}{\sqrt[3]{\log 10} \cdot \sqrt[3]{\log 10}} \cdot \frac{\sqrt[3]{0.5}}{\frac{\sqrt[3]{\log 10}}{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 -2.8311489939222134 \cdot 10^{+74}:\\
\;\;\;\;\frac{0.5}{\frac{\log 10}{\log \left(\frac{-1}{re}\right) \cdot -2}}\\

\mathbf{elif}\;re \leq 3.234431479514519 \cdot 10^{+70}:\\
\;\;\;\;\frac{\sqrt[3]{0.5} \cdot \sqrt[3]{0.5}}{\sqrt[3]{\log 10} \cdot \sqrt[3]{\log 10}} \cdot \frac{\sqrt[3]{0.5}}{\frac{\sqrt[3]{\log 10}}{\log \left(re \cdot re + im \cdot im\right)}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{0.5} \cdot \sqrt[3]{0.5}}{\sqrt[3]{\log 10} \cdot \sqrt[3]{\log 10}} \cdot \frac{\sqrt[3]{0.5}}{\frac{\sqrt[3]{\log 10}}{2 \cdot \log re}}\\

\end{array}
(FPCore (re im)
 :precision binary64
 (/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))
(FPCore (re im)
 :precision binary64
 (if (<= re -2.8311489939222134e+74)
   (/ 0.5 (/ (log 10.0) (* (log (/ -1.0 re)) -2.0)))
   (if (<= re 3.234431479514519e+70)
     (*
      (/ (* (cbrt 0.5) (cbrt 0.5)) (* (cbrt (log 10.0)) (cbrt (log 10.0))))
      (/ (cbrt 0.5) (/ (cbrt (log 10.0)) (log (+ (* re re) (* im im))))))
     (*
      (/ (* (cbrt 0.5) (cbrt 0.5)) (* (cbrt (log 10.0)) (cbrt (log 10.0))))
      (/ (cbrt 0.5) (/ (cbrt (log 10.0)) (* 2.0 (log re))))))))
double code(double re, double im) {
	return log(sqrt((re * re) + (im * im))) / log(10.0);
}
double code(double re, double im) {
	double tmp;
	if (re <= -2.8311489939222134e+74) {
		tmp = 0.5 / (log(10.0) / (log(-1.0 / re) * -2.0));
	} else if (re <= 3.234431479514519e+70) {
		tmp = ((cbrt(0.5) * cbrt(0.5)) / (cbrt(log(10.0)) * cbrt(log(10.0)))) * (cbrt(0.5) / (cbrt(log(10.0)) / log((re * re) + (im * im))));
	} else {
		tmp = ((cbrt(0.5) * cbrt(0.5)) / (cbrt(log(10.0)) * cbrt(log(10.0)))) * (cbrt(0.5) / (cbrt(log(10.0)) / (2.0 * log(re))));
	}
	return tmp;
}

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 < -2.83114899392221336e74

    1. Initial program 48.2

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

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

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

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

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

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

    if -2.83114899392221336e74 < re < 3.234431479514519e70

    1. Initial program 22.5

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

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

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

      \[\leadsto \color{blue}{\frac{0.5}{\frac{\log 10}{\log \left(re \cdot re + im \cdot im\right)}}}\]
    6. Using strategy rm
    7. Applied pow1_binary6422.5

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

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

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

      \[\leadsto \frac{0.5}{\color{blue}{\frac{\sqrt[3]{\log 10} \cdot \sqrt[3]{\log 10}}{1} \cdot \frac{\sqrt[3]{\log 10}}{\log \left(re \cdot re + im \cdot im\right)}}}\]
    11. Applied add-cube-cbrt_binary6422.5

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{0.5} \cdot \sqrt[3]{0.5}}{\frac{\sqrt[3]{\log 10} \cdot \sqrt[3]{\log 10}}{1}} \cdot \frac{\sqrt[3]{0.5}}{\frac{\sqrt[3]{\log 10}}{\log \left(re \cdot re + im \cdot im\right)}}}\]
    13. Simplified22.4

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

    if 3.234431479514519e70 < re

    1. Initial program 48.2

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

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

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

      \[\leadsto \color{blue}{\frac{0.5}{\frac{\log 10}{\log \left(re \cdot re + im \cdot im\right)}}}\]
    6. Using strategy rm
    7. Applied pow1_binary6448.2

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

      \[\leadsto \frac{0.5}{\frac{\log 10}{\color{blue}{1 \cdot \log \left(re \cdot re + im \cdot im\right)}}}\]
    9. Applied add-cube-cbrt_binary6448.4

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

      \[\leadsto \frac{0.5}{\color{blue}{\frac{\sqrt[3]{\log 10} \cdot \sqrt[3]{\log 10}}{1} \cdot \frac{\sqrt[3]{\log 10}}{\log \left(re \cdot re + im \cdot im\right)}}}\]
    11. Applied add-cube-cbrt_binary6448.2

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -2.8311489939222134 \cdot 10^{+74}:\\ \;\;\;\;\frac{0.5}{\frac{\log 10}{\log \left(\frac{-1}{re}\right) \cdot -2}}\\ \mathbf{elif}\;re \leq 3.234431479514519 \cdot 10^{+70}:\\ \;\;\;\;\frac{\sqrt[3]{0.5} \cdot \sqrt[3]{0.5}}{\sqrt[3]{\log 10} \cdot \sqrt[3]{\log 10}} \cdot \frac{\sqrt[3]{0.5}}{\frac{\sqrt[3]{\log 10}}{\log \left(re \cdot re + im \cdot im\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{0.5} \cdot \sqrt[3]{0.5}}{\sqrt[3]{\log 10} \cdot \sqrt[3]{\log 10}} \cdot \frac{\sqrt[3]{0.5}}{\frac{\sqrt[3]{\log 10}}{2 \cdot \log re}}\\ \end{array}\]

Reproduce

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