Average Error: 31.6 → 18.8
Time: 23.7s
Precision: binary64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\begin{array}{l} \mathbf{if}\;re \leq -5.192603281076975 \cdot 10^{+93}:\\ \;\;\;\;\sqrt{\frac{1}{\sqrt{\log 10} \cdot 2}} \cdot \left(-2 \cdot \left(\left(\sqrt{0.5} \cdot \log \left(\frac{-1}{re}\right)\right) \cdot {\left(\frac{1}{{\log 10}^{3}}\right)}^{0.25}\right)\right)\\ \mathbf{elif}\;re \leq -2.8031941910929914 \cdot 10^{-216}:\\ \;\;\;\;\frac{1}{\sqrt{\log 10} \cdot 2} \cdot \left(\log \left(re \cdot re + im \cdot im\right) \cdot \frac{1}{\sqrt{\log 10}}\right)\\ \mathbf{elif}\;re \leq 1.906370662006563 \cdot 10^{-105}:\\ \;\;\;\;\frac{1}{\sqrt{\log 10} \cdot 2} \cdot \left(\left(2 \cdot \log im\right) \cdot \sqrt{\frac{1}{\log 10}}\right)\\ \mathbf{elif}\;re \leq 3.164209138874086 \cdot 10^{+97}:\\ \;\;\;\;\frac{1}{\sqrt{\log 10} \cdot 2} \cdot \left(\log \left(re \cdot re + im \cdot im\right) \cdot \frac{1}{\sqrt{\log 10}}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{1}{\sqrt{\log 10} \cdot 2}} \cdot \left(\sqrt{\frac{1}{\sqrt{\log 10} \cdot 2}} \cdot \frac{-2 \cdot \log \left(\frac{1}{re}\right)}{\sqrt{\log 10}}\right)\\ \end{array}\]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}
\begin{array}{l}
\mathbf{if}\;re \leq -5.192603281076975 \cdot 10^{+93}:\\
\;\;\;\;\sqrt{\frac{1}{\sqrt{\log 10} \cdot 2}} \cdot \left(-2 \cdot \left(\left(\sqrt{0.5} \cdot \log \left(\frac{-1}{re}\right)\right) \cdot {\left(\frac{1}{{\log 10}^{3}}\right)}^{0.25}\right)\right)\\

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

\mathbf{elif}\;re \leq 1.906370662006563 \cdot 10^{-105}:\\
\;\;\;\;\frac{1}{\sqrt{\log 10} \cdot 2} \cdot \left(\left(2 \cdot \log im\right) \cdot \sqrt{\frac{1}{\log 10}}\right)\\

\mathbf{elif}\;re \leq 3.164209138874086 \cdot 10^{+97}:\\
\;\;\;\;\frac{1}{\sqrt{\log 10} \cdot 2} \cdot \left(\log \left(re \cdot re + im \cdot im\right) \cdot \frac{1}{\sqrt{\log 10}}\right)\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{1}{\sqrt{\log 10} \cdot 2}} \cdot \left(\sqrt{\frac{1}{\sqrt{\log 10} \cdot 2}} \cdot \frac{-2 \cdot \log \left(\frac{1}{re}\right)}{\sqrt{\log 10}}\right)\\

\end{array}
(FPCore (re im)
 :precision binary64
 (/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))
