Average Error: 29.4 → 16.4
Time: 2.0s
Precision: 64
Internal Precision: 320
\[\sqrt{re \cdot re + im \cdot im}\]
\[\begin{array}{l} \mathbf{if}\;re \le -1.4072346371405111 \cdot 10^{+153}:\\ \;\;\;\;-re\\ \mathbf{elif}\;re \le 7.806807759685719 \cdot 10^{+146}:\\ \;\;\;\;\sqrt{im \cdot im + re \cdot re}\\ \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.4072346371405111e+153

    1. Initial program 59.0

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

      \[\leadsto \color{blue}{-1 \cdot re}\]
    3. Simplified7.4

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

    if -1.4072346371405111e+153 < re < 7.806807759685719e+146

    1. Initial program 19.4

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

    if 7.806807759685719e+146 < re

    1. Initial program 57.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -1.4072346371405111 \cdot 10^{+153}:\\ \;\;\;\;-re\\ \mathbf{elif}\;re \le 7.806807759685719 \cdot 10^{+146}:\\ \;\;\;\;\sqrt{im \cdot im + re \cdot re}\\ \mathbf{else}:\\ \;\;\;\;re\\ \end{array}\]

Runtime

Time bar (total: 2.0s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes29.416.47.721.759.9%
herbie shell --seed 2018263 
(FPCore (re im)
  :name "math.abs on complex"
  (sqrt (+ (* re re) (* im im))))