Average Error: 29.2 → 16.8
Time: 16.4s
Precision: 64
Internal Precision: 384
\[\sqrt{re \cdot re + im \cdot im}\]
\[\begin{array}{l} \mathbf{if}\;re \le -1.4471521473484649 \cdot 10^{+72}:\\ \;\;\;\;-re\\ \mathbf{if}\;re \le 1.9709800913571092 \cdot 10^{+152}:\\ \;\;\;\;\sqrt{re \cdot re + im \cdot im}\\ \mathbf{else}:\\ \;\;\;\;re\\ \end{array}\]

Error

Bits error versus re

Bits error versus im

Derivation

  1. Split input into 3 regimes
  2. if re < -1.4471521473484649e+72

    1. Initial program 44.0

      \[\sqrt{re \cdot re + im \cdot im}\]
    2. Taylor expanded around -inf 11.4

      \[\leadsto \color{blue}{-1 \cdot re}\]
    3. Applied simplify11.4

      \[\leadsto \color{blue}{-re}\]

    if -1.4471521473484649e+72 < re < 1.9709800913571092e+152

    1. Initial program 20.0

      \[\sqrt{re \cdot re + im \cdot im}\]

    if 1.9709800913571092e+152 < re

    1. Initial program 58.4

      \[\sqrt{re \cdot re + im \cdot im}\]
    2. Taylor expanded around inf 7.1

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

Runtime

Time bar (total: 16.4s)Debug logProfile

herbie shell --seed '#(1063027428 1192549564 1443466578 604016274 3637110559 1698629644)' 
(FPCore (re im)
  :name "math.abs on complex"
  (sqrt (+ (* re re) (* im im))))