Average Error: 28.9 → 16.2
Time: 21.4s
Precision: 64
Internal Precision: 320
\[\sqrt{re \cdot re + im \cdot im}\]
\[\begin{array}{l} \mathbf{if}\;re \le -1.293482981552853 \cdot 10^{+154}:\\ \;\;\;\;-re\\ \mathbf{if}\;re \le 4.2147853830585397 \cdot 10^{+124}:\\ \;\;\;\;\sqrt{re \cdot re + im \cdot im}\\ \mathbf{else}:\\ \;\;\;\;re\\ \end{array}\]

Error

Bits error versus re

Bits error versus im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if re < -1.293482981552853e+154

    1. Initial program 59.3

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

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

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

    if -1.293482981552853e+154 < re < 4.2147853830585397e+124

    1. Initial program 19.1

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

    if 4.2147853830585397e+124 < re

    1. Initial program 51.8

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

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

Runtime

Time bar (total: 21.4s)Debug logProfile

herbie shell --seed 2018296 
(FPCore (re im)
  :name "math.abs on complex"
  (sqrt (+ (* re re) (* im im))))