Average Error: 30.1 → 17.1
Time: 6.1s
Precision: 64
Internal Precision: 320
\[\sqrt{a \cdot a + b \cdot b}\]
\[\begin{array}{l} \mathbf{if}\;a \le -5.147403001023096 \cdot 10^{+84}:\\ \;\;\;\;-a\\ \mathbf{if}\;a \le 2.103882195134527 \cdot 10^{+123}:\\ \;\;\;\;\sqrt{a \cdot a + b \cdot b}\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if a < -5.147403001023096e+84

    1. Initial program 45.3

      \[\sqrt{a \cdot a + b \cdot b}\]
    2. Taylor expanded around -inf 10.5

      \[\leadsto \color{blue}{-1 \cdot a}\]
    3. Applied simplify10.5

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

    if -5.147403001023096e+84 < a < 2.103882195134527e+123

    1. Initial program 20.5

      \[\sqrt{a \cdot a + b \cdot b}\]

    if 2.103882195134527e+123 < a

    1. Initial program 52.6

      \[\sqrt{a \cdot a + b \cdot b}\]
    2. Taylor expanded around inf 10.1

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

Runtime

Time bar (total: 6.1s)Debug log

herbie shell --seed '#(2775764126 3555076145 3898259844 1891440260 2599947619 1948460636)' 
(FPCore (a b)
  :name "sqrt(a*a + b*b)"
  (sqrt (+ (* a a) (* b b))))