Average Error: 29.5 → 17.4
Time: 9.6s
Precision: 64
Internal Precision: 384
\[\sqrt{re \cdot re + im \cdot im}\]
\[\begin{array}{l} \mathbf{if}\;re \le -8.428091631446996 \cdot 10^{+134}:\\ \;\;\;\;-re\\ \mathbf{if}\;re \le -7.392785918139996 \cdot 10^{-177}:\\ \;\;\;\;\sqrt{re \cdot re + im \cdot im}\\ \mathbf{if}\;re \le -7.064547532188703 \cdot 10^{-244}:\\ \;\;\;\;-re\\ \mathbf{if}\;re \le 1.2724750306247727 \cdot 10^{+154}:\\ \;\;\;\;\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 < -8.428091631446996e+134 or -7.392785918139996e-177 < re < -7.064547532188703e-244

    1. Initial program 48.5

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

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

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

    if -8.428091631446996e+134 < re < -7.392785918139996e-177 or -7.064547532188703e-244 < re < 1.2724750306247727e+154

    1. Initial program 18.3

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

    if 1.2724750306247727e+154 < re

    1. Initial program 59.5

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

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

Runtime

Time bar (total: 9.6s)Debug logProfile

herbie shell --seed '#(1070355188 2193211668 3977393919 3454156579 3755371326 1656365382)' 
(FPCore (re im)
  :name "math.abs on complex"
  (sqrt (+ (* re re) (* im im))))