Average Error: 29.5 → 17.5
Time: 10.9s
Precision: 64
Internal Precision: 384
\[\sqrt{re \cdot re + im \cdot im}\]
\[\begin{array}{l} \mathbf{if}\;-re \le -4.31525700637997 \cdot 10^{+154}:\\ \;\;\;\;re\\ \mathbf{if}\;-re \le 7.318822897175706 \cdot 10^{+170}:\\ \;\;\;\;\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) < -4.31525700637997e+154

    1. Initial program 59.5

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

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

    if -4.31525700637997e+154 < (- re) < 7.318822897175706e+170

    1. Initial program 20.6

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

    if 7.318822897175706e+170 < (- re)

    1. Initial program 59.2

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

      \[\leadsto \color{blue}{-1 \cdot re}\]
    3. Applied simplify6.5

      \[\leadsto \color{blue}{-re}\]
  3. Recombined 3 regimes into one program.

Runtime

Time bar (total: 10.9s)Debug logProfile

herbie shell --seed '#(1070578969 3140398606 632207097 462683394 1189254563 964980650)' 
(FPCore (re im)
  :name "math.abs on complex"
  (sqrt (+ (* re re) (* im im))))