Average Error: 29.7 → 16.4
Time: 29.6s
Precision: 64
Internal Precision: 384
\[\sqrt{re \cdot re + im \cdot im}\]
\[\begin{array}{l} \mathbf{if}\;re \le -2.1823101031022743 \cdot 10^{+85}:\\ \;\;\;\;-re\\ \mathbf{if}\;re \le 9.202968581060613 \cdot 10^{+146}:\\ \;\;\;\;\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.1823101031022743e+85

    1. Initial program 46.3

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

      \[\leadsto \color{blue}{-1 \cdot re}\]
    3. Applied simplify11.0

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

    if -2.1823101031022743e+85 < re < 9.202968581060613e+146

    1. Initial program 19.7

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

    if 9.202968581060613e+146 < re

    1. Initial program 57.5

      \[\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: 29.6s)Debug logProfile

herbie shell --seed '#(1070609872 3456127585 2380521889 2328837196 1765472538 734540918)' 
(FPCore (re im)
  :name "math.abs on complex"
  (sqrt (+ (* re re) (* im im))))