Average Error: 29.2 → 16.3
Time: 20.7s
Precision: 64
Internal Precision: 320
\[\sqrt{re \cdot re + im \cdot im}\]
\[\begin{array}{l} \mathbf{if}\;-re \le -2.9582321962369265 \cdot 10^{+140}:\\ \;\;\;\;re\\ \mathbf{if}\;-re \le 9.368578998246488 \cdot 10^{+156}:\\ \;\;\;\;\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) < -2.9582321962369265e+140

    1. Initial program 56.4

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

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

    if -2.9582321962369265e+140 < (- re) < 9.368578998246488e+156

    1. Initial program 19.3

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

    if 9.368578998246488e+156 < (- re)

    1. Initial program 59.4

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

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

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

Runtime

Time bar (total: 20.7s)Debug logProfile

herbie shell --seed '#(1072743783 989954326 4239155542 3782239461 3602631542 1719177920)' 
(FPCore (re im)
  :name "math.abs on complex"
  (sqrt (+ (* re re) (* im im))))