Average Error: 32.7 → 0.6
Time: 6.1s
Precision: binary64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10} \]
\[\begin{array}{l} t_0 := \sqrt{\log 10}\\ \frac{\frac{1}{t_0}}{\frac{t_0}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}} \end{array} \]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}
\begin{array}{l}
t_0 := \sqrt{\log 10}\\
\frac{\frac{1}{t_0}}{\frac{t_0}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}}
\end{array}
(FPCore (re im)
 :precision binary64
 (/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (sqrt (log 10.0)))) (/ (/ 1.0 t_0) (/ t_0 (log (hypot re im))))))
double code(double re, double im) {
	return log(sqrt((re * re) + (im * im))) / log(10.0);
}
double code(double re, double im) {
	double t_0 = sqrt(log(10.0));
	return (1.0 / t_0) / (t_0 / log(hypot(re, im)));
}

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. Initial program 32.7

    \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10} \]
  2. Simplified0.6

    \[\leadsto \color{blue}{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}} \]
  3. Applied add-cube-cbrt_binary640.6

    \[\leadsto \frac{\log \color{blue}{\left(\left(\sqrt[3]{\mathsf{hypot}\left(re, im\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(re, im\right)}\right) \cdot \sqrt[3]{\mathsf{hypot}\left(re, im\right)}\right)}}{\log 10} \]
  4. Applied pow3_binary640.6

    \[\leadsto \frac{\log \color{blue}{\left({\left(\sqrt[3]{\mathsf{hypot}\left(re, im\right)}\right)}^{3}\right)}}{\log 10} \]
  5. Applied log-pow_binary640.6

    \[\leadsto \frac{\color{blue}{3 \cdot \log \left(\sqrt[3]{\mathsf{hypot}\left(re, im\right)}\right)}}{\log 10} \]
  6. Applied associate-/l*_binary640.6

    \[\leadsto \color{blue}{\frac{3}{\frac{\log 10}{\log \left(\sqrt[3]{\mathsf{hypot}\left(re, im\right)}\right)}}} \]
  7. Applied pow1/3_binary640.9

    \[\leadsto \frac{3}{\frac{\log 10}{\log \color{blue}{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{0.3333333333333333}\right)}}} \]
  8. Applied log-pow_binary640.9

    \[\leadsto \frac{3}{\frac{\log 10}{\color{blue}{0.3333333333333333 \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)}}} \]
  9. Applied add-sqr-sqrt_binary640.9

    \[\leadsto \frac{3}{\frac{\color{blue}{\sqrt{\log 10} \cdot \sqrt{\log 10}}}{0.3333333333333333 \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)}} \]
  10. Applied times-frac_binary641.4

    \[\leadsto \frac{3}{\color{blue}{\frac{\sqrt{\log 10}}{0.3333333333333333} \cdot \frac{\sqrt{\log 10}}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}}} \]
  11. Applied associate-/r*_binary641.3

    \[\leadsto \color{blue}{\frac{\frac{3}{\frac{\sqrt{\log 10}}{0.3333333333333333}}}{\frac{\sqrt{\log 10}}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}}} \]
  12. Simplified0.6

    \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt{\log 10}}}}{\frac{\sqrt{\log 10}}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}} \]
  13. Final simplification0.6

    \[\leadsto \frac{\frac{1}{\sqrt{\log 10}}}{\frac{\sqrt{\log 10}}{\log \left(\mathsf{hypot}\left(re, im\right)\right)}} \]

Reproduce

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