Average Error: 33.9 → 23.8
Time: 10.1s
Precision: 64
Internal Precision: 2368
\[\sqrt{x \cdot x + y \cdot y} - x\]
\[\begin{array}{l} \mathbf{if}\;x \le -5.147403001023096 \cdot 10^{+84}:\\ \;\;\;\;\left(-x\right) - x\\ \mathbf{elif}\;x \le 6.294595312968477 \cdot 10^{+146}:\\ \;\;\;\;\sqrt{x \cdot x + y \cdot y} - x\\ \mathbf{else}:\\ \;\;\;\;x - x\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

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.147403001023096e+84

    1. Initial program 45.3

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

      \[\leadsto \color{blue}{-1 \cdot x} - x\]
    3. Simplified10.5

      \[\leadsto \color{blue}{\left(-x\right)} - x\]

    if -5.147403001023096e+84 < x < 6.294595312968477e+146

    1. Initial program 25.4

      \[\sqrt{x \cdot x + y \cdot y} - x\]

    if 6.294595312968477e+146 < x

    1. Initial program 60.9

      \[\sqrt{x \cdot x + y \cdot y} - x\]
    2. Taylor expanded around inf 34.4

      \[\leadsto \color{blue}{x} - x\]
  3. Recombined 3 regimes into one program.
  4. Final simplification23.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -5.147403001023096 \cdot 10^{+84}:\\ \;\;\;\;\left(-x\right) - x\\ \mathbf{elif}\;x \le 6.294595312968477 \cdot 10^{+146}:\\ \;\;\;\;\sqrt{x \cdot x + y \cdot y} - x\\ \mathbf{else}:\\ \;\;\;\;x - x\\ \end{array}\]

Runtime

Time bar (total: 10.1s)Debug log

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