Average Error: 29.9 → 16.3
Time: 16.0s
Precision: 64
Internal Precision: 576
\[\sqrt{re \cdot re + im \cdot im}\]
\[\begin{array}{l} \mathbf{if}\;re \le -2.8594405816066825 \cdot 10^{+130}:\\ \;\;\;\;-re\\ \mathbf{if}\;re \le 1.4789234332494053 \cdot 10^{+144}:\\ \;\;\;\;\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 < -2.8594405816066825e+130

    1. Initial program 53.6

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

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

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

    if -2.8594405816066825e+130 < re < 1.4789234332494053e+144

    1. Initial program 19.7

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

    if 1.4789234332494053e+144 < re

    1. Initial program 56.9

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

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

Runtime

Time bar (total: 16.0s)Debug logProfile

herbie shell --seed '#(1071979731 1496239409 439705970 2863295848 982327776 189749553)' 
(FPCore (re im)
  :name "math.abs on complex"
  (sqrt (+ (* re re) (* im im))))