Average Error: 35.8 → 24.5
Time: 7.4s
Precision: 64
Internal Precision: 320
\[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -5.77126452019715 \cdot 10^{+140}:\\ \;\;\;\;-x\\ \mathbf{elif}\;x \le 1.6019685912508635 \cdot 10^{+155}:\\ \;\;\;\;\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if x < -5.77126452019715e+140

    1. Initial program 56.3

      \[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
    2. Taylor expanded around -inf 15.6

      \[\leadsto \color{blue}{-1 \cdot x}\]
    3. Simplified15.6

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

    if -5.77126452019715e+140 < x < 1.6019685912508635e+155

    1. Initial program 28.0

      \[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]

    if 1.6019685912508635e+155 < x

    1. Initial program 59.2

      \[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
    2. Taylor expanded around inf 13.4

      \[\leadsto \color{blue}{x}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification24.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -5.77126452019715 \cdot 10^{+140}:\\ \;\;\;\;-x\\ \mathbf{elif}\;x \le 1.6019685912508635 \cdot 10^{+155}:\\ \;\;\;\;\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]

Runtime

Time bar (total: 7.4s)Debug log

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