Average Error: 32.4 → 17.6
Time: 6.5s
Precision: binary64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\begin{array}{l} \mathbf{if}\;re \leq -1.1762247444222311 \cdot 10^{+151}:\\ \;\;\;\;\frac{\sqrt{0.5}}{\sqrt{\log 10}} \cdot \left(\frac{\sqrt{0.5}}{\sqrt{\log 10}} \cdot \left(\log \left(\frac{-1}{re}\right) \cdot -2\right)\right)\\ \mathbf{elif}\;re \leq 1.3781415203379638 \cdot 10^{-202}:\\ \;\;\;\;\frac{\sqrt{0.5}}{\sqrt{\log 10}} \cdot \left(\frac{\sqrt{0.5}}{\sqrt{\log 10}} \cdot \log \left(re \cdot re + im \cdot im\right)\right)\\ \mathbf{elif}\;re \leq 1.1082609750789312 \cdot 10^{-166} \lor \neg \left(re \leq 1.4551030635736294 \cdot 10^{+82}\right):\\ \;\;\;\;\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}}\\ \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}}{\log \left(re \cdot re + im \cdot im\right)}}\\ \end{array}\]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}
\begin{array}{l}
\mathbf{if}\;re \leq -1.1762247444222311 \cdot 10^{+151}:\\
\;\;\;\;\frac{\sqrt{0.5}}{\sqrt{\log 10}} \cdot \left(\frac{\sqrt{0.5}}{\sqrt{\log 10}} \cdot \left(\log \left(\frac{-1}{re}\right) \cdot -2\right)\right)\\

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

\mathbf{elif}\;re \leq 1.1082609750789312 \cdot 10^{-166} \lor \neg \left(re \leq 1.4551030635736294 \cdot 10^{+82}\right):\\
\;\;\;\;\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}}\\

\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}}{\log \left(re \cdot re + im \cdot im\right)}}\\

\end{array}
(FPCore (re im)
 :precision binary64
 (/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))
(FPCore (re im)
 :precision binary64
 (if (<= re -1.1762247444222311e+151)
   (*
    (/ (sqrt 0.5) (sqrt (log 10.0)))
    (* (/ (sqrt 0.5) (sqrt (log 10.0))) (* (log (/ -1.0 re)) -2.0)))
   (if (<= re 1.3781415203379638e-202)
     (*
      (/ (sqrt 0.5) (sqrt (log 10.0)))
      (* (/ (sqrt 0.5) (sqrt (log 10.0))) (log (+ (* re re) (* im im)))))
     (if (or (<= re 1.1082609750789312e-166)
             (not (<= re 1.4551030635736294e+82)))
       (*
        (/ (* (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)))))
       (*
        (/ (* (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))))))))))
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 <= -1.1762247444222311e+151) {
		tmp = (sqrt(0.5) / sqrt(log(10.0))) * ((sqrt(0.5) / sqrt(log(10.0))) * (log(-1.0 / re) * -2.0));
	} else if (re <= 1.3781415203379638e-202) {
		tmp = (sqrt(0.5) / sqrt(log(10.0))) * ((sqrt(0.5) / sqrt(log(10.0))) * log((re * re) + (im * im)));
	} else if ((re <= 1.1082609750789312e-166) || !(re <= 1.4551030635736294e+82)) {
		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))));
	} else {
		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))));
	}
	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 4 regimes
  2. if re < -1.17622474442223108e151

    1. Initial program 63.2

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

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

      \[\leadsto \frac{\color{blue}{0.5 \cdot \log \left(re \cdot re + im \cdot im\right)}}{\log 10}\]
    5. Applied associate-/l*_binary64_69863.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_binary64_80963.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_binary64_83763.2

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

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

      \[\leadsto \frac{0.5}{\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-sqrt_binary64_77263.2

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

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

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

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

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

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

    if -1.17622474442223108e151 < re < 1.37814152033796385e-202

    1. Initial program 22.9

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

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

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

      \[\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_binary64_80922.9

      \[\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_binary64_83722.9

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

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

      \[\leadsto \frac{0.5}{\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-sqrt_binary64_77222.9

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

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

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

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

    if 1.37814152033796385e-202 < re < 1.1082609750789312e-166 or 1.4551030635736294e82 < re

    1. Initial program 47.1

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.1082609750789312e-166 < re < 1.4551030635736294e82

    1. Initial program 16.3

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

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

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

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

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

      \[\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_binary64_78316.9

      \[\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_binary64_75716.9

      \[\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_binary64_78316.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_binary64_75716.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. Simplified16.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)}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification17.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -1.1762247444222311 \cdot 10^{+151}:\\ \;\;\;\;\frac{\sqrt{0.5}}{\sqrt{\log 10}} \cdot \left(\frac{\sqrt{0.5}}{\sqrt{\log 10}} \cdot \left(\log \left(\frac{-1}{re}\right) \cdot -2\right)\right)\\ \mathbf{elif}\;re \leq 1.3781415203379638 \cdot 10^{-202}:\\ \;\;\;\;\frac{\sqrt{0.5}}{\sqrt{\log 10}} \cdot \left(\frac{\sqrt{0.5}}{\sqrt{\log 10}} \cdot \log \left(re \cdot re + im \cdot im\right)\right)\\ \mathbf{elif}\;re \leq 1.1082609750789312 \cdot 10^{-166} \lor \neg \left(re \leq 1.4551030635736294 \cdot 10^{+82}\right):\\ \;\;\;\;\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}}\\ \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}}{\log \left(re \cdot re + im \cdot im\right)}}\\ \end{array}\]

Reproduce

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