Average Error: 31.5 → 0.3
Time: 21.5s
Precision: 64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\frac{\frac{1}{\sqrt{\log 10}}}{\sqrt{\log 10}} \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)\]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}
\frac{\frac{1}{\sqrt{\log 10}}}{\sqrt{\log 10}} \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)
double f(double re, double im) {
        double r33858 = re;
        double r33859 = r33858 * r33858;
        double r33860 = im;
        double r33861 = r33860 * r33860;
        double r33862 = r33859 + r33861;
        double r33863 = sqrt(r33862);
        double r33864 = log(r33863);
        double r33865 = 10.0;
        double r33866 = log(r33865);
        double r33867 = r33864 / r33866;
        return r33867;
}

double f(double re, double im) {
        double r33868 = 1.0;
        double r33869 = 10.0;
        double r33870 = log(r33869);
        double r33871 = sqrt(r33870);
        double r33872 = r33868 / r33871;
        double r33873 = r33872 / r33871;
        double r33874 = re;
        double r33875 = im;
        double r33876 = hypot(r33874, r33875);
        double r33877 = log(r33876);
        double r33878 = r33873 * r33877;
        return r33878;
}

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. Simplified0.6

    \[\leadsto \color{blue}{\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}}\]
  3. Using strategy rm
  4. 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}}}\]
  5. 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}}\]
  6. 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}}\]
  7. Applied times-frac0.6

    \[\leadsto \color{blue}{\frac{1}{\sqrt{\log 10}} \cdot \frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\sqrt{\log 10}}}\]
  8. Using strategy rm
  9. Applied div-inv0.4

    \[\leadsto \frac{1}{\sqrt{\log 10}} \cdot \color{blue}{\left(\log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \frac{1}{\sqrt{\log 10}}\right)}\]
  10. Using strategy rm
  11. Applied add-log-exp0.4

    \[\leadsto \frac{1}{\sqrt{\log 10}} \cdot \color{blue}{\log \left(e^{\log \left(\mathsf{hypot}\left(re, im\right)\right) \cdot \frac{1}{\sqrt{\log 10}}}\right)}\]
  12. 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)}\]
  13. Using strategy rm
  14. Applied log-pow0.4

    \[\leadsto \frac{1}{\sqrt{\log 10}} \cdot \color{blue}{\left(\frac{1}{\sqrt{\log 10}} \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)\right)}\]
  15. Applied associate-*r*0.3

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

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

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

Reproduce

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