(FPCore (re im)
 :precision binary64
 (if (<= re -5.192603281076975e+93)
   (*
    (sqrt (/ 1.0 (* (sqrt (log 10.0)) 2.0)))
    (*
     -2.0
     (*
      (* (sqrt 0.5) (log (/ -1.0 re)))
      (pow (/ 1.0 (pow (log 10.0) 3.0)) 0.25))))
   (if (<= re -2.8031941910929914e-216)
     (*
      (/ 1.0 (* (sqrt (log 10.0)) 2.0))
      (* (log (+ (* re re) (* im im))) (/ 1.0 (sqrt (log 10.0)))))
     (if (<= re 1.906370662006563e-105)
       (*
        (/ 1.0 (* (sqrt (log 10.0)) 2.0))
        (* (* 2.0 (log im)) (sqrt (/ 1.0 (log 10.0)))))
       (if (<= re 3.164209138874086e+97)
         (*
          (/ 1.0 (* (sqrt (log 10.0)) 2.0))
          (* (log (+ (* re re) (* im im))) (/ 1.0 (sqrt (log 10.0)))))
         (*
          (sqrt (/ 1.0 (* (sqrt (log 10.0)) 2.0)))
          (*
           (sqrt (/ 1.0 (* (sqrt (log 10.0)) 2.0)))
           (/ (* -2.0 (log (/ 1.0 re))) (sqrt (log 10.0))))))))))
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 <= -5.192603281076975e+93) {
		tmp = sqrt(1.0 / (sqrt(log(10.0)) * 2.0)) * (-2.0 * ((sqrt(0.5) * log(-1.0 / re)) * pow((1.0 / pow(log(10.0), 3.0)), 0.25)));
	} else if (re <= -2.8031941910929914e-216) {
		tmp = (1.0 / (sqrt(log(10.0)) * 2.0)) * (log((re * re) + (im * im)) * (1.0 / sqrt(log(10.0))));
	} else if (re <= 1.906370662006563e-105) {
		tmp = (1.0 / (sqrt(log(10.0)) * 2.0)) * ((2.0 * log(im)) * sqrt(1.0 / log(10.0)));
	} else if (re <= 3.164209138874086e+97) {
		tmp = (1.0 / (sqrt(log(10.0)) * 2.0)) * (log((re * re) + (im * im)) * (1.0 / sqrt(log(10.0))));
	} else {
		tmp = sqrt(1.0 / (sqrt(log(10.0)) * 2.0)) * (sqrt(1.0 / (sqrt(log(10.0)) * 2.0)) * ((-2.0 * log(1.0 / re)) / sqrt(log(10.0))));
	}
	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 < -5.19260328107697459e93

    1. Initial program 49.3

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

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

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

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

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

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

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

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

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

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

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

    if -5.19260328107697459e93 < re < -2.8031941910929914e-216 or 1.90637066200656318e-105 < re < 3.1642091388740861e97

    1. Initial program 17.5

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\log 10} \cdot 2}} \cdot \frac{\log \left(re \cdot re + im \cdot im\right)}{\sqrt{\log 10}}\]
    9. Using strategy rm
    10. Applied div-inv_binary64_75717.4

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

    if -2.8031941910929914e-216 < re < 1.90637066200656318e-105

    1. Initial program 28.3

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

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

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

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

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

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

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

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

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

    if 3.1642091388740861e97 < re

    1. Initial program 51.8

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt_binary64_78251.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_binary64_82151.8

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -5.192603281076975 \cdot 10^{+93}:\\ \;\;\;\;\sqrt{\frac{1}{\sqrt{\log 10} \cdot 2}} \cdot \left(-2 \cdot \left(\left(\sqrt{0.5} \cdot \log \left(\frac{-1}{re}\right)\right) \cdot {\left(\frac{1}{{\log 10}^{3}}\right)}^{0.25}\right)\right)\\ \mathbf{elif}\;re \leq -2.8031941910929914 \cdot 10^{-216}:\\ \;\;\;\;\frac{1}{\sqrt{\log 10} \cdot 2} \cdot \left(\log \left(re \cdot re + im \cdot im\right) \cdot \frac{1}{\sqrt{\log 10}}\right)\\ \mathbf{elif}\;re \leq 1.906370662006563 \cdot 10^{-105}:\\ \;\;\;\;\frac{1}{\sqrt{\log 10} \cdot 2} \cdot \left(\left(2 \cdot \log im\right) \cdot \sqrt{\frac{1}{\log 10}}\right)\\ \mathbf{elif}\;re \leq 3.164209138874086 \cdot 10^{+97}:\\ \;\;\;\;\frac{1}{\sqrt{\log 10} \cdot 2} \cdot \left(\log \left(re \cdot re + im \cdot im\right) \cdot \frac{1}{\sqrt{\log 10}}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{1}{\sqrt{\log 10} \cdot 2}} \cdot \left(\sqrt{\frac{1}{\sqrt{\log 10} \cdot 2}} \cdot \frac{-2 \cdot \log \left(\frac{1}{re}\right)}{\sqrt{\log 10}}\right)\\ \end{array}\]

Reproduce

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