Average Error: 30.8 → 12.8
Time: 4.5s
Precision: 64
Internal precision: 384
\[\sqrt{re \cdot re + im \cdot im}\]
\[\begin{array}{l} \mathbf{if}\;re \le -2.674059323268242 \cdot 10^{+128}:\\ \;\;\;\;-re\\ \mathbf{if}\;re \le -2.321564696919607 \cdot 10^{-245}:\\ \;\;\;\;\sqrt{re \cdot re + im \cdot im}\\ \mathbf{if}\;re \le -2.837848394186995 \cdot 10^{-306}:\\ \;\;\;\;im\\ \mathbf{if}\;re \le 2.540188601643307 \cdot 10^{+151}:\\ \;\;\;\;\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 4 regimes.
  2. if re < -2.674059323268242e+128

    1. Initial program 53.9

      \[\sqrt{re \cdot re + im \cdot im}\]
    2. Applied taylor 0

      \[\leadsto -1 \cdot re\]
    3. Taylor expanded around -inf 0

      \[\leadsto \color{blue}{-1 \cdot re}\]
    4. Applied simplify 0

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

    if -2.674059323268242e+128 < re < -2.321564696919607e-245 or -2.837848394186995e-306 < re < 2.540188601643307e+151

    1. Initial program 19.1

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

    if -2.321564696919607e-245 < re < -2.837848394186995e-306

    1. Initial program 45.8

      \[\sqrt{re \cdot re + im \cdot im}\]
    2. Applied taylor 0

      \[\leadsto im\]
    3. Taylor expanded around 0 0

      \[\leadsto \color{blue}{im}\]

    if 2.540188601643307e+151 < re

    1. Initial program 59.1

      \[\sqrt{re \cdot re + im \cdot im}\]
    2. Applied taylor 0

      \[\leadsto re\]
    3. Taylor expanded around inf 0

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

Runtime

Time bar (total: 4.5s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1064524629 4159152179 2999149171 575749698 4006532819 692958815)'
(FPCore (re im)
  :name "math.abs on complex"
  (sqrt (+ (* re re) (* im im))))