Average Error: 30.0 → 17.3
Time: 4.8s
Precision: 64
Internal Precision: 384
\[\sqrt{re \cdot re + im \cdot im}\]
\[\begin{array}{l} \mathbf{if}\;-re \le -1.111937827625308 \cdot 10^{+152}:\\ \;\;\;\;re\\ \mathbf{if}\;-re \le 3.097092014533353 \cdot 10^{+115}:\\ \;\;\;\;\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.111937827625308e+152

    1. Initial program 58.8

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

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

    if -1.111937827625308e+152 < (- re) < 3.097092014533353e+115

    1. Initial program 20.6

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

    if 3.097092014533353e+115 < (- re)

    1. Initial program 50.1

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

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

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

Runtime

Time bar (total: 4.8s)Debug logProfile

herbie shell --seed '#(1070100504 930361288 1279167582 284574201 1450237281 2578255382)' 
(FPCore (re im)
  :name "math.abs on complex"
  (sqrt (+ (* re re) (* im im))))