Average Error: 32.7 → 0.0
Time: 15.1s
Precision: 64
Internal Precision: 1344
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;\left|x\right| \cdot \frac{-1}{x} + 1 \le 0.0:\\ \;\;\;\;\left|x\right| \cdot \frac{-1}{x} + 1\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{(\left(\left|x\right|\right) \cdot \left(\frac{-1}{x}\right) + 1)_*}\right)\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

  1. Split input into 2 regimes
  2. if (+ (* (fabs x) (/ -1 x)) 1) < 0.0

    1. Initial program 32.2

      \[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
    2. Applied simplify61.9

      \[\leadsto \color{blue}{(\left(\left|x\right|\right) \cdot \left(\frac{-1}{x}\right) + 1)_*}\]
    3. Using strategy rm
    4. Applied fma-udef0.0

      \[\leadsto \color{blue}{\left|x\right| \cdot \frac{-1}{x} + 1}\]

    if 0.0 < (+ (* (fabs x) (/ -1 x)) 1)

    1. Initial program 33.0

      \[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
    2. Applied simplify8.3

      \[\leadsto \color{blue}{(\left(\left|x\right|\right) \cdot \left(\frac{-1}{x}\right) + 1)_*}\]
    3. Using strategy rm
    4. Applied add-log-exp0.0

      \[\leadsto \color{blue}{\log \left(e^{(\left(\left|x\right|\right) \cdot \left(\frac{-1}{x}\right) + 1)_*}\right)}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 15.1s)Debug logProfile

herbie shell --seed '#(1071373924 2949776965 1885069702 3247780810 90874544 2263903749)' +o rules:numerics
(FPCore (x)
  :name "sqrt sqr"

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

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