Average Error: 31.7 → 0
Time: 16.9s
Precision: 64
Internal Precision: 1344
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le 2.37804077828903 \cdot 10^{-310}:\\ \;\;\;\;\left(1 + 1\right) + \left(\left(-1\right) + 1\right)\\ \mathbf{else}:\\ \;\;\;\;1 - 1\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original31.7
Target0
Herbie0
\[\begin{array}{l} \mathbf{if}\;x \lt 0:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if x < 2.37804077828903e-310

    1. Initial program 27.9

      \[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt27.9

      \[\leadsto \color{blue}{\sqrt{\frac{x}{x}} \cdot \sqrt{\frac{x}{x}}} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
    4. Applied prod-diff27.9

      \[\leadsto \color{blue}{(\left(\sqrt{\frac{x}{x}}\right) \cdot \left(\sqrt{\frac{x}{x}}\right) + \left(-\sqrt{x \cdot x} \cdot \frac{1}{x}\right))_* + (\left(-\sqrt{x \cdot x}\right) \cdot \left(\frac{1}{x}\right) + \left(\sqrt{x \cdot x} \cdot \frac{1}{x}\right))_*}\]
    5. Simplified16.0

      \[\leadsto \color{blue}{\left(1 + 1\right)} + (\left(-\sqrt{x \cdot x}\right) \cdot \left(\frac{1}{x}\right) + \left(\sqrt{x \cdot x} \cdot \frac{1}{x}\right))_*\]
    6. Simplified0

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

    if 2.37804077828903e-310 < x

    1. Initial program 35.6

      \[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
    2. Initial simplification0

      \[\leadsto 1 - 1\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 2.37804077828903 \cdot 10^{-310}:\\ \;\;\;\;\left(1 + 1\right) + \left(\left(-1\right) + 1\right)\\ \mathbf{else}:\\ \;\;\;\;1 - 1\\ \end{array}\]

Runtime

Time bar (total: 16.9s)Debug logProfile

herbie shell --seed 2018214 +o rules:numerics
(FPCore (x)
  :name "sqrt sqr"

  :herbie-target
  (if (< x 0) 2 0)

  (- (/ x x) (* (/ 1 x) (sqrt (* x x)))))