Average Error: 31.5 → 0.3
Time: 5.1s
Precision: 64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\frac{1}{\sqrt{\log 10}} \cdot \log \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}}\right) + \frac{1}{\sqrt{\log 10}} \cdot \log \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}}\right)\]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}
\frac{1}{\sqrt{\log 10}} \cdot \log \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}}\right) + \frac{1}{\sqrt{\log 10}} \cdot \log \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}}\right)
double f(double re, double im) {
        double r39808 = re;
        double r39809 = r39808 * r39808;
        double r39810 = im;
        double r39811 = r39810 * r39810;
        double r39812 = r39809 + r39811;
        double r39813 = sqrt(r39812);
        double r39814 = log(r39813);
        double r39815 = 10.0;
        double r39816 = log(r39815);
        double r39817 = r39814 / r39816;
        return r39817;
}

double f(double re, double im) {
        double r39818 = 1.0;
        double r39819 = 10.0;
        double r39820 = log(r39819);
        double r39821 = sqrt(r39820);
        double r39822 = r39818 / r39821;
        double r39823 = re;
        double r39824 = im;
        double r39825 = hypot(r39823, r39824);
        double r39826 = pow(r39825, r39822);
        double r39827 = sqrt(r39826);
        double r39828 = log(r39827);
        double r39829 = r39822 * r39828;
        double r39830 = r39829 + r39829;
        return r39830;
}

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.5

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

    \[\leadsto \frac{\log \color{blue}{\left(\mathsf{hypot}\left(re, im\right)\right)}}{\log 10}\]
  4. Using strategy rm
  5. Applied add-sqr-sqrt0.6

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

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

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

    \[\leadsto \color{blue}{\frac{1}{\sqrt{\log 10}} \cdot \frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\sqrt{\log 10}}}\]
  9. Using strategy rm
  10. Applied add-log-exp0.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)}\]
  11. Simplified0.3

    \[\leadsto \frac{1}{\sqrt{\log 10}} \cdot \log \color{blue}{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)}\]
  12. Using strategy rm
  13. Applied add-sqr-sqrt0.3

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

    \[\leadsto \frac{1}{\sqrt{\log 10}} \cdot \color{blue}{\left(\log \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}}\right) + \log \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}}\right)\right)}\]
  15. Applied distribute-lft-in0.3

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

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

Reproduce

herbie shell --seed 2020001 +o rules:numerics
(FPCore (re im)
  :name "math.log10 on complex, real part"
  :precision binary64
  (/ (log (sqrt (+ (* re re) (* im im)))) (log 10)))