Average Error: 29.7 → 16.6
Time: 10.9s
Precision: 64
Internal Precision: 320
\[\sqrt{re \cdot re + im \cdot im}\]
\[\begin{array}{l} \mathbf{if}\;re \le -7.702493838381082 \cdot 10^{+139}:\\ \;\;\;\;-re\\ \mathbf{if}\;re \le 1.8988390560210017 \cdot 10^{+126}:\\ \;\;\;\;\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 < -7.702493838381082e+139

    1. Initial program 55.8

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

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

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

    if -7.702493838381082e+139 < re < 1.8988390560210017e+126

    1. Initial program 20.0

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

    if 1.8988390560210017e+126 < re

    1. Initial program 52.4

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

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

Runtime

Time bar (total: 10.9s)Debug logProfile

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