Average Error: 32.7 → 0.6
Time: 11.0s
Precision: 64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}\]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}
\frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}
double f(double re, double im) {
        double r92299 = re;
        double r92300 = r92299 * r92299;
        double r92301 = im;
        double r92302 = r92301 * r92301;
        double r92303 = r92300 + r92302;
        double r92304 = sqrt(r92303);
        double r92305 = log(r92304);
        double r92306 = 10.0;
        double r92307 = log(r92306);
        double r92308 = r92305 / r92307;
        return r92308;
}

double f(double re, double im) {
        double r92309 = re;
        double r92310 = im;
        double r92311 = hypot(r92309, r92310);
        double r92312 = log(r92311);
        double r92313 = 10.0;
        double r92314 = log(r92313);
        double r92315 = r92312 / r92314;
        return r92315;
}

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

    \[\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 *-un-lft-identity0.5

    \[\leadsto \frac{1}{\color{blue}{1 \cdot \sqrt{\log 10}}} \cdot \frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\sqrt{\log 10}}\]
  10. Applied *-un-lft-identity0.5

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

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

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

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

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

Reproduce

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