Average Error: 31.3 → 0.2
Time: 5.2s
Precision: binary64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10} \]
\[\log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{\sqrt{\frac{1}{\log 10}}}{\sqrt{\log 10}}\right)}\right) \]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}
\log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{\sqrt{\frac{1}{\log 10}}}{\sqrt{\log 10}}\right)}\right)
(FPCore (re im)
 :precision binary64
 (/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))
(FPCore (re im)
 :precision binary64
 (log (pow (hypot re im) (/ (sqrt (/ 1.0 (log 10.0))) (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) {
	return log(pow(hypot(re, im), (sqrt(1.0 / log(10.0)) / sqrt(log(10.0)))));
}

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 31.3

    \[\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-sqr-sqrt_binary640.6

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

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

    \[\leadsto \frac{\color{blue}{1 \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)}}{\sqrt{\log 10} \cdot \sqrt{\log 10}} \]
  6. Applied times-frac_binary640.5

    \[\leadsto \color{blue}{\frac{1}{\sqrt{\log 10}} \cdot \frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\sqrt{\log 10}}} \]
  7. Applied add-log-exp_binary640.5

    \[\leadsto \frac{1}{\sqrt{\log 10}} \cdot \color{blue}{\log \left(e^{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\sqrt{\log 10}}}\right)} \]
  8. Simplified0.3

    \[\leadsto \frac{1}{\sqrt{\log 10}} \cdot \log \color{blue}{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\sqrt{\frac{1}{\log 10}}\right)}\right)} \]
  9. Applied add-log-exp_binary640.3

    \[\leadsto \color{blue}{\log \left(e^{\frac{1}{\sqrt{\log 10}} \cdot \log \left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\sqrt{\frac{1}{\log 10}}\right)}\right)}\right)} \]
  10. Simplified0.2

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

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

Reproduce

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