Average Error: 30.9 → 0.4
Time: 28.1s
Precision: 64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\frac{1}{\sqrt{\log 10}} \cdot \left(\frac{1}{\sqrt{\log 10}} \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)\right)\]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}
\frac{1}{\sqrt{\log 10}} \cdot \left(\frac{1}{\sqrt{\log 10}} \cdot \log \left(\mathsf{hypot}\left(re, im\right)\right)\right)
double f(double re, double im) {
        double r671302 = re;
        double r671303 = r671302 * r671302;
        double r671304 = im;
        double r671305 = r671304 * r671304;
        double r671306 = r671303 + r671305;
        double r671307 = sqrt(r671306);
        double r671308 = log(r671307);
        double r671309 = 10.0;
        double r671310 = log(r671309);
        double r671311 = r671308 / r671310;
        return r671311;
}

double f(double re, double im) {
        double r671312 = 1.0;
        double r671313 = 10.0;
        double r671314 = log(r671313);
        double r671315 = sqrt(r671314);
        double r671316 = r671312 / r671315;
        double r671317 = re;
        double r671318 = im;
        double r671319 = hypot(r671317, r671318);
        double r671320 = log(r671319);
        double r671321 = r671316 * r671320;
        double r671322 = r671316 * r671321;
        return r671322;
}

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 30.9

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

    \[\leadsto \color{blue}{\frac{1}{\sqrt{\log 10}} \cdot \frac{\log \left(\mathsf{hypot}\left(re, im\right)\right)}{\sqrt{\log 10}}}\]
  7. Using strategy rm
  8. 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)}\]
  9. Final simplification0.4

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

Reproduce

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