Average Error: 32.7 → 0.6
Time: 11.4s
Precision: 64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\frac{\sqrt{1}}{\sqrt{1}} \cdot \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{\sqrt{1}}{\sqrt{1}} \cdot \frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\log 10}
double f(double re, double im) {
        double r47529 = re;
        double r47530 = r47529 * r47529;
        double r47531 = im;
        double r47532 = r47531 * r47531;
        double r47533 = r47530 + r47532;
        double r47534 = sqrt(r47533);
        double r47535 = log(r47534);
        double r47536 = 10.0;
        double r47537 = log(r47536);
        double r47538 = r47535 / r47537;
        return r47538;
}

double f(double re, double im) {
        double r47539 = 1.0;
        double r47540 = sqrt(r47539);
        double r47541 = r47540 / r47540;
        double r47542 = re;
        double r47543 = im;
        double r47544 = hypot(r47542, r47543);
        double r47545 = log(r47544);
        double r47546 = 10.0;
        double r47547 = log(r47546);
        double r47548 = r47545 / r47547;
        double r47549 = r47541 * r47548;
        return r47549;
}

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\sqrt{1}}{\sqrt{1}} \cdot \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)))