Average Error: 30.6 → 17.2
Time: 1.2m
Precision: 64
Internal Precision: 384
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\begin{array}{l} \mathbf{if}\;re \le -4.530751028329648 \cdot 10^{+71}:\\ \;\;\;\;\frac{\log \left(-re\right)}{\log 10}\\ \mathbf{if}\;re \le 2.1379952367367442 \cdot 10^{+116}:\\ \;\;\;\;\sqrt{\frac{\frac{1}{2}}{\sqrt{\log 10}}} \cdot \left(\sqrt{\frac{\frac{1}{2}}{\sqrt{\log 10}}} \cdot \frac{\log \left(re \cdot re + im \cdot im\right)}{\sqrt{\log 10}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\log re}{\log 10}\\ \end{array}\]

Error

Bits error versus re

Bits error versus im

Derivation

  1. Split input into 3 regimes
  2. if re < -4.530751028329648e+71

    1. Initial program 46.0

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Taylor expanded around -inf 10.3

      \[\leadsto \frac{\log \color{blue}{\left(-1 \cdot re\right)}}{\log 10}\]
    3. Applied simplify10.3

      \[\leadsto \color{blue}{\frac{\log \left(-re\right)}{\log 10}}\]

    if -4.530751028329648e+71 < re < 2.1379952367367442e+116

    1. Initial program 21.3

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

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\color{blue}{\sqrt{\log 10} \cdot \sqrt{\log 10}}}\]
    4. Applied pow1/221.3

      \[\leadsto \frac{\log \color{blue}{\left({\left(re \cdot re + im \cdot im\right)}^{\frac{1}{2}}\right)}}{\sqrt{\log 10} \cdot \sqrt{\log 10}}\]
    5. Applied log-pow21.3

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \log \left(re \cdot re + im \cdot im\right)}}{\sqrt{\log 10} \cdot \sqrt{\log 10}}\]
    6. Applied times-frac21.3

      \[\leadsto \color{blue}{\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \frac{\log \left(re \cdot re + im \cdot im\right)}{\sqrt{\log 10}}}\]
    7. Using strategy rm
    8. Applied add-sqr-sqrt21.3

      \[\leadsto \color{blue}{\left(\sqrt{\frac{\frac{1}{2}}{\sqrt{\log 10}}} \cdot \sqrt{\frac{\frac{1}{2}}{\sqrt{\log 10}}}\right)} \cdot \frac{\log \left(re \cdot re + im \cdot im\right)}{\sqrt{\log 10}}\]
    9. Applied associate-*l*21.2

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{2}}{\sqrt{\log 10}}} \cdot \left(\sqrt{\frac{\frac{1}{2}}{\sqrt{\log 10}}} \cdot \frac{\log \left(re \cdot re + im \cdot im\right)}{\sqrt{\log 10}}\right)}\]

    if 2.1379952367367442e+116 < re

    1. Initial program 52.1

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Taylor expanded around inf 8.0

      \[\leadsto \frac{\log \color{blue}{re}}{\log 10}\]
  3. Recombined 3 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 1.2m)Debug logProfile

herbie shell --seed '#(1063027428 1192549564 1443466578 604016274 3637110559 1698629644)' 
(FPCore (re im)
  :name "math.log10 on complex, real part"
  (/ (log (sqrt (+ (* re re) (* im im)))) (log 10)))